govuk-frontend icon indicating copy to clipboard operation
govuk-frontend copied to clipboard

[Stretch] Review the overlap of the different types representing a component class in our code

Open romaricpascal opened this issue 1 year ago • 1 comments
trafficstars

What

Review the types representing a component class across our codebase and:

  • make sure their names are unique and expressive
  • shared concepts are named appropriately and reused as needed.

Why

The work on configuration will introduce another type to represent a partial component class. It seems it’ll have some overlap with the one used by createAll, as well as the one used in GOVUKFrontendComponent.

Keeping things tidy and nicely named will help us understand what's going on in the long run.

Who needs to work on this

Developers

Who needs to review this

Developers

Done when

  • [ ] We've reviewed the types and updated them as necessary.

romaricpascal avatar Nov 04 '24 17:11 romaricpascal

This has also been flagged by @colinrotherham in this comment.

Wondering if:

  • for ChildClass we could have the one in configuration.mjs extend the one from component.mjs (as it's what the classes actually do), which would allow it not to redefine moduleName and benefit from any further properties added to the base component. It might be useful to rename it to ConfigurableChildClass for clarity
  • for the ChildClassConstructor type, I'm wondering if we need a generic type of ComponentConstructor<Class> which creates typeof Component & Class to be used as ComponentConstructor<ChildClass> in component.mjs and ComponentConstructor<ChildClass<ConfigurationType>> in configuration.mjs at the point we do the casting with @type.

romaricpascal avatar Mar 18 '25 17:03 romaricpascal