Enhance utility type definitions with typed method signatures #7652
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The Problem
When calling [registerUtility], you could pass any random function as the [method] parameter, regardless of what that utility type was supposed to expect.
The Fix
created a type-safe utility registration system that enforces correct method signatures based on the utility type
For utility types that don't exist in [UtilityTypeSignatures], the conditional type falls through to the else branch, which allows any function signature
You can extend [UtilityTypeSignatures] via declaration merging
I signed and returned the Plone Contributor Agreement, and received and accepted an invitation to join a team in the Plone GitHub organization.
I verified there aren't other open pull requests for the same change.
I followed the guidelines in Contributing to Volto.
I successfully ran code linting checks on my changes locally.
I successfully ran unit tests on my changes locally.
I successfully ran acceptance tests on my changes locally.
If needed, I added new tests for my changes.
If needed, I added documentation for my changes, either in the Storybook or narrative documentation.
I included a change log entry in my commits.
Closes #7651