Fix TypeScript type-checking: Set "target": "esnext" in the default tsconfig.json #5772
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This fixes the issue that I just experienced while trying to figure out a TypeScript type error: #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 defaulttsconfig.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 thatyarn start
andyarn 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!