Create-react-app: tsconfig.js.

Created on 23 Nov 2020  ·  11Comments  ·  Source: facebook/create-react-app

在最新的脚手架,创建的项目npx create-react-app xx --template typescript 会出现tsconfig.js 中“jsx”: "react-jsx"

Most helpful comment

@raikusy @upendra-web I got the same problem. I just ran the following code

yarn upgrade @types/react@latest @types/react-dom@latest typescript@latest

And restarted vscode after. And fixed that error.

My dependecies now are

 ...
 "@types/react": "^17.0.0",
 "@types/react-dom": "^17.0.0",
 "typescript": "^4.1.2",
...

It appearts to run tsconfig with react-jsx typescript 4.1.0 or superior is required

I also had to install https://marketplace.visualstudio.com/items?itemName=ms-vscode.vscode-typescript-next

All 11 comments

Yeah, react-scripts is forcefully changing the jsx key in compilerOptions from react to react-jsx. But my code editor is showing some tsconfig related errors.

Here's my tsconfig.json

Screenshot 2020-11-23 at 4 39 45 PM

Here's the error my code editor is showing

Screenshot 2020-11-23 at 4 39 13 PM

So any tips to solve this issue? Thanks in advance.

I am also facing this issue. Any help regarding this?

restarting your ide/editor likely helps

restarting your ide/editor likely helps

No it doesn't.

I created a fresh project using create-react-app. And got this warning in VSCode.

❯ create-react-app --version
4.0.1

Screenshot 2020-11-23 at 6 01 50 PM
Screenshot 2020-11-23 at 6 02 02 PM

@raikusy @upendra-web I got the same problem. I just ran the following code

yarn upgrade @types/react@latest @types/react-dom@latest typescript@latest

And restarted vscode after. And fixed that error.

My dependecies now are

 ...
 "@types/react": "^17.0.0",
 "@types/react-dom": "^17.0.0",
 "typescript": "^4.1.2",
...

It appearts to run tsconfig with react-jsx typescript 4.1.0 or superior is required

I also had to install https://marketplace.visualstudio.com/items?itemName=ms-vscode.vscode-typescript-next

@raikusy @upendra-web I got the same problem. I just ran the following code

yarn upgrade @types/react@latest @types/react-dom@latest typescript@latest

And restarted vscode after. And fixed that error.

My dependecies now are

 ...
 "@types/react": "^17.0.0",
 "@types/react-dom": "^17.0.0",
 "typescript": "^4.1.2",
...

It appearts to run tsconfig with react-jsx typescript 4.1.0 or superior is required

I also had to install https://marketplace.visualstudio.com/items?itemName=ms-vscode.vscode-typescript-next

Yeah, installing the latest vscode-typescript plugin solved the issue for me.

Thanks @LuizCristino , for the tip.

Hello,

My solution

yarn add -D npm-check-updates
  • Step 2: Upgrade package
yarn ncu -u
  • Step 3: Reload VSCode

Thanks @LuizCristino .

Hello,

My solution

yarn add -D npm-check-updates
  • Step 2: Upgrade package
yarn ncu -u
  • Step 3: Reload VSCode

Thanks @LuizCristino .

⚠️ WARNING ⚠️
If you do this in an old/existing project, it will update all the packages. Which might break your application. You can do this on a newly created app. But this isn't recommended. Simply upgrading typescript, @types/react, @types/react-dom and installing the JavaScript and TypeScript Nightly will do the job. Upgrading all packages to latest version might break the app.

@raikusy @upendra-web
The solution is here #10107

This is an editor issue, and not specific to CRA from what i can tell. If you receive errors in npm start or npm run build, then you know you have an issue with CRA. The suggestion from https://github.com/facebook/create-react-app/issues/10144#issuecomment-733278351 should get you on the right path.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Evan-GK picture Evan-GK  ·  3Comments

JimmyLv picture JimmyLv  ·  3Comments

jnachtigall picture jnachtigall  ·  3Comments

adrice727 picture adrice727  ·  3Comments

dualcnhq picture dualcnhq  ·  3Comments