0

I've got a monorepo project structured in the following way

/web
/native
  /tsconfig.json
tsconfig.json

My /native/tsconfig.json looks like this

{
  "extends": "../../tsconfig.json",
  "compilerOptions": {
    "jsx": "react-native"
  }
}

But for some reason my .tsx files with some jsx in them return following error

[ts] Cannot use JSX unless the '--jsx' flag is provided. [17004]

When I typecheck using cli tsc, I don't get these errors.

Ilja
  • 44,142
  • 92
  • 275
  • 498
  • Does this answer your question? [Cannot use JSX unless the '--jsx' flag is provided](https://stackoverflow.com/questions/50432556/cannot-use-jsx-unless-the-jsx-flag-is-provided) – Michael Freidgeim Feb 24 '23 at 07:54

2 Answers2

3

You need to specify the folder like this in your tsconfig.

"include": [
  "./src/ts/**/*" //Path to your source
],
"jsx": "preserve",
Harish Soni
  • 1,796
  • 12
  • 27
2

Typescript version in VsCode workspace and package.json are not equal. To solve this problem in Vscode,

  1. Open the tsx file. In right bottom corner you will find typescript react

2 click this button and choose change VS Code to use the workspace's version of Typescript.

The errors will disappear.

Athena Chen
  • 269
  • 2
  • 4