es6和es2017之间tsconfig.json中'lib'属性的区别?

Vig*_*dis 10 typescript ecmascript-6 typescript-typings typescript2.0 ecmascript-2017

我一直在研究文件中找到的lib属性的可能值是什么意思.我在Typescript GitHub页面找到了与这些值相对应的相关文件,并且显然使用了以下ES功能:compilerOptionstsconfig.jsond.tsES2017

/// <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" />
Run Code Online (Sandbox Code Playgroud)

但显然ES6不包括在内,并且它自己的文件没有引用任何内容.我的问题是,如果有人知道,可以安全地假设通过使用es2017我覆盖所有es6功能(从打字的角度来看)或者是否应该单独包含在lib选项中?

例如,像这样:

{
  ...
  "compilerOptions": {
    ...
    "lib": ["es2017", "dom"]
  },
  ...
  }
}
Run Code Online (Sandbox Code Playgroud)

或这个:

{
  ...
  "compilerOptions": {
    ...
    "lib": ["es2017", "es6", "dom"]
  },
  ...
  }
}
Run Code Online (Sandbox Code Playgroud)

Vig*_*dis 11

在通过Typescript GitHub上lib文件夹进行一些挖掘和比较后,我发现,在对应于这些引用中找到的代码的属性中使用:es6libcompilerOptions

/// <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" />
/// <reference path="lib.dom.d.ts" />
/// <reference path="lib.scripthost.d.ts.d.ts" />
/// <reference path="lib.dom.iterable.d.ts" />
Run Code Online (Sandbox Code Playgroud)

所以要回答我的问题,正确地覆盖中的所有内容es6es2017该tsconfig.json的那部分应该是这样的:

{
  ...
  "compilerOptions": {
    ...
    "lib": ["es2017", "dom", "dom.iterable", "scripthost"]
  },
  ...
  }
}
Run Code Online (Sandbox Code Playgroud)