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
Expected behavior:
Should complain about incompatible types, maybe with a warning that the == operator will lead to an implicit type conversion.
Actual behavior:
It does complain, but the error message is wrong.
error TS2367: This condition will always return 'false' since the types 'string' and 'number' have no overlap.
This is wrong. If the code is executed, the comparison will evaluate to true.
Related Issues: #30655. In that issue the expected behaviour was that loose comparisons of strings and numbers are considered valid. The issue was closed with a comment that an error message is intended here. I do agree with an error being the intended output. It's simply that the error message is wrong.
#29155 has exactly this problem as title but seems unrelated.
This should be correct. If you do not use any compiled code will behave right, if it compiles :-). You should not be able to compare different types. So, implicit conversions should not be valid typescript.
TypeScript Version: 3.8.3
Search Terms:
Code
Expected behavior:
Should complain about incompatible types, maybe with a warning that the
==
operator will lead to an implicit type conversion.Actual behavior:
It does complain, but the error message is wrong.
error TS2367: This condition will always return 'false' since the types 'string' and 'number' have no overlap.
This is wrong. If the code is executed, the comparison will evaluate to true.
Related Issues:
#30655. In that issue the expected behaviour was that loose comparisons of strings and numbers are considered valid. The issue was closed with a comment that an error message is intended here. I do agree with an error being the intended output. It's simply that the error message is wrong.
#29155 has exactly this problem as title but seems unrelated.
Playground Link: Provided
The text was updated successfully, but these errors were encountered: