I have a TypeScript/React project in Visual Studio.
The challenge is getting Visual Studio to recognize React.
IntelliSense errors in Visual Studio are of the form -
“--jsx is not set”, “Cannot use JSX, unless the ‘—jsx’ flag is provided”
The obvious solution is to configure –-jsx.
There seems to be at least two way to do this -
tsConfig.json
{ "compilerOptions": {
"jsx": "react",
"noUnusedLocals": true,
"noUnusedParameters": true,
"noFallthroughCasesInSwitch": true,
"noImplicitReturns": true,
"target": "es5", ...
I have already configured -–jsx in tsConfig.json, and the command line gulp build works just fine, but Visual Studio still thinks that –jsx is not set.
So, for Visual Studio, I figured I could just set the project property ( in addition to tsconfig.json) But in Visual Studio this is disabled - “One or more tsconfig.json files detected. Project Properties are disabled”
How do I get Visual Studio to recognize the –jsx setting from the tsConfig,json. It seems to recognize that tsConfig.json exists , but does not specifically recognize that –jsx is configured
Dev Environment
To solve the error "Cannot use jsx unless the '--jsx' flag is provided", restart your IDE and development server and make sure your IDE is using the same version of TypeScript that your project uses. The project's TypeScript version and your IDE's TypeScript versions should match.
The tsconfig.json file specifies the root files and the compiler options required to compile the project. JavaScript projects can use a jsconfig.json file instead, which acts almost the same but has some JavaScript-related compiler flags enabled by default.
Historic question but still relevant today (at least to me...)
Solution: After setting "jsx": "react"
in tsConfig.json
restart Visual Studio.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With