I have a typescript@2 project. I wanted to use some ecma2017 features. I found out that one can apply a lib
in the compilerOptions
in the tsconfig.json
:
"target": "es6",
"lib": [
"es2017",
"dom"
],
Yet why is this working? Where do these lib come from, what libs can one include?
The closest to a documentation I could find was this this what's new entry:
Downlevel Async Functions
This feature was supported before TypeScript 2.1, but only when targeting ES6/ES2015. TypeScript 2.1 brings the capability to ES3 and ES5 run-times, meaning you'll be free to take advantage of it no matter what environment you're using.
Note: first, we need to make sure our run-time has an ECMAScript-compliant Promise available globally. That might involve grabbing a polyfill for Promise, or relying on one that you might have in the run-time that you're targeting. We also need to make sure that TypeScript knows Promise exists by setting your lib flag to something like "dom", "es2015" or "dom", "es2015.promise", "es5"
yet I didn't find it particular helpful.