Or in other words: “can I please have a TypeScript 5/6/7 language spec?”
——-
Using “extends” in a TS generic type-param constraint is straightforward to understand if you’re only concerned with Java/C#-style single inheritance for classes - and one can stretch that to include interface types once you wean-off Java/.NET nominal typing and get comfortable with structural typing, then it’s straightforward to reduce it to “ T extends U means “T must subclass U” - or even “A T -shaped plug can be stored in a U -shaped hole”.
But my personal intuition breaks down when the extends constraint is used with other kinds of types, especially when the concept of subclassing or specializing or “extending” is inverted:
Consider type Two = ‘foo’ | ‘bar’; - if I then define type Three = Two | ‘baz’; then intuitively one can say “Three extends Two” (that is, the set of possible values for Three is extended from the set of values for Two” - but a Three -shaped plug does not fit into a Two -shaped hole: ’baz’ is not a Two .…