-
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
Tuple types aren't always inferred when calling generic functions. For example:
function identity<A>(value: A): A {
return value
}
// works
const [a1, b1]: [number, string] = [1, 'a']
// works
const [a2, b2]: [number, string] = identity<[number, string]>([1, 'a'])
// breaks
const [a3, b3]: [number, string] = identity([1, 'a'])
Output:
foo.ts(12,7): error TS2322: Type '(number | string)[]' is not assignable to type '[number, string]'.
Property '0' is missing in type '(number | string)[]'.
madelson
Metadata
Metadata
Assignees
Labels
QuestionAn issue which isn't directly actionable in codeAn issue which isn't directly actionable in code