-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
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
Storybook warns when function named add is called in story file. #12208
Comments
add
is called in story file with non-string first arg.
That's exactly right. I think fix here is to create a
|
Hi everyone! Seems like there hasn't been much going on in this issue lately. If there are still questions, comments, or bugs, please feel free to continue the discussion. Unfortunately, we don't have time to get to every issue. We are always open to contributions so please send us a pull request if you would like to help. Inactive issues will be closed after 30 days. Thanks! |
This is still very much a bug! We're having problems with |
Seems like a workaround is to assign the number to a variable ahead of time, e.g.:
|
I encountered the same problem with My workaround was to use - dayjs().add(1, 'day').format('YYYY-MM-DD')
+ dayjs().subtract(-1, 'day').format('YYYY-MM-DD') |
Same issue (and giving a var as first arg to add workaround) still persists today with
|
I can reproduce this problem with the webpack5 builder at 6.4.18 as well. Suspecting the fix in #11920 didn't quite fully do it. |
I just hit this as well (upgrading from 6.4.0-beta.11 to 6.4.19). I'm using storybook-builder-vite for what it's worth. @jaredcwhite's workaround worked for me (thanks!). |
same here with |
A silly workaround 🙃 dayjs().subtract(-1, 'day'); |
Discovered the same here with dayjs().add(). Storybook v6.5.3 |
I face the same issue with moment: module.exports = {
webpackFinal: config => {
return {
...config,
resolve: {
...config.resolve,
modules: [...(config.resolve.modules || []), path.resolve('./src')],
},
};
},
stories: ['../src/**/*.stories.mdx', '../src/**/*.stories.@(js|jsx|ts|tsx)'],
addons: [
'@storybook/addon-links',
'@storybook/addon-essentials',
'@storybook/addon-interactions',
'@storybook/preset-create-react-app',
],
framework: '@storybook/react',
core: {
builder: '@storybook/builder-webpack5',
},
}; node version - 16.14.0 packages:
btw, previously I used ejected CRA and manually merged ejected CRA webpack config with storybook config and didn't have this issue. Currently we've forked CRA and use |
Ermahgerd!! I just released https://github.com/storybookjs/storybook/releases/tag/v7.0.0-alpha.34 containing PR #18930 that references this issue. Upgrade today to the
Closing this issue. Please re-open if you think there's still more to do. |
@shilman is it possible to merge this PR to LTS version? 6.15 for example |
I found another solution based on your reply! Instead of having to define an additional variable to pass down, you can use a template literal:
|
This needs to be backported to v6 |
Storybook issues a warning when any function named
add
is called with a non-string first arg. The warning happens at build time, and doesn't trigger if the add function isn't being called as a property (ie must beblah.add(1,2)
).The warning generated:
To Reproduce
yarn storybook
The warning message should show up in the console during build. The warning is also issued without including the first line (so the second line is what actually triggers it), but I included it just to prove that it fails on valid code.
Expected behavior
There shouldn't be a build time warning; this is valid code.
System:
Additional context
From my reading of the warning (
handleADD
in@storybook/source-loader/dist/abstract-syntax-tree/parse-helpers.js
), it looks like this is caused by some special parsing of storybook files. My guess is the parser is trying to pull outstoriesOf(...).add(
calls. The error message,string.toLowerCase is not a function
, jives with this: storybook's add takes a string as the first param, but I pass in a number. To drive this home, the build doesn't issue this warning if you change the line added toblah.add("1", "2")
.Workaround
Ran into this because we were defining a constant using
moment.add(...)
. Changing the property access to use bracket notation (iemoment["add"](...)
fixed the issue.The text was updated successfully, but these errors were encountered: