javascript - How can I get TypeScript to build iterables in ES6 to ES5? -
i trying create unique array of user objects in angular 2 writing in typescript. using short , elegant es6 way create unique array:
this.users = array.from(new set(this.users))
i error when build typescript es5:
argument of type 'set<{}>' not assignable parameter of type 'iterableshim<{}>'. property '"es6-shim iterator"' missing in type 'set<{}>'.
i tried setting this.users : iterableshim<t>
iterableshim not acceptable type string. docs string, array, typedarray, map , set built-in iterables, because prototype objects of them have symbol.iterator method. (source: https://developer.mozilla.org/en-us/docs/web/javascript/guide/iterators_and_generators ) there way typescript compile es6 recognizes iterables es5 without errors?
using lib
option as:
"lib": [ "dom","es6" ]
the following works fine :
let users = [] users = array.from(new set(users))
more
https://basarat.gitbooks.io/typescript/content/docs/types/lib.d.ts.html#lib-option
Comments
Post a Comment