Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Typescript Error: TS2339:Property 'map' does not exist on type 'string'

It seem typescript doesn't currently have the new object types in ECMAScript 2015 (6th Edition, ECMA-262). Here is my code:

const SkipAny: string = requestBody.SkipAny;
CurTester.SkipAny = SkipAny.map((value)=>{return new RegExp(value)});

The error I get is:

TS2339:Property 'map' does not exist on type 'string'

I would like to find a work around for this but I do want to use map. Is there anyway to ignore this rule in tslint?

like image 454
Bill Software Engineer Avatar asked Oct 28 '25 22:10

Bill Software Engineer


1 Answers

Turns out the error is correct, I should had used array:

const SkipAny: string [] = requestBody.SkipAny;
CurTester.SkipAny = SkipAny.map((value)=>{return new RegExp(value)});
like image 165
Bill Software Engineer Avatar answered Oct 31 '25 15:10

Bill Software Engineer