Confusing error message: Operator '===' cannot be applied to types '1' and '0'. · Issue #25245 · microsoft/TypeScript (original) (raw)
TypeScript Version: 3.0.0-dev.20180623
Search Terms:
Code
function foo(x: [number]) { return x.length === 0; }
Bug:
The error message is: Operator '===' cannot be applied to types '1' and '0'.
I found this error very confusing. It took me a while to understand that the error meant that the type on the left hand side was 1
.
In this case, I think we should instead report that the condition always evaluates to false.
Related Issues:
/cc @chrisdias