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

Why is create react app editing my tsconfig.json? #6269

Closed
developer239 opened this issue Jan 24, 2019 · 7 comments
Closed

Why is create react app editing my tsconfig.json? #6269

developer239 opened this issue Jan 24, 2019 · 7 comments

Comments

@developer239
Copy link

Is this a bug report?

No

Why is create react app editing my tsconfig.json

Config files like tsconfig should be project specific.

@Bin-Huang
Copy link

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

Yes, it is not a bug, but its feature puzzle me.😅

@Timer
Copy link
Contributor

Timer commented Jan 25, 2019

Create React App only supports certain TypeScript features. Because of this, the tsconfig.json is modified to be in compliance.

@JaceHensley
Copy link

There should be an option to opt-out of this auto editing of tsconfig.json

@Timer
Copy link
Contributor

Timer commented Jan 28, 2019

@JaceHensley if you "opt-out" Create React App wouldn't work. This is not optional.

@JaceHensley
Copy link

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
Copy link
Author

developer239 commented 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 tsconfig but 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
Copy link
Contributor

robertvansteen commented 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

@lock lock bot locked and limited conversation to collaborators Feb 2, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants