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
{{ message }}
Repository navigation
Function not callable when using a generic type parameter and union typesΒ #50182
The following error is reported when calling mod.on('foo'); without narrowing its exact type:
This expression is not callable.
Each member of the union type '(<EventName extends keyof PayloadA>(eventName: EventName) => void) | (<EventName extends keyof PayloadB>(eventName: EventName) => void)' has signatures, but none of those signatures are compatible with each other.
π Expected behavior
Since mod.on('foo') works in all possible branches when narrowing down the type I would expect it to also work without branching and narrowing.
Joe Calzaretta (@jcalz) thanks for pointing that out. I have troubles understanding the recommended solution and applying it for my use-case. Iβve posted the question on stackoverflow.
Activity
jcalz commentedon Aug 4, 2022
Duplicate of #30581, recommended solution is at #47109
lo1tuma commentedon Aug 5, 2022
Joe Calzaretta (@jcalz) thanks for pointing that out. I have troubles understanding the recommended solution and applying it for my use-case. Iβve posted the question on stackoverflow.