Skip to content

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

Closed

Description

@developer239

Is this a bug report?

No

Why is create react app editing my tsconfig.json

Config files like tsconfig should be project specific.

Activity

  1. Bin-Huang commented on Jan 25, 2019

    @Bin-Huang

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

  2. Timer commented on Jan 25, 2019

    @Timer
    Contributor

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

  3. JaceHensley commented on Jan 28, 2019

    @JaceHensley

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

  4. Timer commented on Jan 28, 2019

    @Timer
    Contributor

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

  5. JaceHensley commented on Jan 28, 2019

    @JaceHensley

    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 🤷‍♂️

  6. developer239 commented on Jan 28, 2019

    @developer239
    Author

    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.

  7. robertvansteen commented on Jan 28, 2019

    @robertvansteen
    Contributor

    @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

  8. locked and limited conversation to collaborators on Feb 2, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions