volto icon indicating copy to clipboard operation
volto copied to clipboard

Enhance utility type definitions with typed method signatures

Open ompharate opened this issue 1 month ago • 1 comments

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

  • [x] I signed and returned the Plone Contributor Agreement, and received and accepted an invitation to join a team in the Plone GitHub organization.

  • [x] I verified there aren't other open pull requests for the same change.

  • [x] I followed the guidelines in Contributing to Volto.

  • [x] I successfully ran code linting checks on my changes locally.

  • [x] I successfully ran unit tests on my changes locally.

  • [x] I successfully ran acceptance tests on my changes locally.

  • [x] If needed, I added new tests for my changes.

  • [x] 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


ompharate avatar Nov 23 '25 15:11 ompharate

[!CAUTION] The Volto Team has suspended its review of new pull requests from first-time contributors until the release of Plone 7, which is preliminarily scheduled for the second quarter of 2026. Read details.

Thanks for submitting your first pull request! You are awesome! :hugs:

If you haven't done so already, read Plone's Code of Conduct, Contributing to Plone, First-time contributors, and Contributing to Volto, as this will greatly help the review process.

Welcome to the Plone community! :tada:

boring-cyborg[bot] avatar Nov 23 '25 15:11 boring-cyborg[bot]

@ompharate Thanks for the contribution! I took a look because we want this since a while, and I decided to go forward with it and complete it myself, because I'd like to have it as a baseline for other features. I hope you don't mind.

I added documentation too.

sneridagh avatar Dec 16 '25 10:12 sneridagh

@pnicolli @ebrehault Could you please take a look? It addresses the concern in:

https://github.com/plone/volto/pull/7603#discussion_r2553276210

sneridagh avatar Dec 16 '25 11:12 sneridagh

Glad to contribute. please feel free to loop me in if I can help with follow-ups

ompharate avatar Dec 16 '25 11:12 ompharate

@ebrehault @pnicolli going to merge this one, we can improve this later if you have anything.

sneridagh avatar Dec 22 '25 15:12 sneridagh

Congratulations on your first merged pull request in this project! :tada: Congratulations
Thank you for contributing, we are very proud of you! :heart:

boring-cyborg[bot] avatar Dec 22 '25 15:12 boring-cyborg[bot]