Misleading error message when interface tries to extend constrained type parameter
#57,037 opened on 2024幎1æ12æ¥
Repository metrics
- Stars
- Â (48,455 stars)
- PR merge metrics
-  (å¹³åããŒãž 6d 17h) (30d ã§ 9 merged PRs)
説æ
ð Search Terms
"statically known members." "could be instantiated with a different subtype of constraint 'object'."
ð Version & Regression Information
- This changed between versions 3.6.2 and 3.7.5
⯠Playground Link
ð» Code
interface Example<T extends object> extends T {}
ð Actual behavior
I get the following message:
Interface 'Example' incorrectly extends interface 'T'. 'Example' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'object'.
This error message is misleading. The interface does not vary with T and since it declares no new members, is completely compatible with T.
ð Expected behavior
I expect a descriptive message. Prior to 3.6.2, the error message was more helpful:
An interface can only extend an object type or intersection of object types with statically known members.
This is still the error you get if the type variable T does not have the extends constraint.
Additional information about the issue
No response