Array.from and other new methods from ES6
So I was googling and asking on StackOverflow. For now no clear answer. So decided to ask here as for me it is a blocker.
How can use the newest methods for existing JS types (like Array, Number)?
Array.from(someIterable) throws an error: error TS2339: Property 'from' does not exist on type 'ArrayConstructor'
I would appreciate any tip, how to make it work.
You have to specify "target": "es6" in tsconfig.json
Alternatively you can add make .d.ts file contains
interface ObjectConstructor {
assign(target : any, ...sources: any[]) : Object;
}
and then reference it. But if you will want to support es5, you will have to use polyfill for that - https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign#Polyfill
"target": "es6" in tsconfig.json, or --target es6 on commandline
So, yes I changed the target from es5 to es6. And now I get: ERROR in node_modules/typescript/lib/lib.es6.d.ts (1257,11): error TS2300: Duplicate identifier 'Promise'.
@mayacode that is because your project is importing something else that is declaring Promise (something like maybe Bluebird)
Even though your googling and questions on StackOverflow didn't resolve your issues, they are the correct places for these types of questions.