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
{{ message }}
Repository navigation
TS2367: Support loose equivalence of 'number' and 'string' #30655
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]) {
~~~~~~~~~~ ~~~~~~~~~~
Activity
RyanCavanaugh commentedon Apr 1, 2019
This is the intended error for this code.