Make sure to update the lib
in your tsconfig.json
file to es2017
.
Set Target Version (--target)
Specify the version of ECMAScript target you want to use.
Include Library Files (--lib)
List of library files that should be included during compilation.
By changing the lib
to es2017
, you will import typings for VSCode and can utilize polyfills for compilation purposes.
Example
{
"compileOnSave": false,
"compilerOptions": {
// ...
"target": "es2015",
// ...
"lib": [
"dom",
"es2017" // <-- make sure to switch to es2017
],
"paths": { ... }
}
}
You can refer to TypeScript's documentation for a comprehensive list of compiler options.
In Angular, there are various polyfills available but are often commented out in the polyfills.ts
file. You can uncomment needed polyfills and install any necessary dependencies using npm
or yarn
. For this case, you only require the string prototype polyfill from ES7.