Repository navigation
DF-1509: Convert the component classes and helpers to JavaScript with JSDoc - #511
Open
alexluckett wants to merge 1 commit into
Open
alexluckett wants to merge 1 commit into
alexluckett wants to merge 1 commit into
Conversation
alexluckett
force-pushed
the
chore/df-1509-components
branch
from
November 25, 2026 09:03
476248f to
019b8c1
Compare
|
jbarnsley10
approved these changes
Nov 27, 2026
jbarnsley10
left a comment
Contributor
There was a problem hiding this comment.
LGTM (apart from the number of Sonar issues). Approving in principle
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.




Proposed change
This is the last conversion PR of the TypeScript to JavaScript migration (v6). Stacked on the page controllers PR, it converts the 45 files in
engine/components/andcomponents/helpers/to JavaScript with JSDoc types. These files make up the published./componentsAPI, and since every component inherits fields from its parent class, this is the PR most likely to need discussion.@importblock at the end of each file, annotations are now@type,@paramand@returns, and casts are JSDoc casts.declare. JavaScript has no type-only field, and a field without a value would reset the inherited value toundefinedaftersuper(), so each field takes the value the parent constructor has already set:declare. The@ts-expect-errorcovers only that one false error, andtscwill report it as unused if the error ever goes away. None of these names is defined as a getter or setter on a parent class, and every component class is built with the same values and property descriptors as onmain.limitsonCheckboxesField,FileUploadFieldandGeospatialField, andcontentanddeclarationConfirmationLabelonDeclarationField) are now plain typed fields, set by the constructor. OnDeclarationFieldthis changes the order of its own properties, but not their values.TrackingField.schema,EmailAddressField.formSchemaandstateSchema), the value is cast to the inherited type; otherwise JavaScript would give the subclass field a different, inferred type.PaymentFieldincludes the payment reference fix frommain: the reference comes frommodel.getReference(state, request), and the payment metadata is{ formId, language }.?, sox?: Tbecomesx: T | undefinedonComponentBase(id,page,schema,options),ListandListFormComponent(list),ComponentCollection(page,parent) andLocationFieldBase(instructionText). This only affects code that types a plain object as one of these classes.LocationFieldBaseis no longerabstractin the types. The class has@abstract, andgetValidationConfigandgetErrorTemplatesare now stubs that throwNot implemented. Both methods are implemented byOsGridRefFieldandNationalGridFieldNumberField, and the two stub lines are not covered by tests.ViewModel,Label,ListItem, the*Statetypes andUkAddressState.DateInputItemuses@propertydescriptions like the other types, and its member comment stays onprefix, where it was in the source. The// Submission datacomments after union members ingetAnswerandgetAnswerMarkdownhave moved into the[options]description.getAllPossibleErrors,tscleaves it out of the published types; the method is still available through the parent class.answer.test.jsandgenerate-component-previews.test.jsnow mockhelpers/components.js, andsonar-project.propertiesrefers toDatePartsField.jsandMonthYearField.js.The compiled code differs from
mainonly in the 78 field lines, the 5 plain field declarations, the 2LocationFieldBasestubs and 2 type-only modules that no longer emitexport {}. The full test suite gives the same results as onmain(2,583 passed, 13 skipped).Jira ticket: DF-1509
Type of change
Checklist
README.mdanddocs/*(where appropriate, e.g. new features).npm run test).npm run lint).npm run format).