Repository navigation
DF-1509: Convert the public types, form models and engine tests to JavaScript with JSDoc - #508
Open
alexluckett wants to merge 4 commits into
Open
alexluckett wants to merge 4 commits into
alexluckett wants to merge 4 commits into
Conversation
…o JavaScript with JSDoc
FormModel, SummaryViewModel, the model type modules and engine/types are now .js files typed with JSDoc and checked by tsc. Members with a comment in the source become @Property lines with that comment as description. The typings, a jest mock and a comment refer to the new .js paths.
The type is published through ./engine/* in v5, with a lowercase "i". v6 is a major release, so it takes the corrected name now rather than in a later breaking release. The v5 to v6 guide lists the rename.
alexluckett
force-pushed
the
chore/df-1509-types
branch
from
November 25, 2026 09:02
83c32d3 to
7ed8b49
Compare
|
jbarnsley10
reviewed
Nov 26, 2026
| import { logger } from '~/src/server/common/helpers/logging/logger.js' | ||
| import { EN_GB } from '~/src/server/constants.js' | ||
| import { type ListFormComponent } from '~/src/server/plugins/engine/components/ListFormComponent.js' | ||
| import {} from '~/src/server/plugins/engine/components/YesNoField.js' |
Contributor
There was a problem hiding this comment.
Why are we doing this (import without specifier)?
jbarnsley10
approved these changes
Nov 26, 2026
jbarnsley10
left a comment
Contributor
There was a problem hiding this comment.
LGTM. Lots of Sonar issues if we want to fix them.
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
Part of the TypeScript to JavaScript migration (v6), this PR is stacked on the server and helpers PR and brings the changes to the published types together in one place. The package's
./typesentry point, the submission message schemas,engine/typesand the form models (FormModel,SummaryViewModel, the modeltypes,index,unavailable-view-model, and the emptySectionandRepeatingSummaryViewModel) are converted to JavaScript with JSDoc types, along with the 24 engine, i18n, model and output formatter tests. A final commit renamesFileUploadFieldDetailitem.@importblock at the end of each file, annotations are now@type,@paramand@returns, and casts are JSDoc casts../types(export type { X } from '…') are now@import { X as XType } from '…'followed by@typedef {XType} X, with@templatefor generics. They are the same 77 names, from the same modules and in the same order as onmain. Inschema.js, the result of eachJoi.object<X>()call is cast with/** @type {ObjectSchema<X>} */ (Joi.object()).@propertydescriptions, so they now appear as hover text. Where a type extends another, its own members move into a new named typedef joined with&, which publishes four new names:FormSubmissionErrorFields,ExecutableConditionFields,DetailItemFieldFieldsandDetailItemRepeatFields.FormModelconstructor,def: typeof this.defis nowdef: FormModel['def'], which is the same type; JSDoc does not allowthisin a parameter type.FormModel.getReference, added onmainwith the payment reference fix, has been converted with the rest of the class, and its tests withFormModel.test.SummaryViewModelsnapshot has been renamed along with its test (.test.ts.snapto.test.js.snap), and its content is unchanged. Jest names a snapshot after its test file.@defra/forms-engine-plugin/typesas well asPluginOptionsandFormContext, so applications can no longer augment them through declaration merging.?, sox?: Tbecomesx: T | undefinedonFormModel(engine,ordnanceSurveyApiKey,controllers) andSummaryViewModel(11 fields). This only affects code that types a plain object as one of these classes.FileUploadFieldDetailitemis renamedFileUploadFieldDetailIteminengine/typesand the output formatters. The type is published through./engine/*, and since v6 is a major release, this is the right time to correct the name. The v5 to v6 guide describes the rename../helpers.jsinhelpers.test.jshave been merged into one, which is the only runtime change in the tests. Twothis:parameters inside function types are kept as written.src/typings/hapiandsrc/typings/joinow importengine/types.js, and thejest.mockpaths inform-context.testnamemodels/index.js.Apart from the merged test import and the removed
export {}lines, the compiled code is identical tomain. 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).