Is it possible to define this specialized overload without introducing the signature which exactly matches the implementation?
on(eventName: string, cb: Function);
on(eventName: "view", cb: (args: {
foo: {
}
}) => void);
on(eventName: string, cb: Function) {
}
When I remove it I receive this error:
Specialized overload signature is not assignable to any non-specialized signature.
Specialized overloads are a specialism of one of the other overload signatures (the implementation signature is not visible, so doesn't count).
When you use a specialized overload, there must be at least one non-specialized signature that the specialized version "makes special".
The return type of the specialized signature has to be a sub-type of the non-specialized signature.
So in short, you have to have the overload even if it is identical to the implementation signature.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With