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
TS2367: This condition will always return 'false' since the types 'number' and 'string' have no overlap.
Code
declarevaraa: string[];declarevarbb: string[];for(letx=0;aa[x]&&bb[x];x++){if(aa[x]!==bb[x]){constc=Number(aa[x]);constd=Number(bb[x]);if(c==aa[x]&&d==bb[x]){// Do stuff if both strings contain numbers}}}
Expected behavior:
TypeScript considers loose equivalence of string and number valid, at least when type checking JavaScript code.
Actual behavior:
.hidden/stuff.ts:9:7 - error TS2367: This condition will always return 'false' since
the types 'number' and 'string' have no overlap.
9 if (c == aa[x] && d == bb[x]) {
~~~~~~~~~~ ~~~~~~~~~~
TypeScript Version: 3.4.0-dev.201xxxxx
Search Terms:
Code
Expected behavior:
TypeScript considers loose equivalence of
string
andnumber
valid, at least when type checking JavaScript code.Actual behavior:
Related Issues:
Additional info:
This is a snippet of legacy code that I’m not allowed to change.
The text was updated successfully, but these errors were encountered: