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
Type inference for variable "b" at row 14 is wrong, even if I specify explicitly "boolean | null". The compiler is unable to understand that b is effectively assigned immediately at line 15, and I find it to be correct, but it also infers that the actual type of the variable is just "null" and not "boolean | null" as I provided.
As a result, the code at line 16 (which I loosely borrowed from jasmine), does not compile, as the expect function is unable to get the property generic type instantiation, because T gets replaced with "null".
The text was updated successfully, but these errors were encountered:
TypeScript Version: 4.1.3
Search Terms: inference, variable, block, wrong
Expected behavior:
It should compile just fine.
Actual behavior:
Compilation error on row 16 due to wrong inference of variable.
Related Issues: not found
Code:
Compiler Options
Playground Link: Provided
Type inference for variable "b" at row 14 is wrong, even if I specify explicitly "boolean | null". The compiler is unable to understand that b is effectively assigned immediately at line 15, and I find it to be correct, but it also infers that the actual type of the variable is just "null" and not "boolean | null" as I provided.
As a result, the code at line 16 (which I loosely borrowed from jasmine), does not compile, as the expect function is unable to get the property generic type instantiation, because T gets replaced with "null".
The text was updated successfully, but these errors were encountered: