tsconfig 选项“lib"有什么作用?做? [英] What does the tsconfig option "lib" do?

查看:119
本文介绍了tsconfig 选项“lib"有什么作用?做?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个在 tsconfig.json 中有这一行的现有项目:

lib:["2016", "DOM"]

这样做的目的是什么?

我能找到的唯一信息是:

<块引用>

指定要包含在编译中的库文件.需要TypeScript 2.0 或更高版本.

这是什么意思?

解决方案

这是一个新的 typescript 2 功能,因此它仍然缺乏文档,但您可以在 Typescript 2.0 中的新功能::><块引用>

使用 --lib 可以指定内置 API 声明组的列表您可以选择包含在您的项目中.例如,如果你希望您的运行时支持 Map、Set 和 Promise(例如当今大多数常绿浏览器),只需包含 --libes2015.collection,es2015.promise.同样你可以排除您不想包含在项目中的声明,例如DOM 如果您正在使用 --lib es5,es6 处理节点项目.

还有一个受支持的 API 组 列表以及该链接中的一个非常简短的示例.

I have an existing project that has this line in tsconfig.json:

lib:["2016", "DOM"]

What is the purpose of this?

The only info I could find is this:

Specify library file to be included in the compilation. Requires TypeScript version 2.0 or later.

What does that mean?

解决方案

This is a new typescript 2 feature and so it still lacks documentation, but you can read about it in the What's new in Typescript 2.0:

with --lib you can specify a list of built-in API declaration groups that you can chose to include in your project. For instance, if you expect your runtime to have support for Map, Set and Promise (e.g. most evergreen browsers today), just include --lib es2015.collection,es2015.promise. Similarly you can exclude declarations you do not want to include in your project, e.g. DOM if you are working on a node project using --lib es5,es6.

There's also a list of the API groups that are supported and a very short example in that link.

这篇关于tsconfig 选项“lib"有什么作用?做?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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