I have the following map:
var myMap = new Map<string, [string, number]>()
The values of this map are always going to be a 2-item array, the first item being a string, and the second item being a number
myMap.set("foo", ["bar", 42])
This works as expected. Additionally, have an array with extra members does not work, also as expected
myMap.set("foo", ["bar", 42, 0]) // too many arguments
The problem I'm having is defining this outside of the set():
var value = ["bar", 42]
myMap.set("foo", value)
This causes the following error:
Argument of type '(string | number)[]' is not assignable to parameter of type '[string, number]'.
Type '(string | number)[]' is missing the following properties from type '[string, number]': 0, 1
I can fix this by forcing the type:
var value = <[string, number]>["bar", 42]
But I hate doing this as it seems too verbose (I very well may have arrays that are defined as 10 or 15 members). Is there anything else I can do to resolve this issue?