In tsconfig.json
you need to update the lib
to be es2017
.
Target (--target)
Specify ECMAScript target version
Lib (--lib)
List of library files to be included in the compilation.
Changing the lib
to es2017
pulls in the typings for VSCode, and for compilation you can use polyfills.
Example
{
"compileOnSave": false,
"compilerOptions": {
// ...
"target": "es2015",
// ...
"lib": [
"dom",
"es2017" // <-- change to use es2017
],
"paths": { ... }
}
}
You can find the full list of compiler options in TypeScript's docs
Angular has a bunch of polyfills that are commented out by default in polyfills.ts
. You can uncomment what you need and add the dependencies they request using npm
or yarn
. In your case you only need the string prototype polyfill from ES7.
padStart
Just angulars typescript interface hasn't it. Ok, I could extend the typescript types interface for string prototype methods. – Perloff