Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork8.1k
feat(microservices): add event typings to the@EventPattern decorator#14798
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
base:master
Are you sure you want to change the base?
Uh oh!
There was an error while loading.Please reload this page.
Conversation
Adds overloads for `@EventPattern` to allow validation that decorated method signatures match event payload types based on a specified mapping type. Includes tests demonstrating correct usage and error cases with `// @ts-expect-error`.
coveralls commentedMar 18, 2025
Pull Request Test Coverage Report forBuild 17672a4a-de8d-4a97-8fa2-abef07e8be32Details
💛 -Coveralls |
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.
Pull Request Overview
This PR adds static type overloads for the @EventPattern decorator to ensure the decorated method's parameter types align with the event payload types specified in a mapping type, along with tests to verify the desired behavior.
- Introduces generic, typed overloads for @EventPattern in the decorator file
- Adds type safety tests in the corresponding spec file to demonstrate correct usage and expected error conditions
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| packages/microservices/test/decorators/event-pattern.decorator.spec.ts | Adds new static type safety tests for the @EventPattern decorator overloads |
| packages/microservices/decorators/event-pattern.decorator.ts | Introduces typed overloads for the EventPattern decorator to enforce correct event payload types |
Comments suppressed due to low confidence (1)
packages/microservices/decorators/event-pattern.decorator.ts:33
- [nitpick] Consider aligning the parameter naming between the typed overloads (using 'topic') and the untyped overloads (using 'metadata') for improved consistency and clarity. This may help reduce confusion about the intended usage.
<TEventTypes extends Record<string, any>>(joelday commentedApr 23, 2025
@Hardanish-Singh Does this PR need any follow-up work? I see your approval, but I'm not sure what needs to be done next before it can be merged. Thanks! |
Adds overloads for
@EventPatternto allow validation that decorated method signatures match event payload types based on a specified mapping type. Includes tests demonstrating correct usage and error cases with// @ts-expect-error.PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
What is the current behavior?
Issue Number: N/A
What is the new behavior?
Adds overloads to the
@EventPatterndecorator that creates a static type constraint between the pattern and the decorated method's parameter type.Example:
Does this PR introduce a breaking change?
Other information
topicis an appropriate name for these overloads instead ofmetadata.