Closed
Description
TypeScript Version: 2.0.0
Code
var x = [];
x.push(1);
Expected behavior:
Accept this, and have the type inferencer postulate x:number[]
. Alternatively, an error message along the lines of "cannot assign number
to parameter {}
" (because type inferencer could also assume x:undefined[]
).
Actual behavior:
(with strictNullCheck
)
error TS2345: Argument of type 'string' is not assignable to parameter of type 'never'.
This might be because of how never
is documented as the "bottom" type (for functions that never return), but since the code isn't using the result expression, this is pretty confusing. Is this because the assumed type of x
is never[]
?
I tried looking for related issues, I feel like it's slightly related to empty tuple discussions, but not 100% sure.