Typescript with tsx error Follow
Hi i have phpstorm where React written in .ts and .tsx files is compiled through babel in webpack.
I cant get editor to work, it marks my tsx syntax as wrong because allegedly:
`TS17004: Cannot use JSX unless the '--jsx' flag is provided.`
I tried to do it with and without `tsconfig.json` with this content
```
{
"jsx": true,
"comment": "Only for phpstorm highlighting, not actually used in compiling",
"compilerOptions": {
"jsx": "react"
},
"include": [
"www/js/ts/*"
],
"exclude": [
"node_modules",
"**/*.spec.ts"
]
}
```
but nothing changed, can you please help me?
PHPStorm 2020.1.1
Please sign in to leave a comment.
Adding
to
"compilerOptions": {}
in tsconfig.json should do the thing (placing it outside this section is not permitted)
How many tsconfig.*.json files do you have in your project? Is your .tsx file included in any of them?
I have exactly that in compilerOptions secttion, nothing changes if i remove first line, my config looks like this now:
I have only `tsconfig.json` in root directory, nothing else in project matches that pattern.
Please attach s screenshot of Typescript error console with the error message.
can't reproduce with similar configurtion
please share a sample project the issue can be repeated with
Well this is kind of weird, i was setting the sample project and my original project started working just ok, no wrong errors. It works either with or without `tsconfig.json`.
SInce i cannot reproduce the issue i guess this is all. Thank you for your time.
I'm having the same issue in WebStorm 2021.2.3. The problematic files are named like `BarChart.spec.tsx`.
We have "**/*.spec.*" listed under "exclude" in tsconfig.json. Removing that made the error go away. But I don't think that's a proper solution, just a workaround.
I had similar issue with WebStorm 2021.2.3. I was working on a Lerna monorepo. My issue was the editor has picked up Typescript from another module instead the one I was working. So pointing correct TS version fixed everything. Also I was having TSLint not found error and that also fixed