2017-01-04 83 views
1

我有一个typecript @ 2项目。我想使用一些ecma2017功能。我发现一个可以在tsconfig.json适用于compilerOptions一个liblib在哪里来自typecsript?

"target": "es6", 
"lib": [ 
    "es2017", 
    "dom" 
], 

然而,这是为什么工作?这些库是从哪里来的,包括哪些库?

最近的文档我能找到的这个this what's new entry

下层异步功能

此功能打字稿2.1之前的支持,但只有当目标ES6/ES2015。 TypeScript 2.1将ES3和 ES5运行时间的功能带入其中,这意味着您可以免费利用它,而不是使用您使用的环境 。

注意:首先,我们需要确保我们的运行时间在全局范围内具有符合ECMAScript的Promise。这可能涉及 为Promise抓取一个polyfill,或者依赖于您在目标运行时可能有 的那个。我们还需要确保 打字稿知道无极存在通过像“DOM”,“ES2015”或“DOM”,“es2015.promise”,“ES5”

您的lib标志设置的东西 但我没有发现它特别有用。

回答

2

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