打字稿错误TS2339

我运行一个只有一个名为iterator的类,如下所示:

Iterator.class.ts

export class Iterator { private itr: any; private opt: any; private keys: any; private type: string; constructor(iterable, options) { this.itr = iterable; this.opt = options; this.keys = []; this.prepare(); } private prepare() { this.type = this.itr.constructor.name.toLowerCase().trim(); if (['array', 'object'].includes(this.type)) { this.keys = Object.keys(this.itr); } } } 

我还在我的项目中使用-g标志和local来安装打字稿。 但每当我尝试编译我的iterator.class.ts文件到js文件,我遇到了下面的错误:
iterator.class.ts(18,29):错误TS2339:属性'includes'在types'string []'上不存在。

这是我的tsconfig.json文件,我安装了我在这个文件中提到的所有要求,如:

 { "compilerOptions": { "module": "commonjs", "target": "es5", "moduleResolution": "node", "lib": ["es2016", "dom"], "typeRoots" : ["./node_modules/@types"], "types": ["node"] } } 

我尝试全球安装的打字稿和地方之一,每次我给我提到的错误! 我也改变目标到es2016和es2017,并添加“es2016.array.includes”在tsconfig.js中的lib,但结果没有任何变化。 我在打字稿和非解决scheme的问题search没有为我工作!

操作系统:Ubuntu 16.04 LTS
NODE:v8.2.1
npm:v5.3.0
打字稿:v2.4.2和2.2.2