6
votes

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 -

  • Visual Studio project , Project properties -> TypeScript Build –> JSX Compilation in TSX files
  • 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”

enter image description here

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

  • Visual Studio: 2017 Professional
  • TypeScript : 2.1.4
  • React : 15.4.2
1
Hi Robotronic, please share the detail steps to get the IntelliSense errors in Visual Studio that you mentioned?Sara Liu - MSFT
The grayed out settings page does not show the current configuration of your tsConfig.json file. So do not worry about what you see there.Jack Miller
Any update on this @Sara Lui-MSFT? I can easily reproduce this still now with the latest VS2017 Enterprise + latest updates.Sat Thiru

1 Answers

2
votes

Historic question but still relevant today (at least to me...)

Solution: After setting "jsx": "react" in tsConfig.json restart Visual Studio.