-
Notifications
You must be signed in to change notification settings - Fork 13.2k
Closed
Labels
Working as IntendedThe behavior described is the intended behavior; this is not a bugThe behavior described is the intended behavior; this is not a bug
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.
ankitrg, zheeeng, TheLus, bestwestern, michaelharrod and 56 moreNeboer, KesselRun-xyz and felixcatto
Metadata
Metadata
Assignees
Labels
Working as IntendedThe behavior described is the intended behavior; this is not a bugThe behavior described is the intended behavior; this is not a bug