Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • C create-react-app
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 1,547
    • Issues 1,547
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 417
    • Merge requests 417
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Meta
  • create-react-app
  • Merge requests
  • !5772

Fix TypeScript type-checking: Set "target": "esnext" in the default tsconfig.json

  • Review changes

  • Download
  • Email patches
  • Plain diff
Closed Administrator requested to merge github/fork/ndbroadbent/fix_default_typescript_target into master Nov 11, 2018
  • Overview 2
  • Commits 1
  • Pipelines 0
  • Changes 1

Created by: ndbroadbent

This fixes the issue that I just experienced while trying to figure out a TypeScript type error: https://github.com/facebook/create-react-app/issues/5771

The CRA webpack config includes polyfills for IE9+, so the TypeScript type checker should be using the type definitions for the latest JS features, including Array.includes, Object.assign, etc. The current default tsconfig.json limits TypeScript to only using ES5 features.

Note that the Babel compilation doesn't actually care about tsconfig.json, and this doesn't affect any emitted JavaScript, because CRA isn't using TypeScript to compile the JS. It only affects type-checking, because TypeScript infers the type declarations from the "target". (Type declarations can also be overriden by setting the "lib" option.)

I've confirmed that the new default tsconfig.json has the updated target, and that yarn start and yarn build are both running fine after this change.

UPDATE: Actually I just did some research to find out what Babel supports, and I think it would be better to use ES2018 here, because Babel definitely supports ES2018. And actually it's better to leave the target as "es5", and just add the "lib" option.

UPDATE 2: Haha NOOOOOOOOO, this was already fixed but wasn't released yet! Oh well!

Assignee
Assign to
Reviewers
Request review from
Time tracking
Source branch: github/fork/ndbroadbent/fix_default_typescript_target