govuk-frontend
govuk-frontend copied to clipboard
[Stretch] Review the overlap of the different types representing a component class in our code
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.
This has also been flagged by @colinrotherham in this comment.
Wondering if:
- for
ChildClasswe could have the one inconfiguration.mjsextend the one fromcomponent.mjs(as it's what the classes actually do), which would allow it not to redefinemoduleNameand benefit from any further properties added to the base component. It might be useful to rename it toConfigurableChildClassfor clarity - for the
ChildClassConstructortype, I'm wondering if we need a generic type ofComponentConstructor<Class>which createstypeof Component & Classto be used asComponentConstructor<ChildClass>incomponent.mjsandComponentConstructor<ChildClass<ConfigurationType>>inconfiguration.mjsat the point we do the casting with@type.