Skip to content
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

Typescript: Migrate @storybook/csf-tools to strict TS #22312

Merged
merged 4 commits into from
May 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion code/lib/csf-tools/src/ConfigFile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,7 @@ export class ConfigFile {

appendValueToArray(path: string[], value: any) {
const node = this.valueToNode(value);
this.appendNodeToArray(path, node);
if (node) this.appendNodeToArray(path, node);
}

appendNodeToArray(path: string[], node: t.Expression) {
Expand Down
2 changes: 1 addition & 1 deletion code/lib/csf-tools/src/babelParse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ function parseWithFlowOrTypescript(source: string, parserOptions: babelParser.Pa
// Merge the provided parserOptions with the custom parser plugins
const mergedParserOptions = {
...parserOptions,
plugins: [...parserOptions.plugins, ...parserPlugins],
plugins: [...(parserOptions.plugins ?? []), ...parserPlugins],
};

return babelParser.parse(source, mergedParserOptions);
Expand Down
2 changes: 1 addition & 1 deletion code/lib/csf-tools/src/getStorySortParameter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ export const getStorySortParameter = (previewCode: string) => {
node.declaration.declarations.forEach((decl) => {
if (t.isVariableDeclarator(decl) && t.isIdentifier(decl.id)) {
const { name: exportName } = decl.id;
if (exportName === 'parameters') {
if (exportName === 'parameters' && decl.init) {
const paramsObject = stripTSModifiers(decl.init);
storySort = parseParameters(paramsObject);
}
Expand Down
2 changes: 1 addition & 1 deletion code/lib/csf-tools/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"strict": false
"strict": true
},
"include": ["src/**/*"]
}