-
Notifications
You must be signed in to change notification settings - Fork 8
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
Unexpected token 'default' - Storing sub-components as properties on Components #33
Comments
I'm able to suppress the issue by modifying index.ts lines 95 - 98 to filter out this const componentDocs = docGenParser.parseWithProgramProvider(
id,
() => tsProgram,
).filter( // filter out 'default.*' case
componentDoc => !componentDoc.displayName.startsWith("default.")
); Not sure if this is the right solution, or if a better solution would be to prevent |
Ok, I'm confirming that this bug was in So the problem is just a dependency version issue: this plugin ( Please update the dependency to v2.2.3 so this is no longer an issue. Thanks! |
..Or maybe at least start by pushing it to npm? Is it maybe not stable, or is there another reason that it hasn't been? |
@pvasek - I see you just updated the I just happened to hit the issue @CodeSmith32 described above today, coincidentally. Is this fixed (to your knowledge) and will 2.3.0 be on NPM soon? Edit: asked here, also: styleguidist/react-docgen-typescript#505 |
EDIT: Skip to end. This issue was fixed, but the dependency version hasn't been updated.
Coming here from this Storybook issue
This package appears to generate invalid code for the following scenario (code that a
try catch
does not catch):When I export a React component as default, but also export another React component that is a property on the first component, e.g.:
The issue trickles down to generating the following code, which throws a syntax error and completely fails to load – try catch doesn't help – due to the
default.Sub.*
lines in the middle block:When logging the value of
componentDocs
assigned inindex.ts: 95
of this package, I'm seeingdefault.Sub
as one of the 'documentable' exports:I apologize if this issue is actually with the
react-docgen-typescript
package. It seems like it, but I couldn't be sure.My guess is that it is, and that it's in the
parseWithProgramProvider
method, probably somewhere around the processing ofcomponents
after collecting the module exports:https://github.com/styleguidist/react-docgen-typescript/blob/master/src/parser.ts#L1392
The text was updated successfully, but these errors were encountered: