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
I am just a TypeScript user myself, but this is much more complex than you might think, because function bar is hoisted to the top of the scope before your if:
Yes, true. I realize this is a slightly tricky case, but I think this type error/warning is bogus: x can only be a number within bar(), and I got the impression from the docs that TS 2.0 (though not 1.8) is supposed to know this.
TypeScript Version
2.0 (installed via
npm install typescript@2
)Code
Expected behavior
Code compiles cleanly.
Actual behavior
Compiler complains
Operator '+' cannot be applied to types 'number' and 'number | string'
(within functionbar()
).The text was updated successfully, but these errors were encountered: