在TypeScript中,lib.es6.d.ts和lib.es2015.d.ts有什么区别? [英] In TypeScript, what's the difference between the `lib.es6.d.ts` and `lib.es2015.d.ts`?

查看:764
本文介绍了在TypeScript中,lib.es6.d.ts和lib.es2015.d.ts有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

据我了解,ES6和ES2015是同一回事.但是在打字稿中,有两种类型的声明可用于这两件事:lib.es6.d.tslib.es2015.d.ts.有什么区别?我应该使用哪一个?

From my understanding, the ES6 and the ES2015 is the same thing. But in typescript, there are 2 type declaration for these 2 things: lib.es6.d.ts and lib.es2015.d.ts. What's difference? Which one should I use?

推荐答案

ES6和ES2015是同义词.在TypeScript中,具有相同名称的TypeScript targetlib的行为应该相似-

ES6 and ES2015 are synonymous. Both TypeScript targets and libs of same names are expected to behave similarly in TypeScript - and they are.

lib.d.tslib.es6.d.ts是累积库文件.它们是从其他库生成的:

lib.d.ts and lib.es6.d.ts are cumulative library files. They are generated from other libraries:

此目录中的文件用于生成lib.d.ts和lib.es6.d.ts.

The files within this directory are used to generate lib.d.ts and lib.es6.d.ts.

它们包括相应的规范库以及DOM.

They include respective spec libraries plus DOM.

lib.es6.d.tslib.es2015.d.ts之间的区别在于,当未指定lib时,默认情况下将前者包括在内,且target设置为ES6,而将后者使用时,将lib设置为ES6. IE. --target ES6--target ES6 --lib ES6,DOM,DOM.Iterable,Scripthost相同.

The difference between lib.es6.d.ts and lib.es2015.d.ts is that the former is included by default with target set to ES6 when no lib is specified, while the latter is used with lib set to ES6. I.e. --target ES6 is the same as --target ES6 --lib ES6,DOM,DOM.Iterable,Scripthost.

ES2015库是细粒度的,因此可以将ES6ES2015替换为

ES2015 library is fine-grained, so ES6 or ES2015 can be replaced with a subset of features when necessary: ES2015.Core, etc.

这篇关于在TypeScript中,lib.es6.d.ts和lib.es2015.d.ts有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆