Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

error TS2339: Property 'endsWith' does not exist on type 'string'

I get this error on the code block below.

error TS2339: Property 'endsWith' does not exist on type 'string'

let myList = angular.element(elem).attr("href").split("/");
let last = _.last<string>(myList);
if (last.endsWith("something")) {
   return last;
}

I have also discovered this link that shows that there is a function endsWith(...).

http://definitelytyped.org/docs/typescript-services--typescriptServices/classes/typescript.stringutilities.html

Do I miss some .d.ts file or what?

like image 874
ipinak Avatar asked Dec 23 '15 08:12

ipinak


1 Answers

While compiling your typescript code, please point the target to ES6.

tsc --target ES6 "filename"
like image 151
wandermonk Avatar answered Sep 28 '22 08:09

wandermonk