You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
No error when using uninitialized value in noImplicitAny & strictNullChecks mode #12002
This is actually by design. Your var x is an implicit any variable that is tracked by control flow analysis (#11263). Because it hasn't been initialized, its control flow type in the 100 + x expression is undefined, and the + operator permits undefined as an operand value. If anything, we should discuss whether the numeric operators should be stricter with respect to undefined and null, but that's a different discussion.
Activity
ahejlsberg commentedon Nov 2, 2016
This is actually by design. Your
var xis an implicit any variable that is tracked by control flow analysis (#11263). Because it hasn't been initialized, its control flow type in the100 + xexpression isundefined, and the+operator permitsundefinedas an operand value. If anything, we should discuss whether the numeric operators should be stricter with respect toundefinedandnull, but that's a different discussion.DanielRosenwasser commentedon Nov 2, 2016
Sure, that issue definitely sounds like something we should look into; is the type of
xstill going to beundefinedundernoImplicitAny?