Using typescript and babel-polyfill leads to compiler errors

I use babel-polyfill with typescript.

When I use the string.includes () function, I get an error

Error TS2339: Property 'includes' does not exist in type 'string'

There is a similar question in stack overflow: error TS2339: property 'endsWith' does not exist in type 'string'

The answer is to extend the String user interface

interface String {    
    endsWith(searchString: string, endPosition?: number): boolean;
};

I don't like this idea too much because it means that I will have to fix every es6 polyfill function this way.

Is there a way to tell typescript that it should use es6 definitions but translate to es5?

+4
1

, lib.es6.d.ts:

///<reference path="../path/to/node_modules/typescript/lib/lib.es6.d.ts" />

, es6-shim, , js, babel .

tsd install es6-shim
+3

Source: https://habr.com/ru/post/1625791/