Skip to content

Commit

Permalink
Merge pull request #22312 from usrrname/22176-csf-tools-strict-ts
Browse files Browse the repository at this point in the history
Typescript: Migrate `@storybook/csf-tools` to strict TS
  • Loading branch information
shilman authored May 1, 2023
2 parents 51f7cd7 + ef5206b commit f0af303
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
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/**/*"]
}

0 comments on commit f0af303

Please sign in to comment.