目标:找到一个d.ts文件来教TypeScript ES6 2015/ES6中的变化。
TypeScript 1.5 ES6 modules & .d.ts files from DefinitelyTyped seem incompatible (2015年7月)使用es6.lib.d.ts的参考资料。
error TS2339: Property 'endsWith' does not exist on type 'string' (2015年12月)指的是https://github.com/Microsoft/TypeScript/blob/master/lib/lib.es6.d.ts。
注意文件标题之间的区别!
我看了typings,发现es6.lib.d.ts和lib.es6.d.ts都没有。
我复制了上面引用的lib.es6.d.ts,并在我的程序(/// <reference path="./typings/lib.es6.d.ts" />)中引用了它;编译器在处理该文件时倾斜。第132行
readonly prototype: Object;第132行是文件中readonly的第一次出现。编译器指向readonly并报告
error TS1131: Property or signature expected.有人知道如何教ES6给TypeScript吗?还是教它?(当然,我很想使用ES6特性!)提前感谢!
发布于 2016-05-06 01:47:18
任何人都知道如何教ES6到TypeScript
使用最新的编译器(您确实应该使用该https://basarat.gitbooks.io/typescript/content/docs/getting-started.html#nightly-typescript),您可以使用--lib es6选项。
更多
关于lib选项的更多信息:https://github.com/Microsoft/TypeScript/issues/6974
(PS:在alm https://github.com/alm-tools/alm/中支持它)
发布于 2016-05-06 01:49:45
只要设置ES6作为你的目标,你已经教ES6打字。
// tsconfig.json
{
"compilerOptions": {
"target": "ES6",
"module": "commonjs",
"sourceMap": true,
"noImplicitAny": true
}
}https://stackoverflow.com/questions/37062880
复制相似问题