Comparison operator is prohibited for nulls, but is allowed for union types containing the null type (with strictNullChecks turned on). #13863
Labels
Needs Investigation
This issue needs a team member to investigate its status.
TypeScript Version: 2.1.5
Code
--strictNullChecks
should be enabled.Expected behavior:
Both comparisons should generate a compilation error.
Actual behavior:
The first comparison (nil < 10) fails to compile (as expected), but the second one (n < 1) compiles successfully.
It seems odd that the same operation (less-than number) is not allowed for
null
(what is completely fine), but allowed for union type that includesnull
. If there are some solid reasons to behave this way, I think they should be mentioned in the language guide (can't find something about it).The text was updated successfully, but these errors were encountered: