最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - using core-js with TypeScript - Stack Overflow

programmeradmin1浏览0评论

The Kangax patibility table for ES6 at / shows results for "TypeScript + core-js". I need core-js in order to use ES6 methods like String#startsWith. I haven't been able to figure out how to tell the TypeScript piler to consider core-js and couldn't find an example. How can I use core-js with TypeScript?

The Kangax patibility table for ES6 at http://kangax.github.io/pat-table/es6/ shows results for "TypeScript + core-js". I need core-js in order to use ES6 methods like String#startsWith. I haven't been able to figure out how to tell the TypeScript piler to consider core-js and couldn't find an example. How can I use core-js with TypeScript?

Share Improve this question asked Jul 14, 2015 at 21:36 Mark VolkmannMark Volkmann 9791 gold badge12 silver badges15 bronze badges 2
  • Wouldn't you be able to use the standard ES6 definitions from typescript? github./Microsoft/TypeScript/blob/master/bin/lib.es6.d.ts Or do you mean how would you load the library? – loganfsmyth Commented Jul 14, 2015 at 21:43
  • Ah, yes I can use that! Thanks! – Mark Volkmann Commented Jul 15, 2015 at 18:45
Add a ment  | 

2 Answers 2

Reset to default 6

If you using Typescript 2.0, you can use @types to solve this issue.

@types and types

When you pile typescript code, by default all visible @types packages are included in your pilation. Packages in node_modules/@types of any enclosing folder are considered visible; specifically, that means packages within:

  • ./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.

npm install --save-dev @types/core-js

More information at: tscconfig.json

Good luck.

The Typescript repo provides standard definitions for ES6 functionality.

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.

发布评论

评论列表(0)

  1. 暂无评论