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
Type 'any[]' is not assignable to type '[any, any]' when constructing a Map from array of entries #22870
lib/util/objectToMap.js:9:17 - error TS2345: Argument of type 'any[][]' is not assignable to parameter of type 'Iterable<[any, any]>'.
Types of property '[Symbol.iterator]' are incompatible.
Type '() => IterableIterator<any[]>' is not assignable to type '() => Iterator<[any, any]>'.
Type 'IterableIterator<any[]>' is not assignable to type 'Iterator<[any, any]>'.
Types of property 'next' are incompatible.
Type '{ (value?: any): IteratorResult<any[]>; (value?: any): IteratorResult<any[]>; }' is not assignable to type '{ (value?: any): IteratorResult<[any, any]>; (value?: any): IteratorResult<[any, any]>; }'.
Type 'IteratorResult<any[]>' is not assignable to type 'IteratorResult<[any, any]>'.
Type 'any[]' is not assignable to type '[any, any]'.
Property '0' is missing in type 'any[]'.
9 return new Map(Object.keys(obj).map(key => [key, obj[key]]));
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Automatically closing this issue for housekeeping purposes. The issue labels indicate that it is unactionable at the moment or has already been addressed.
Activity
DanielRosenwasser commentedon Mar 26, 2018
I think this looks like a duplicate of #11152.
MartinJohns commentedon Mar 26, 2018
The tuple is inferred to be an array. As a temporary workaround you can just specify the exact type when calling
map:That will make it explicit that you want a tuple.
mhegazy commentedon Mar 26, 2018
in a .js file you can cast using
/** @type ... */:typescript-bot commentedon Apr 10, 2018
Automatically closing this issue for housekeeping purposes. The issue labels indicate that it is unactionable at the moment or has already been addressed.