storybook: Docgen: Errors on TS components whose names are keywords
It appears that a change introduced in 6.0.0-beta.24 is causing my storybook to fail to load:

I’m not sure exactly what is going on here because source maps don’t seem to be working.
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 17 (4 by maintainers)
Commits related to this issue
- resolve storybook runtime error: "Unexpected token 'default'" - https://github.com/storybookjs/storybook/issues/11419#issuecomment-658969643 — committed to baurine/tidb-dashboard by baurine 4 years ago
- ci: IT COMPILES! When static properties are assigned to a component when it is exported this seems to cause issues. Separating components from export fixed this. See: https://github.com/storybookjs/s... — committed to cultureamp/kaizen-design-system by ActuallyACat 4 years ago
- Separate export from declaration in all pages. Workaround for fixing this Storybook issue: https://github.com/storybookjs/storybook/issues/11419#issuecomment-658969643 — committed to OasisDEX/oasis-borrow by ferni 2 years ago
- Uniswap widget style (#922) * Organize css selectors. * Update RouterContext import in Storybook. * Separate export from declaration in all pages. Workaround for fixing this Storybook issue:... — committed to OasisDEX/oasis-borrow by ferni 2 years ago
- Uniswap widget style (#922) * Organize css selectors. * Update RouterContext import in Storybook. * Separate export from declaration in all pages. Workaround for fixing this Storybook issue:... — committed to iamsalmandev/gsu-borrow by ferni 2 years ago
This seems to happen in cases where a static property is assigned to a component which is exported at its declaration site, e.g.
A workaround seems to be separating the export from the declaration:
Class components with static properties suffer from the same problem:
and the workaround is the same:
I also experience this when my 'default.[exported-component]` is not understood by Storybook, which should be consider as unacceptable because the way I write code should not be affected by how a document-purpose framework works.
it is happening again for us
Uncaught SyntaxError: Unexpected token '.'can we disable react doc gen?
for us, the error was because we have some old stories without using CSF format
we just moved most of them to CSF and everything is fixed
switch.stories.jsx:
I my case the problem was in naming of component - default.tsx, changed it to simple.tsx resolved this issue.
Still getting this error on storybook v6.0.21 (updating from v5.3.21) and @pelotom workaround works. It is definitely related to assigning after exporting (not only in the story, but anything the story imports).
I tried to create a minimum reproducible project: https://github.com/DanielHoffmann/storybook-bug
to run:
but I could NOT reproduce the bug in a clean project. I imagine the problem is some mix of dependencies, maybe some babel configuration as I am using a custom webpack config in my storybook project
Also from my tests is also seems related to using this syntax in the code:
although I am not 100% sure
Unfortunately my whole codebase uses this pattern:
so I will refrain from updating until this has been figured out
we got a weird
Uncaught SyntaxError: Unexpected token '.'on6.0.13after fixing babel loose issue https://github.com/babel/babel/issues/11622