Suggestion: narrower parameters for NumberConstructor #20754
Labels
Suggestion
An idea for TypeScript
Working as Intended
The behavior described is the intended behavior; this is not a bug
TypeScript Version: 2.6.2
Code
Expected behavior:
Number(foo)
should be an error.Actual behavior: Type checks.
num
isNaN
at runtime.I assume this is WAI, but figured I'd ask. This came up when I got a type error in a math expression, something like
2 * box.width
. I didn't read the error closely and assumed the issue was thatbox.width
was a string. So I made it2 * Number(box.width)
. This made the error go away, but introducedNaN
s at runtime.Number
is declared as:could we make this narrower? maybe
The text was updated successfully, but these errors were encountered: