Create-react-app: Put TypeScript configuration in react-scripts instead of individual project? (TS3.2+)

Created on 17 Dec 2018  ·  9Comments  ·  Source: facebook/create-react-app

Is this a bug report?

No

Motivation

TypeScript 3.2, released November 29th, 2018, now uses Node.js-based resolution for tsconfig.json inheritance

TypeScript 3.2 now resolves tsconfig.jsons from node_modules. When using a bare path for the "extends" field in tsconfig.json, TypeScript will dive into node_modules packages for us.

{
    "extends": "@my-team/tsconfig-base",
    "include": ["./**/*"]
    "compilerOptions": {
        // Override certain options on a project-by-project basis.
        "strictBindCallApply": false,
    }
}

TypeScript will look for "tsconfig" field in package.json to determine the configuration file to use.

Therefore, the generated tsconfig.json could be reduced to

{ "extends": "react-scripts", "include": ["src"] }

This would further reduce configuration in create-react-app projects.

proposal

Most helpful comment

Yay! We requested this over a year and a half ago: https://github.com/Microsoft/TypeScript/issues/15984

All 9 comments

what stops people from just changing the package.json file to go back to the file that they want to use?

Yay! We requested this over a year and a half ago: https://github.com/Microsoft/TypeScript/issues/15984

This is a great idea @dtinth, I assume this will still allow people to use the config they want - which is not necessarily a bad thing @shavyg2 - but it would require us to still verify that the tsconfig.json that the user is using (if custom) works with our configuration.

What do you think @Timer?

I love that idea. Reducing config is always good.

Please ship it @Timer 🙏🏻🥺

I think hiding the configuration from the user may be undesirable, so we may as well continue letting users configure it how we do now. We can talk about it at the maintainer's meeting.

CRA already “hides” config for almost everything, that’s the goal.

Most configs exposed by CRA’s tsconfig are either mandatory or recommended, so hiding them and allowing the user to override if necessary seems to follow the goals for CRA.

Hiding the configuration doesn’t make it unconfigurable.

TypeScript configs like target, lib, jsx, no*, etc can evolve over time as browser tech evolve. The goal should be to allow users to upgrade to latest practice by just upgrading react-scripts and not have to copy the latest tsconfig.json from the source code.

This issue has been automatically marked as stale because it has not had any recent activity. It will be closed in 5 days if no further activity occurs.

(This discussion is not resolved yet.)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

rdamian3 picture rdamian3  ·  3Comments

Evan-GK picture Evan-GK  ·  3Comments

adrice727 picture adrice727  ·  3Comments

alleroux picture alleroux  ·  3Comments

AlexeyRyashencev picture AlexeyRyashencev  ·  3Comments