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
Duplicate #9239, basically. Call signatures from different declarations in union types can only be merged when they have sufficiently similar parameter types, and the differing argument types to change means that overload can't be merged. This process attempts to yield the best set of possible output overloads, so in this case change gets dropped.
TypeScript Version: 4.0.2
Search Terms: overload union type callback
Expected behavior: No Type error
Actual behavior:
Argument of type '"change"' is not assignable to parameter of type '"focus"'
Related Issues: Possibly #39692
Code
Output
Compiler Options
Playground Link: Provided
Details
Removing the overload (commenting out the
focus
eventType in the example), work fine, so TS is able to resolve the union type for the handler.Adding an
event
argument as a unionFooChangeEvent | BarChangeEvent
to the change's handler doesn't help the compiler resolve the overload.Defining a base signature for the overloaded method only helps if using
Base
and not a union of subtypes, which isn't acceptable if one wants to only accept a subset of subtypes.The text was updated successfully, but these errors were encountered: