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
Invalid type coercion with == operator and strings #24991
Actual behavior:
The code compiles. As mentioned in the comment, typescript assumes that level inside the if block is a number; however in reality that condition passes also for number-like string ("5")
Activity
Kingwl commentedon Jun 22, 2018
seems narrow type in
narrowTypeByEqualitynot handle the Relax Equal Operatori would like to add a new type comparable similar
areTypesComparable,that handle the Relax Equal Operator and narrow type
follow the rule: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Equality_comparisons_and_sameness
Fix #24991: Weaken narrowing for == (#29840)