Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tsconfig.js. #10129

Closed
root-lxq opened this issue Nov 23, 2020 · 11 comments
Closed

tsconfig.js. #10129

root-lxq opened this issue Nov 23, 2020 · 11 comments

Comments

@root-lxq
Copy link

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

@upendra-web
Copy link

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.

@raikusy
Copy link

raikusy commented Nov 23, 2020

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

@agos
Copy link

agos commented Nov 23, 2020

restarting your ide/editor likely helps

@raikusy
Copy link

raikusy commented Nov 23, 2020

restarting your ide/editor likely helps

No it doesn't.

@raikusy
Copy link

raikusy commented Nov 23, 2020

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

@LuizCristino
Copy link

LuizCristino commented Nov 23, 2020

@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

@upendra-web
Copy link

upendra-web commented Nov 23, 2020

@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.

@ancs21
Copy link

ancs21 commented Nov 23, 2020

Hello,

My solution

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

Thanks @LuizCristino .

@raikusy
Copy link

raikusy commented Nov 23, 2020

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.

@Jasonzj
Copy link

Jasonzj commented Nov 24, 2020

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

@ianschmitz
Copy link
Contributor

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 #10144 (comment) should get you on the right path.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants