条件:我正在使用Win10,TypeScript 1.8和Visual Studio Code 1.0.0.我的代码就像
///<reference path = "./typings/lib.es6.d.ts" />
然后
let z = "0".repeat(4 - str.length)
这是let z线.
VS Code在“重复”下加上红色下划线并报告
[ts] Property 'repeat' does not exist on type 'string'.
我在命令行编译了
tsc <filename>.ts
编译器报告指出let z行中重复的开始
error TS2339: Property 'repeat' does not exist on type 'string'.
Beggin’与TypeScript不同,但是随ES2015(ES6)添加了.
问题:如何获得干净的编译?
编辑:缩短.
最佳答案 就我而言,我只在tsconfig.json文件中更改了这一行:
之前:
"compilerOptions": {
"target": "es5"
}
后:
"compilerOptions": {
"target": "es6"
}