Repository navigation
DF-1509: Convert the page controllers and their helpers to JavaScript with JSDoc - #510
Open
alexluckett wants to merge 2 commits into
Open
alexluckett wants to merge 2 commits into
alexluckett wants to merge 2 commits into
Conversation
…controller test stubs to JavaScript with JSDoc
alexluckett
force-pushed
the
chore/df-1509-controllers
branch
from
November 25, 2026 09:03
28baf21 to
81f112e
Compare
|
jbarnsley10
approved these changes
Nov 26, 2026
jbarnsley10
left a comment
Contributor
There was a problem hiding this comment.
LGTM other than many Sonar issues
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 error classes PR and converts the 17 page controller files to JavaScript with JSDoc types, in two commits. The first covers the base controllers (
PageController,QuestionPageController,StartPageController,StatusPageController,TerminalPageController),index,validationOptionsandpageControllers/helpers/; the second coversFileUploadPageController,RepeatPageController,SummaryPageControllerand the controller test stubs inpageControllers/__stubs__/. Applications extend these classes for their custom page controllers.@importblock at the end of each file, annotations are now@type,@paramand@returns, and casts are JSDoc casts.pageDefwas narrowed withdeclareonStatusPageController,TerminalPageController,FileUploadPageController,RepeatPageControllerandSummaryPageController. JavaScript has nodeclare, so on each of these classespageDefis now a typed field that takes the value set by the parent constructor,pageDef = this.pageDef, with// @ts-expect-error TS2729: the base constructor has already set it. The published types are the same as withdeclare, andpageDefholds the same object after construction.fileUploadandrepeat, which no parent declares, are plain typed fields without a value and are set by the constructor. These fields were already present in the compiled code.collectionandviewNameinSummaryPageController,viewNameinFileUploadPageController), the value is cast to the inherited type, for example/** @type {QuestionPageController['collection']} */. Without the cast, JavaScript would give the subclass field a different, inferred type.privateandprotectedare now@privateand@protected, and the published types keep the modifiers. Getters keepgetand gain@returns.makePostRouteHandleronPageControllerandTerminalPageControlleronly throws, but declares the return type that subclasses implement. It keeps its@returns, with// eslint-disable-next-line jsdoc/require-returns-checkand the reason.createPagehas@returns {PageControllerClass}, so thattscdoes not write the return type out as a list of seven controller classes.flashedErrorsinQuestionPageControllerhas a type, because in JavaScript an empty array[]would beany[].PageControllerlose their?, soname,id,section,condition,eventsandcollectionbecomeT | undefined. This only affects code that types a plain object as aPageController.allowSaveAndExit,getErrors,getState, some constructors and route handlers),tscleaves it out of the published types. The methods are still available through the parent class.form-context.test.jsnow mockspageControllers/index.js, anddocs/features/code-based/components.mdrefers toSummaryPageController.js.Apart from the five
pageDef = this.pageDeflines, 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).