node.js - Typescript error TS2339 -


i run small project has 1 class called iterator below:

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);     }   } } 

i installed typescript both -g flag , local in project. whenever try compile iterator.class.ts file js file, faced below error:
iterator.class.ts(18,29): error ts2339: property 'includes' not exist on type 'string[]'.

this tsconfig.json file , installed requirements mentioned in file :

{   "compileroptions": {     "module": "commonjs",     "target": "es5",     "moduleresolution": "node",     "lib": ["es2016", "dom"],     "typeroots" : ["./node_modules/@types"],     "types": ["node"]   } } 

i try both global installed of typescript , local 1 , each time gave error mentioned! change target es2016 , es2017 , add "es2016.array.includes" lib in tsconfig.js nothing changed in result. searched in issues on typescript , non of solutions don't worked me!

os: ubuntu 16.04 lts
node: v8.2.1
npm: v5.3.0
typescript: v2.4.2 , 2.2.2


Comments

Popular posts from this blog

javascript - Create a stacked percentage column -

Optimising Firebase database by automatically overwriting data -

javascript - Angular UI-Grid customTemplate directive causing rows to load slowly/? -