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!