【发布时间】:2017-10-08 00:24:57
【问题描述】:
我一直在研究 tsconfig.json 文件中的 compilerOptions 中 lib 属性的可能值的含义。我在 Typescript GitHub 页面上找到了与这些值相对应的相关 d.ts 文件,显然通过使用 ES2017 包含以下 ES 功能:
/// <reference path="lib.es2016.d.ts" />
/// <reference path="lib.es2017.object.d.ts" />
/// <reference path="lib.es2017.sharedmemory.d.ts" />
/// <reference path="lib.es2017.string.d.ts" />
/// <reference path="lib.es2015.d.ts" />
/// <reference path="lib.es2016.array.include.d.ts" />
/// <reference path="lib.es2015.core.d.ts" />
/// <reference path="lib.es2015.collection.d.ts" />
/// <reference path="lib.es2015.generator.d.ts" />
/// <reference path="lib.es2015.iterable.d.ts" />
/// <reference path="lib.es2015.promise.d.ts" />
/// <reference path="lib.es2015.proxy.d.ts" />
/// <reference path="lib.es2015.reflect.d.ts" />
/// <reference path="lib.es2015.symbol.d.ts" />
/// <reference path="lib.es2015.symbol.wellknown.d.ts" />
/// <reference path="lib.es5.d.ts" />
但显然 ES6 不包括在内,并且有自己的 file 不引用任何内容。我的问题是,如果有人知道,是否可以安全地假设通过使用 es2017 我涵盖了所有 es6 功能(从打字的角度来看),还是应该单独包含在 lib 选项中?
例如,像这样:
{
...
"compilerOptions": {
...
"lib": ["es2017", "dom"]
},
...
}
}
或者这个:
{
...
"compilerOptions": {
...
"lib": ["es2017", "es6", "dom"]
},
...
}
}
【问题讨论】:
-
ES6 == ES2015 -
@Bergi 并不完全符合 Typescript 的类型。它包括所有 ES2015 的东西和其他东西。请参阅下面的答案。
标签: typescript ecmascript-6 typescript-typings typescript2.0 ecmascript-2017