3 ms·
Exactly. Leaving off the return type annotation is just asking for trouble, and this example proves it. And the actual type of the const won't be `string | num
by ihsw 10y ago
Exactly. Leaving off the return type annotation is just asking for trouble, and this example proves it.
And the actual type of the const won't be `string | number` -- it will be `any`.
MaulingMonkey[1] has the right idea, though.
[1] https://news.ycombinator.com/item?id=12192240 https://news.ycombinator.com/item?id=12192240