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
Causes error TS2367: This condition will always return 'false' since the types 'number & Height' and 'number & Width' have no overlap.
There seems to be several issues here:
Why is number & Height not absorbed into just Height? - Might not be a bug
Why is it number & Height in the first place? - Might not be a bug
Why is there an error occurring here? Both Width and Height extend number and thus there should be ample overlap between the two types. - Defiantly an issue.
My best guess at what is occurring is the type checker doesn't have the capability to look at the "parent" of Width and Height and notice that they both have the same "parent"
Casting the types to Width and Height and doing the comparison still has the domain error.
π Expected behaviour
No errors occur
The text was updated successfully, but these errors were encountered:
Related to #47026; comparisons between two generic types are not usually allowed.
The wording of the error message "This condition will always return false because the types Foo and Bar don't overlap" isn't great, in my opinion. I'd prefer something like "Types Foo and Bar are not directly related to each other and comparing them is probably a mistake; if this is intentional, please assert one or both of the expressions to a common type like Foo | Bar." I guess that message is probably going to stay, though... #26592 is open, but #36534 is closed as "won't fix"
Its certainly disappointing that any checking doesn't occur, but I guess the complexity of the type checker needs to be considered, but it certainly should have a better compiler message needs to be used because it is a valid statement.
Bug Report
π Search Terms
Type Value Comparison Type Domain Overlap TS2367
π Version & Regression Information
β― Playground Link
Link to the example code
π» Code
π Actual behaviour
Causes error
TS2367: This condition will always return 'false' since the types 'number & Height' and 'number & Width' have no overlap.
There seems to be several issues here:
My best guess at what is occurring is the type checker doesn't have the capability to look at the "parent" of Width and Height and notice that they both have the same "parent"
Casting the types to Width and Height and doing the comparison still has the domain error.
π Expected behaviour
No errors occur
The text was updated successfully, but these errors were encountered: