-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Issue with subclasses #6
Comments
I finally worked around this issue by following how FeathersJS extends its ServiceTypes interface; To make this work, follow these steps:
You will now have a strongly typed "newEvent" for the child class and observe that other child classes will not have that new event, as expected. Notice that I created the interfaces and classes in separate files as to eliminate any possibility for a collision with another Enjoy. |
Scratch my previous. So, you could use what I stated previously, however you will end up with code bleed all over. I have another solution that I've been using for a few months, but it's hackish. |
Hi, thanks for the great library 👍
I have a question about the subclasses with different events example that you provided in the readme:
The example works when calling the events from outside the class, but not from within the class itself. Specifically, if I alter the example to be as follows:
Then the compiler fails at the
this.emit('spawn');
line with the error:Argument of type '[]' is not assignable to parameter of type 'Parameters<({ spawn: () => void; } & E)["spawn"]>'.
I'm assuming this is because of some constraint that can't be applied, but I can't seem to wrap my head around it. Is there any way to solve this?
The text was updated successfully, but these errors were encountered: