storybook: Docgen: Errors on components whose names are keywords
The storybook project builds fine:

When I load the page I get a cryptic Javascript error:

My deps are as below (let me know if there are other relevant deps):
"@storybook/addon-a11y": "^6.0.5",
"@storybook/addon-actions": "^6.0.5",
"@storybook/addon-knobs": "^6.0.5",
"@storybook/addon-links": "^6.0.5",
"@storybook/addons": "^6.0.5",
"@storybook/react": "^6.0.5",
"@storybook/source-loader": "^6.0.5",
"react": "16.13.1",
Not really sure where to start debugging, any ideas on what could be wrong?
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 26
- Comments: 21 (5 by maintainers)
Please upvote the fix in https://github.com/styleguidist/react-docgen-typescript/pull/313
@TheKnarf
I had a similar problem in a project after upgrading Storybook, turned out I head a react component called
deletein a file calleddelete.tsxand at some point Storybook tried to generate some code that looked something likedelete.module = ...which caused the SyntaxError. Renaming the component and the file solved it (never checked which one was the problem).Still a bug
Manually set the display name solved this for me
switch.tsx … Switch.displayName = ‘Switch’; …
switch.tsxtoo!Same issue here. In my case instead of having a file
delete.tsxI had aswitch.tsxwhich caused the same problem:(SyntaxError: Unexpected token '.')Yep, exactly the same issue here - I have
switch.tsxwhich causes the same problem. Changing the file name tosomethingElse.tsxeverything compiles fineSame issue,
(SyntaxError: Unexpected token '.')andswitch.tsx😄Yeps, versions 7.6.12
If you had a problem with the switch component in the storybook, try changing it to “toogle”, or similar names. The problem itself is the name guys
As of 7.6.4 I’m still seeing this issue in Storybook. Above fixes work.
I think this got fixed in 7.0 beta.