*.tsx parser fails
See original GitHub issueHi. I’ve tried to use depcheck with tsx files + typescript@2, but with no luck. I reciving parsing error like:
"SyntaxError: Unexpectedtoken(5: 16)
atParser.pp$5.raise(.../depcheck/node_modules/babylon/lib/index.js: 4333: 13)
atParser.pp.unexpected(.../depcheck/node_modules/babylon/lib/index.js: 1705: 8)
atParser.pp$3.parseParenAndDistinguishExpression(.../depcheck/node_modules/babylon/lib/index.js: 3776: 10)
atParser.pp$3.parseExprAtom(.../depcheck/node_modules/babylon/lib/index.js: 3629: 19)
atParser.pp$3.parseExprSubscripts(.../depcheck/node_modules/babylon/lib/index.js: 3414: 19)
atParser.pp$3.parseMaybeUnary(.../depcheck/node_modules/babylon/lib/index.js: 3394: 19)
atParser.pp$3.parseExprOps(.../depcheck/node_modules/babylon/lib/index.js: 3324: 19)
atParser.pp$3.parseMaybeConditional(.../depcheck/node_modules/babylon/lib/index.js: 3301: 19)
atParser.pp$3.parseMaybeAssign(.../depcheck/node_modules/babylon/lib/index.js: 3264: 19)
atParser.pp$3.parseExpression(.../depcheck/node_modules/babylon/lib/index.js: 3226: 19)"
To reproduce go to test/fake_modules/typescript and change component.tsx from
import * as React from 'react';
export default class MyComponent extends React.Component<{}, {}> {
}
to
import * as React from 'react';
export default class MyComponent extends React.Component<{}, {}> {
render() {
return (<div>fake</div>)
}
}
and run tests.
You will see that there are 2 failing tests. Both about typescript parser.
Issue Analytics
- State:
- Created 7 years ago
- Reactions:1
- Comments:10 (7 by maintainers)
Top Results From Across the Web
JSX parsing failure when mixing ts, tsx, js and jsx files #6031
Describe the bug My project is a bit of a mess. I have a mixture of ts, tsx, js and jsx files. I'm...
Read more >When Eslint parse Tsx/Ts file 'public' token, always shows ...
When Eslint parse Tsx/Ts file 'public' token, always shows 'Parsing error: Unexpected token' · Ask Question. Asked 1 year ago.
Read more >"ERROR: Unable to parse file" for numerous valid typescript files
When running a scan of a typescript (v4.4) project, I get a number of parser errors. The error reads: ERROR: Unable to parse...
Read more >eslint-import-resolver-typescript - npm
This plugin adds `TypeScript` support to `eslint-plugin-import`. Latest version: 3.5.2, last published: 2 months ago.
Read more >Documentation - JSX - TypeScript
If that fails, TS will report an error. Function Component. As the name suggests, the component is defined as a JavaScript function where...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I see. I suppose that is controlled here:
https://github.com/depcheck/depcheck/blob/153aa50925e4a02f1b418a7d1349bff8f5f925eb/src/parser/typescript.js#L11-L14
We need to change this hard coded compile option to read it from file. Not sure if TypeScript provides util to help here.
@yurii-sorokin Could you please help on this issue?
Thanks @yurii-sorokin !