-
-
Notifications
You must be signed in to change notification settings - Fork 587
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
Update types for Context, ActionHandler, and Cachers Base #626
Conversation
…ware-type Add call middleware type
Transit options missing type definition for disableVersionCheck as specified in v0.13 broker documentation
…efinitions Added Type Definition disableVersionCheck for BrokerTransitOptions
- ActionHandler accepts Context<any, any> - Context constructed with unknown params - defaultKeygen type added to Cachers
- CallMiddlewareHandler type should not be included
- the method has a condition for expecting meta to be null - this condition warrants the possibility to expect null as meta
Pull Request Test Coverage Report for Build 2157
💛 - Coveralls |
@ipetrovic11 @shawnmcknight please review it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The changes to ActionHandler
and Context
are what was discussed in that other PR, so this can be a replacement for that PR.
One thing I question is the type of params
in the defaultKeyGen
method. I believe params
no longer has (if it ever had) a restriction on type. That is, you could pass through a string as the params value in a call. However, this is typed as object | null
which only represents the non-primitive types and null
.
I'm thinking this should probably be typed as any
since I do not believe there is a restriction on what type parameters can be. However, I'm not really sure if it is intentional to allow any type through as parameters -- most of the jsdocs throughout moleculer indicate params to be an object, including for the defaultKeyGen
. If it is intentional for params to allow any type, then this should probably be typed as any
and eliminate the restrictions and the jsdocs for the defaultKeyGen
should be updated to reflect that. If the allowing of any parameter type is not by design, then this type is fine as is.
@icebob Can you provide any additional detail on the intent of the type for params?
I've checked the source, so in the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@glenn-p-ryan Can you go ahead and update the jsdocs for the defaultKeygen
to match the TS type?
In the |
- params can be null
It appears to me that @icebob Do you agree? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Yes, meta can't be null, it's initialized as |
📝 Description
This PR updates types for
Context
andActionHandler
which, as a result, should solve the problem discussed in PR 600. Additionally, the typedefaultKeygen
has been added to theCachers
namespace under theBase
class. This method type for generating the key seems to be missing.🎯 Relevant issues
Issue being discussed here
💎 Type of change
🚦 How Has This Been Tested?
Overrode types in our current implementation of moleculer and tested for ts errors.
🏁 Checklist: