-
-
Notifications
You must be signed in to change notification settings - Fork 9.8k
Sandboxes: Typecheck check production storybook packages #32447
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 4 commits
f34122d
4c198ed
a2ac7da
6b6e9b6
730f279
6fa69bd
f9c3d71
cabc59e
59007d8
f6763fb
d5a5789
4051541
0509e56
8db83ae
17d3f63
8a7a695
7c8f521
ba719e6
816d794
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -93,6 +93,8 @@ interface TypeScriptPropsProps { | |
| } | ||
|
|
||
| export const TypeScriptProps: FC<TypeScriptPropsProps> = () => <div>TypeScript!</div>; | ||
| // eslint-disable-next-line @typescript-eslint/ban-ts-comment -- we can't expect error as it isn't an error in 18 (development) but it is in 19 (sandbox) | ||
| // @ts-ignore not present on react 19 | ||
|
Comment on lines
+96
to
+97
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should be fixed, if we do #32406 |
||
| TypeScriptProps.defaultProps = { | ||
| any: 'Any value', | ||
| string: 'A string value', | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,24 @@ | ||||||
| import { access } from 'node:fs/promises'; | ||||||
|
|
||||||
| import type { Task } from '../task'; | ||||||
| import { exec } from '../utils/exec'; | ||||||
|
|
||||||
| async function pathExists(path: string) { | ||||||
| try { | ||||||
| await access(path); | ||||||
| return true; | ||||||
| } catch { | ||||||
| return false; | ||||||
| } | ||||||
| } | ||||||
|
|
||||||
| export const checkSandbox: Task = { | ||||||
| description: 'Typecheck the a sandbox', | ||||||
|
||||||
| description: 'Typecheck the a sandbox', | |
| description: 'Typecheck a sandbox', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this one I will give you
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -217,6 +217,9 @@ export const init: Task['run'] = async ( | |
| case '@storybook/angular': | ||
| await prepareAngularSandbox(cwd, template.name); | ||
| break; | ||
| case '@storybook/react-vite': | ||
| await prepareViteSandbox(cwd); | ||
| break; | ||
| default: | ||
| } | ||
|
|
||
|
|
@@ -878,6 +881,30 @@ async function prepareReactNativeWebSandbox(cwd: string) { | |
| } | ||
| } | ||
|
|
||
| async function prepareViteSandbox(cwd: string) { | ||
| const packageJsonPath = join(cwd, 'package.json'); | ||
| const packageJson = await readJson(packageJsonPath); | ||
|
|
||
| packageJson.scripts = { | ||
| ...packageJson.scripts, | ||
| typecheck: 'yarn tsc -p tsconfig.app.json', | ||
| }; | ||
| await writeFile(packageJsonPath, JSON.stringify(packageJson, null, 2)); | ||
|
|
||
| const tsConfigPath = join(cwd, 'tsconfig.app.json'); | ||
| const tsConfigContent = await readFile(tsConfigPath, { encoding: 'utf-8' }); | ||
| // This does not preserve comments, but that shouldn't be an issue for sandboxes | ||
| const tsConfigJson = JSON5.parse(tsConfigContent); | ||
|
|
||
| // We use enums | ||
| tsConfigJson.compilerOptions.erasableSyntaxOnly = false; | ||
| // Lots of unnecessary imports of react that need fixing | ||
| tsConfigJson.compilerOptions.noUnusedLocals = false; | ||
| // Means we can check our own public types | ||
| tsConfigJson.compilerOptions.skipLibCheck = false; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. style: Setting
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. shush greptile, that's the point! you managed to get that in your summary also if there are type errors in the third-party packages we should be fixing them |
||
| await writeFile(tsConfigPath, JSON.stringify(tsConfigJson, null, 2)); | ||
| } | ||
|
|
||
| async function prepareAngularSandbox(cwd: string, templateName: string) { | ||
| const angularJson = await readJson(join(cwd, 'angular.json')); | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
style: Consider using underscore prefix for unused parameters (
_padding,_margin) as a TypeScript convention instead of ts-ignore, which would be more explicit about intentional non-usage