-
-
Notifications
You must be signed in to change notification settings - Fork 751
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
Use stricter type for HookContext 'method' prop #1896
Conversation
What about custom methods? |
This only affects the TypeScript type definitions for a hook's I'm unsure whether |
I added support for custom methods with this PR, it is something common and that I do very often. I do not use TypeScript and I am embarrassed to have to overload the type definition in all my projects. |
Oh, very cool. I was not aware of that. 👀 This should only affect TypeScript projects, so assuming you're not using TypeScript, no action should be necessary. 👍 If you are using TypeScript, you'll only get a compile warning. Your project should still compile and run as before. |
I'll look into automatically incorporating custom method names into the type definition here. 👍 |
It does not affect me directly. My IDE, IntelliJ IDEA, will use these types and maybe show me warnings, we'll see. |
I had a closer look at the type definitions for services; the current type definitions have limited support for custom methods. Opting for the It's likely going to end up taking a pretty serious refactor to Feathers' service type definitions to properly support inferred custom service methods. While it'd be a pretty good productivity boost for most TypeScript users, this is unfortunately not something I would be able to take responsibility for at the moment. |
A simple tweak to the HookContext's
method
property type declaration. This specifies a union type with the possible string types for themethod
property. Essentially allowing for autocompletes by the IDEs that support TypeScript, as well as warnings should you mistype a method name.