this
parameter of union signatures should be the intersection of constituents’ this
parameters
#31547
Labels
Milestone
...but currently it’s the union. Discovered while looking at #31485.
Minimal repro:
Silly but understandable real-world-ish example (playground):
Since
cow.isARealCow
might callthis.drive()
or might callthis.eatGrass()
, the only thing that should be able to call it is something has aweight
,eatGrass()
,odometer
, anddrive()
—that is, the intersection of the constitutents’this
parameter types. (Perhaps a mechanical cow of some kind would do.)TypeScript Version: 6a559e3
Search Terms: union signatures this parameter variance intersection
Playground Link
Related Issues: #31485
The text was updated successfully, but these errors were encountered: