Skip to content
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

[Typescript] Cannot parse enums #355

Closed
redallen opened this issue May 8, 2019 · 2 comments
Closed

[Typescript] Cannot parse enums #355

redallen opened this issue May 8, 2019 · 2 comments

Comments

@redallen
Copy link

redallen commented May 8, 2019

Components that use enums should have react-docgen just ignore them for now, I suppose.

SyntaxError: unknown: Unexpected token (8:12)

   6 | import { BaseSizes } from '../../styles/sizes';
   7 | 
>  8 | export enum TitleLevel {
     |             ^
   9 |   h1 = 'h1',
  10 |   h2 = 'h2',
  11 |   h3 = 'h3',
    at Object.raise (/home/redallen/src/patternfly-react/node_modules/@babel/parser/lib/index.js:6322:17)
    at Object.unexpected (/home/redallen/src/patternfly-react/node_modules/@babel/parser/lib/index.js:7638:16)
    at Object.parseExportFrom (/home/redallen/src/patternfly-react/node_modules/@babel/parser/lib/index.js:10978:14)
    at Object.parseExport (/home/redallen/src/patternfly-react/node_modules/@babel/parser/lib/index.js:10833:12)
    at Object.parseExport (/home/redallen/src/patternfly-react/node_modules/@babel/parser/lib/index.js:2225:24)
    at Object.parseStatementContent (/home/redallen/src/patternfly-react/node_modules/@babel/parser/lib/index.js:9867:27)
    at Object.parseStatement (/home/redallen/src/patternfly-react/node_modules/@babel/parser/lib/index.js:9763:17)
    at Object.parseStatement (/home/redallen/src/patternfly-react/node_modules/@babel/parser/lib/index.js:2019:26)
    at Object.parseBlockOrModuleBlockBody (/home/redallen/src/patternfly-react/node_modules/@babel/parser/lib/index.js:10340:25)
    at Object.parseBlockBody (/home/redallen/src/patternfly-react/node_modules/@babel/parser/lib/index.js:10327:10)

This is the entire file.

Let me know how I can contribute @devongovett !

@devongovett
Copy link
Contributor

devongovett commented May 8, 2019

Make sure your file is a .ts or .tsx file, and that you pass the file name as an option to react-docgen otherwise it won’t know to enable typescript parsing.

@redallen
Copy link
Author

redallen commented May 8, 2019

That fixed it, awesome!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants