-
-
Notifications
You must be signed in to change notification settings - Fork 9.3k
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
[bugfix] Check for undefined before reading property in extractArgTypes.ts #18710
[bugfix] Check for undefined before reading property in extractArgTypes.ts #18710
Conversation
☁️ Nx Cloud ReportCI is running/has finished running commands for commit dbef1ab. As they complete they will appear below. Click to see the status, the terminal output, and the build insights. 📂 See all runs for this branch ✅ Successfully ran 1 targetSent with 💌 from NxCloud. |
Thanks! I run into the same problem😉 |
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.
Hey @ProjektGopher thank you so much for your contribution! 🚀
Hey @ndelangen could you check whether this change has to be done in other frameworks as well? Or at least Vue3? Thanks! |
For anyone who needs to patch this before the PR gets merged, here's a useful workaround that'll get your CI builds passing as well: Create #!/usr/bin/env node
'use strict';
var fs = require('fs')
var path = require('path')
const patches = [
{ // app/vue/src/client/docs/extractArgTypes.ts (cjs)
file: path.resolve(__dirname, '../node_modules/@storybook/vue/dist/cjs/client/docs/extractArgTypes.js'),
find: "var matched = Array.isArray(values) && values.length && type.name !== 'enum';",
replace: "var matched = Array.isArray(values) && values.length && type && type.name !== 'enum';"
},
{ // app/vue/src/client/docs/extractArgTypes.ts (esm)
file: path.resolve(__dirname, '../node_modules/@storybook/vue/dist/esm/client/docs/extractArgTypes.js'),
find: "var matched = Array.isArray(values) && values.length && type.name !== 'enum';",
replace: "var matched = Array.isArray(values) && values.length && type && type.name !== 'enum';"
},
]
for (const patch of patches) {
fs.readFile(patch.file, 'utf8', (err,data) => {
if (err) {
return console.log(err);
}
const result = data.replace(patch.find, patch.replace);
fs.writeFile(patch.file, result, 'utf8', (err) => {
if (err) return console.log(err);
});
});
} Add this command to the "patch:storybook": "node .storybook/patch.js" Add this command to your CI config right after installing dependencies - run:
name: Patch Storybook
command: npm run patch:storybook From now until patch, you can simply run |
The code in question does not appear anywhere else. @yannbf |
…gTypes [bugfix] Check for undefined before reading property in extractArgTypes.ts
Issue:
The
type
property onDocgenInfo
is optional. By casting toany
we lose the prompt thattype
could beundefined
. So in some cases we're trying to read the propertyname
ofundefined
.What I did