-
Notifications
You must be signed in to change notification settings - Fork 13.1k
Closed
Labels
QuestionAn issue which isn't directly actionable in codeAn issue which isn't directly actionable in code
Description
Have I made a silly mistake here? I thought the tuple type [string, number] was roughly equivalent to the array-of-union-type (string | number)[], and that the following was therefore legal:
function lengths (xs: string[]): [string, number][] {
return xs.map((x: string) => [x, x.length])
}
However tsc 1.4 complains:
Config.ts(127,11): error TS2322: Type '(string | number)[][]' is not assignable to type '[string, number][]'. Type '(string | number)[]' is not assignable to type '[string, number]'.
Property '0' is missing in type '(string | number)[]'.
Metadata
Metadata
Assignees
Labels
QuestionAn issue which isn't directly actionable in codeAn issue which isn't directly actionable in code