[英]using core-js with TypeScript
The Kangax compatibility table for ES6 at http://kangax.github.io/compat-table/es6/ shows results for "TypeScript + core-js". ES6的Kangax兼容性表位于http://kangax.github.io/compat-table/es6/,显示了“ TypeScript + core-js”的结果。 I need core-js in order to use ES6 methods like String#startsWith.
我需要core-js才能使用诸如String#startsWith之类的ES6方法。 I haven't been able to figure out how to tell the TypeScript compiler to consider core-js and couldn't find an example.
我一直无法弄清楚如何告诉TypeScript编译器考虑使用core-js,并且找不到示例。 How can I use core-js with TypeScript?
如何在TypeScript中使用core-js?
If you using Typescript 2.0, you can use @types
to solve this issue. 如果使用Typescript 2.0,则可以使用
@types
解决此问题。
@types
and types @types
类型和类型
When you compile typescript code, by default all visible @types
packages are included in your compilation. 编译打字稿代码时,默认情况下,所有可见的
@types
包均包含在编译中。 Packages in node_modules/@types
of any enclosing folder are considered visible; 任何封闭文件夹的
node_modules/@types
的软件包都被视为可见; specifically, that means packages within: 具体来说,这意味着以下程序包:
./node_modules/@types/
, ./node_modules/@types/
, ../node_modules/@types/
, ../node_modules/@types/
, ../../node_modules/@types/
, ../../node_modules/@types/
, and so on. 等等。
@types/core-js
provide the definition for core.js, you can install it as another modules. @types/core-js
提供core.js的定义,您可以将其安装为另一个模块。
npm install --save-dev @types/core-js
More information at: tscconfig.json 有关更多信息,请访问: tscconfig.json
Good luck. 祝好运。
The Typescript repo provides standard definitions for ES6 functionality. Typescript存储库提供了ES6功能的标准定义 。
I suppose if you wanted to use some of core-js's functionality that is beyond ES6, you would have to add definition files yourself. 我想如果您想使用ES6以外的core-js的某些功能,则必须自己添加定义文件。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.