You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Why is create react app editing my tsconfig.json? #6269
I have same problem that existing tsconfig.json is overwrited by react-scripts when I run npm start. It seem react-scripts in current version will generate tsconfig.json automatically when it find .ts files in project. So I keep my project-specific tsconfig.json by reinstall react-scripts@1 instead of current version(2.1.1).
Hmm maybe it was just how I was using it but I had added an express server at the root of the directory and the include: ['src'] was causing the server code to not be analyzed.
I've since moved the client code to a sub project of the server with different tsconfigs so not a problem for me anymore 🤷♂️
Well, there are many problems actually. I was able to make absolute imports work but I had to use this workaround. I understand why would you want to somehow control tsconfig but I don't think it is a good idea to enforce whatever good practices you think are the best.
@developer239 CRA should always "just" work. If we don't enforce or restrict certain features we will break functionality or have inconsistencies. There was no deliberate choice to disable absolute imports in Typescript because we don't want that feature but because it hasn't been implemented in such a way that it is consistent and will always work.
We are currently working on absolute imports for both TypeScript and JavaScript. You can track the progress here: #6116
Activity
Bin-Huang commentedon Jan 25, 2019
I have same problem that existing tsconfig.json is overwrited by
react-scriptswhen I runnpm start. It seemreact-scriptsin current version will generate tsconfig.json automatically when it find.tsfiles in project. So I keep my project-specific tsconfig.json by reinstallreact-scripts@1instead of current version(2.1.1).Yes, it is not a bug, but its feature puzzle me.😅
Timer commentedon Jan 25, 2019
Create React App only supports certain TypeScript features. Because of this, the
tsconfig.jsonis modified to be in compliance.JaceHensley commentedon Jan 28, 2019
There should be an option to opt-out of this auto editing of tsconfig.json
Timer commentedon Jan 28, 2019
@JaceHensley if you "opt-out" Create React App wouldn't work. This is not optional.
JaceHensley commentedon Jan 28, 2019
Hmm maybe it was just how I was using it but I had added an express server at the root of the directory and the
include: ['src']was causing the server code to not be analyzed.I've since moved the client code to a sub project of the server with different
tsconfigs so not a problem for me anymore 🤷♂️developer239 commentedon Jan 28, 2019
Well, there are many problems actually. I was able to make absolute imports work but I had to use this workaround. I understand why would you want to somehow control
tsconfigbut I don't think it is a good idea to enforce whatever good practices you think are the best.https://github.com/developer239/node-typescript-react-web/blob/master/tsconfig.paths.json
It should be possible to enforce only things that are necessary for running CRA and ignore the rest? 🙂
Btw I would like to know if there are people using CRA and typescript without absolute imports. That has to be terrible.
robertvansteen commentedon Jan 28, 2019
@developer239 CRA should always "just" work. If we don't enforce or restrict certain features we will break functionality or have inconsistencies. There was no deliberate choice to disable absolute imports in Typescript because we don't want that feature but because it hasn't been implemented in such a way that it is consistent and will always work.
We are currently working on absolute imports for both TypeScript and JavaScript. You can track the progress here: #6116