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
if(isMaximised){varonClose=()=>{/* code */};}console.log(onClose);// Error: Variable 'onClose' is used before being assigned
Expected behavior: onClose should have the type () => void | undefined and be usable. In my opinion the warning about usage before assignment is only necessary when strictNullChecks is off.
Actual behavior: onClose has the type () => void and it doesn't compile when being used.
The text was updated successfully, but these errors were encountered:
JannesMeyer
changed the title
Hoisted variables should have be usable without assignment
Hoisted variables should be usable without assignment
Sep 15, 2016
JannesMeyer
changed the title
Hoisted variables should be usable without assignment
[Strict null checks] Hoisted variables should be usable without assignment
Sep 15, 2016
the compiler could not guarantee that this variable is used before it was initialized. if your intention is to treat it as () => void | undefined add a type annotation.
TypeScript Version: 2.0.2 with strictNullChecks
Code
Expected behavior:
onClose
should have the type() => void | undefined
and be usable. In my opinion the warning about usage before assignment is only necessary when strictNullChecks is off.Actual behavior:
onClose
has the type() => void
and it doesn't compile when being used.The text was updated successfully, but these errors were encountered: