Why is typescript compiler changing my tsconfig.json file on server start up?

Viewed 5729

I'm trying to move my react app to a react-typescript app. firstly, this seems really tricky which is disappointing

the issue I'm having is that I get typescript errors in my console. I'm trying to fix them by changing my tsconfig.json file

but whenever I do and restart the server, I get a message in the console saying: the following changes are being made to your tsconfig.json file and then it lists the changes which are basically "undos" of the stuff I've just added or changed. why would it do this?

it is a create-react-app project and I followed this to migrate to typescript: https://facebook.github.io/create-react-app/docs/adding-typescript

4 Answers

You can manually add a tsconfig.path.json file with all the compilerOptions included and add "extends": "./tsconfig.path.json" to your tsconfig file.

The error eventually went away after upgrading to the latest version of Typescript

I have been getting this issue for my React 17 project. Every time I run npm start, it overrides whatever I configure in {jsx: ...} with react-jsx in order to be compatible with JSX transform in React 17. And it shows the following message:

The following changes are being made to your tsconfig.json file:

compilerOptions.jsx must be react-jsx (to support the new JSX transform in React 17) The problem is VSCode using an older version of typescript (4.0.3), while the typescript version shipped with the project is (4.1.2).

SOLUTION:

The following did the trick for me:

In visual studio:

  • Go to the command palette and press CTRL+Shift+P.
  • Choose "TypeScript: Select a TypeScript Version...".
  • Choose "Use workspace Version".

Ejecting from create-react-app worked for me.

Command: npm run eject

Related