Closed
Description
I think the bottom type, never
, could be used for this case: when passing an empty array to an argument of type T[]
, where T
is a type argument.
@ahejlsberg What do you think?
TypeScript Version:
1.7.5 / 1.8.0-beta / nightly (1.9.0-dev.20160528-1.0)
Code
function a<T>(xs: T[]) {
return xs;
}
const x = a([]);
function b<T extends Node>(xs: T[]) {
return xs;
}
const y = b([]);
Expected behavior:
Type of x
would be never[]
, y
would be Node[]
Actual behavior:
Type of x
is any[]
, y
is any[]
.