打字稿中的lib来自哪里?

Where does the lib come from in typecsript?

我有一个 typescript@2 项目。我想使用一些 ecma2017 功能。我发现可以在 tsconfig.json:

中的 compilerOptions 中应用 lib
"target": "es6",
"lib": [
    "es2017",
    "dom"
],

然而为什么这有效?这些库从哪里来,可以包含哪些库?

我能找到的最接近文档的是这个 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"

但我没有发现它特别有用。

编译器选项 lib 的所有值都在 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