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
"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.
All values of the compiler options
lib is referenced in the Lib documentation:
List of library files to be included in the Possible values are: ► ES5 ► ES6 ► ES2015 ► ES7 ► ES2016 ► ES2017 ► ESNext ► DOM ► DOM.Iterable ► WebWorker ► ScriptHost ► ES2015.Core ► ES2015.Collection ► ES2015.Generator ► ES2015.Iterable ► ES2015.Promise ► ES2015.Proxy ► ES2015.Reflect ► ES2015.Symbol ► ES2015.Symbol.WellKnown ► ES2016.Array.Include ► ES2017.object ► ES2017.SharedMemory ► esnext.asynciterable Note: If --lib is not specified a default library is injected. The default library injected is: ► For --target ES5: DOM,ES5,ScriptHost ► For --target ES6: DOM,ES6,DOM.Iterable,ScriptHost
Answered By – HolgerJeromin
Answer Checked By – Marie Seifert (AngularFixing Admin)