Closed
Description
TypeScript Version: 3.4.0-dev.20190202
Search Terms:
Readonly tuple, map, as const, const context
Code
const pairs = [['1', 1], ['2', 2]] as const
new Map(pairs);
Expected behavior:
No error
Actual behavior:
TS2345: Argument of type 'readonly [readonly ["1", 1], readonly ["2", 2]]' is not assignable to parameter of type 'readonly [{}, {}][]'.
Type 'readonly ["1", 1] | readonly ["2", 2]' is not assignable to type '[{}, {}]'.
Type 'readonly ["1", 1]' is missing the following properties from type '[{}, {}]': pop, push, reverse, shift, and 6 more.
Playground Link:
Related Issues:
The same issue applies to some libraries on DefinitelyTyped. Maybe readonly tuples should be added to Common mistakes, like arrays?