Skip to content
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 interface instead of type to allow for declaration merging #1165

Merged

Conversation

shawnmcknight
Copy link
Member

📝 Description

This PR modifies a few type aliases in the declaration file to instead be interfaces. As noted in #1164 , an interface can be augmented through declaration merging. This is important for consumers and third party plugins as it allows them to extend the built-in types. type will not allow this merging behavior.

This PR adjusts ActionSchema, EventSchema, ServiceEvent, and ContextParentSpan to all be interfaces instead of types. A few of these types also were intersections with ThisType<Service<S>>. In order to avoid breaking changes, the ServiceEvents type was adjusted to have the ThisType<Service<S>> instead so the type of this will be available in the appropriate contexts for service schemas. The ServiceActionsSchema type already included ThisType<Service<S>> so a change there was unnecessary.

A few additional unrelated changes were triggered due to prettier auto-formatting.

This PR supersedes and closes #1164 .

💎 Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

🚦 How Has This Been Tested?

I loaded the changed definition in a large repository of services and ran typescript type checking with no errors. Additionally, I augmented the ActionSchema type in a third party library successfully and was able to access the augmented types.

🏁 Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • I have commented my code, particularly in hard-to-understand areas

Copy link
Member

@icebob icebob left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome, thanks!

@icebob icebob merged commit 1b760d6 into moleculerjs:master Dec 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants