You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Map constructor doesn't work with target ES5, lib ES6 #8407
Actual behavior:
Errors are reported on the first two lines:
Argument of type '(string | number)[][]' is not assignable to parameter of type 'Iterable<[{}, {}]>'.
Argument of type '(string | number)[][]' is not assignable to parameter of type 'Iterable<[string, number]>'.
I think the reason is that the compiler doesn't use iterators to resolve the type arguments when the target is ES5. Adding an overload to the Map constructor, which takes an array of tuples instead of an iterator, would probably fix this. I'm not sure whether this happens on more locations though, if so it might be worth to pick up iterators in the compiler even when the target is ES5.
Iterator support are not guaranteed to exist if target is not ES6, so i think the assumption we have today is accurate. I agree with your proposal to add an array overload for Map, WeakMap, Set and WeakSet. A PR would be appreciated.
Activity
mhegazy commentedon May 1, 2016
Iterator support are not guaranteed to exist if target is not ES6, so i think the assumption we have today is accurate. I agree with your proposal to add an array overload for
Map,WeakMap,SetandWeakSet. A PR would be appreciated.ivogabe commentedon May 2, 2016
I've opened PR #8422
ivogabe commentedon May 5, 2016
Thanks!