我正在使用typescript @ next(版本2.1.0-dev.20160812具体). 我在尝试使用Arrays.prototype.includes时遇到错误. 例如这段代码 let myItems: Arraystring;let exists: boolean = myItems.includes('blah'); 生成以下错误:
我在尝试使用Arrays.prototype.includes时遇到错误.
例如这段代码
let myItems: Array<string>; let exists: boolean = myItems.includes('blah');
生成以下错误:
Property 'includes' does not exist on type 'string[]'.at line 124 col 26
这是我的tsconfig.json:
{ "compileOnSave": true, "compilerOptions": { "module": "es6", "target": "es6", "moduleResolution": "node", "allowSyntheticDefaultImports": true, "noImplicitAny": true, "sourceMap": true, "outDir": "ts-build", "jsx": "preserve" }, "exclude": [ "node_modules" ] }我通过将lib:[“es2016”,“dom”]添加到tsconfig.json中的编译器选项来修复此问题