question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

See original GitHub issue

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.

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:6
  • Comments:9 (5 by maintainers)

github_iconTop GitHub Comments

3reactions
Timercommented, Dec 17, 2018

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

1reaction
dtinthcommented, Jan 21, 2019

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Adding TypeScript - Create React App
TypeScript is a typed superset of JavaScript that compiles to plain JavaScript. Installation​. To start a new Create React App project with ...
Read more >
Setting TypeScript For Modern React Projects Using Webpack
There are several ways to set up TypeScript in a React Project. In this tutorial, we'll be covering just two. Method 1: Create...
Read more >
Migrating from create-react-app-typescript to Create React App
Let's get to it. #Step 1: remove react-scripts-ts, add react-scripts. Create React App is a command line application that generates a basic ...
Read more >
Migrating create-react-app from javascript to typescript
Create a temporary react project with typescript by running the command create-react-app --scripts-version=react-scripts-ts (Note - requires ...
Read more >
Getting Started with React and TypeScript | Pluralsight
Getting Started Using Create React App (CRA) ; # Generate a new React Typescript project 2npx create-react-app my-typescript-app --typescript 3 4 ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found