Skip to content

8791 ts error cleanup#9802

Merged
jimlerza merged 44 commits intostagingfrom
8791-ts-error-cleanup
Mar 19, 2026
Merged

8791 ts error cleanup#9802
jimlerza merged 44 commits intostagingfrom
8791-ts-error-cleanup

Conversation

@jimlerza
Copy link
Collaborator

@jimlerza jimlerza commented Mar 7, 2026

8791 - TS Error Cleanup: Miscellaneous

#8791

Description

This PR resolves a broad set of strict-mode TypeScript compilation errors across the application. No business logic or UI behavior has been changed — all modifications are limited to satisfying type constraints, fixing linter issues, and improving developer tooling. 133 files were touched across shared/, web-client/, web-api/, cypress/, and scripts/.


Key Changes

Typed Case & Docket Entry Formatting Pipeline (shared/ + web-client/)

The largest portion of this PR introduces explicit TypeScript types for the formatted case and docket entry objects that flow through the application:

  • New types in getFormattedCaseDetail.ts: FormattedCaseDetailDocketEntry, FormattedCaseDetail, FormattedCase, FormattedCounsel, and supporting types (PreformattedCaseDetailDocketEntry, etc.) to explicitly describe the shape of objects returned by the case/docket formatting utilities.
  • New types in formattedDocketEntries.ts: FormattedDocketEntry (extends FormattedCaseDetailDocketEntry with UI-specific fields like iconsToDisplay, sealButtonText, etc.), ComputedFormattedDocketEntry, ComputedFormattedCaseDetail, and RelatedDocketEntry.
  • New types in generateDocketRecordPdfInteractor.ts: DocketRecordPdfCaseDetail for the PDF generation pipeline.
  • Refactored formatting functions to accept and return these explicit types instead of any, including formatCase, formatDocketEntry, formatCaseDetail, sortDocketEntryTable, setupIconsToDisplay, and others.
  • Extracted helper imports: Moved getDescriptionDisplay and getSealedDocketEntryTooltip to direct imports in getFormattedCaseDetail.ts to support the refactored formatting pipeline.
  • Updated DocketRecord.tsx (PDF template): Added explicit React prop types for the DocketRecord component and its sub-components.

Non-Null Assertions & Strict Typing Fixes (web-client/)

  • Applied targeted non-null assertions (!), optional chaining (?.), defaults (|| [], || ''), and explicit casts (as any, as RawCase, etc.) across ~60 web-client files including:
    • Cerebral actions (e.g., removePetitionerCounselFromCaseAction, strikeDocketEntryAction, assignSelectedWorkItemsAction, etc.)
    • Cerebral computeds (e.g., correspondenceViewerHelper, docketEntryQcHelper, draftDocumentViewerHelper, messageModalHelper, sessionAssignmentHelper, etc.)
    • Integration test journeys (e.g., docketClerkSealsDocketEntry, chambersUserAddsOrderToCase, multiple order-type journeys, etc.)

React Component Prop Typings & DOM Interfaces (web-client/)

  • Added explicit React.FC prop type definitions for components: InclusionsForm, NonstandardForm, ObjectionsForm, ElectronicServiceCheckbox, IrsNoticeUploadForm, PartiesInformationContentHeader.
  • Replaced <div role="form"> with semantic <form> element in StartCaseInternal.tsx.
  • Fixed FocusLock.tsx to use properly typed useRef<HTMLDivElement>(null) and HTMLElement casting for DOM references.

Shared Entity & Utility Fixes (shared/)

  • Added non-null assertions in 10 Case.*.test.ts files for strict entity property access (e.g., irsPractitioners!, privatePractitioners!, statistics!, archivedDocketEntries!).
  • Added this: any typing to stream helper in shared/src/tools/helpers.ts.
  • Added explicit parameter typing in assignWorkItemsProxy.ts.
  • Fixed shouldAppendClinicLetter.ts to initialize clinicLetterKey to empty string (and updated test).
  • Made disposition access optional in setDocumentTitleFromStampDataInteractor.ts.
  • Added explicit casting in getPractitionerCasesInteractor.ts for formatCase calls.
  • Fixed type imports in CaseAssociationRequestDocumentTypeB.ts and CaseAssociationRequestDocumentTypeD.ts.
  • Updated setNoticeOfChangeOfTrialJudge.ts to use shared imports and casting.

Web API Adjustments (web-api/)

  • connectLambda.ts: Defaulted connectionId to empty string for strict null satisfaction.
  • genericHandler.ts: Typed caught error as any to access .message property.
  • associatePrivatePractitionerWithCaseInteractor.ts: Added practitioner typing and explicit cast.
  • generateDocketRecordPdfInteractor.ts: Added typed pipeline with DocketRecordPdfCaseDetail and updated formatting logic (including new unit tests).

Developer Tooling

  • eslint.config.mjs: Added settings.react.version: 'detect' to the flat ESLint config to resolve React version warning logs during linting.
  • scripts/compareTypescriptErrors.ts:
    • Fixed countTypescriptErrors to return 0 instead of throwing when no errors are found (supports the goal of reaching zero TS errors).
    • Added validateTscResult() helper to properly diagnose tsc process failures (error, signal, exit code with no output).

Testing

  • All modified unit tests updated to work with the new explicit types (updated imports, casts, and assertions).
  • New unit tests added for generateDocketRecordPdfInteractor covering the typed formatting pipeline.
  • No business logic changes — all existing test assertions for behavior remain unchanged.

What This PR Does NOT Change

  • No UI behavior or visual changes
  • No business logic modifications
  • No API contract changes
  • No database or persistence changes

Oh Yeah Also

Screenshot 2026-03-18 at 10 55 54 AM

@jimlerza jimlerza marked this pull request as ready for review March 7, 2026 08:09
Copilot AI review requested due to automatic review settings March 7, 2026 08:09
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR focuses on resolving strict-mode TypeScript compilation issues across the web client, shared, and web-api layers by tightening/adjusting types, adding explicit casts/assertions, and updating a few call signatures/configs.

Changes:

  • Updated multiple React views/components and Cerebral computeds/actions to satisfy strict null checks and stricter typings.
  • Refactored docket entry formatting typings (introducing FormattedDocketEntry and FormattedCaseDetailDocketEntry) and updated related tests accordingly.
  • Adjusted several server/lambda handlers and shared utilities to align with library/type expectations, plus updated ESLint flat config React version detection.

Reviewed changes

Copilot reviewed 80 out of 80 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
web-client/src/views/StartCaseUpdated/IrsNoticeUploadForm.tsx Type adjustments for FormGroup errorText and file input props
web-client/src/views/StartCaseInternal/StartCaseInternal.tsx Replaced div role="form" with semantic <form> element
web-client/src/views/StartCaseInternal/ElectronicServiceCheckbox.tsx Added explicit prop/deps typing for Cerebral connect
web-client/src/views/FileDocument/ObjectionsForm.tsx Added explicit React.FC prop typing wrapper
web-client/src/views/FileDocument/NonstandardForm.tsx Added optional showIndex prop typing and defaulting
web-client/src/views/FileDocument/InclusionsForm.tsx Added explicit React.FC prop typing wrapper
web-client/src/views/CaseDetail/PartiesInformationContentHeader.tsx Type tightening for connected props/sequences
web-client/src/ustc-ui/FocusLock/FocusLock.tsx Added stricter DOM/ref typings and non-null assertions
web-client/src/presenter/computeds/sessionAssignmentHelper.ts Added RawUser import/cast for “Other” option
web-client/src/presenter/computeds/scanBatchPreviewerHelper.ts Non-null assertions for selected batch access
web-client/src/presenter/computeds/formattedDocketEntries.ts Added/expanded formatted docket entry types and refactored formatting logic
web-client/src/presenter/computeds/formattedDocketEntries.test.ts Updated tests to use new FormattedDocketEntry typing
web-client/src/presenter/computeds/formattedDocketEntries.getShowSealDocketRecordEntry.test.ts Updated imports/typing for refactored helper signature
web-client/src/presenter/computeds/formattedDocketEntries.getShowEditDocketRecordEntry.test.ts Updated tests to match refactored helper signature and typings
web-client/src/presenter/computeds/formattedDocketEntries.getFormattedDocketEntry.test.ts Updated tests with explicit Get typing and new return typing expectations
web-client/src/presenter/computeds/documentSigningHelper.ts Non-null assertion for pdfjs object access
web-client/src/presenter/computeds/docketEntryQcHelper.ts Cast current document into expected raw docket entry type
web-client/src/presenter/computeds/correspondenceViewerHelper.ts Non-null assertion for viewer correspondence state
web-client/src/presenter/computeds/Public/publicCaseDetailHelper.test.ts Cast formatted docket entry input to RawDocketEntry for strict typing
web-client/src/presenter/actions/unsetNegativeValueConfirmationTextAction.ts Non-null assertion for confirmationText state indexing
web-client/src/presenter/actions/unsetNegativeValueConfirmationTextAction.test.ts Updated test to align with non-null assertion
web-client/src/presenter/actions/setUserAction.test.ts Updated global window delete to satisfy TS delete constraints
web-client/src/presenter/actions/setNegativeValueConfirmationTextAction.ts Non-null assertion for confirmationText state indexing
web-client/src/presenter/actions/setNegativeValueConfirmationTextAction.test.ts Updated test to align with non-null assertion
web-client/src/presenter/actions/saveAndSubmitCaseAction.ts Cast petition metadata to expected case type
web-client/src/presenter/actions/openPractitionerDocumentDownloadUrlAction.ts Typed caught error as any to access .message
web-client/src/presenter/actions/openCaseDocumentDownloadUrlAction.ts Typed caught error as any to access .message
web-client/src/presenter/actions/isRespondentInCaseAction.ts Non-null assertion for irsPractitioners array access
web-client/src/presenter/actions/isPractitionerInCaseAction.ts Non-null assertion for privatePractitioners array access
web-client/src/presenter/actions/assignSelectedWorkItemsAction.ts Defaulted assigneeId to empty string for typing
web-client/src/presenter/actions/TrialSessionWorkingCopy/setAddEditUserCaseNoteModalStateFromListAction.ts Non-null assertion for caseDetail.caseCaption
web-client/src/presenter/actions/TrialSessionWorkingCopy/generatePrintableTrialSessionCopyReportAction.test.ts Non-null assertion for judge name access in fixtures
web-client/src/presenter/actions/TrialSession/setQcCompleteOnCaseOnTrialSessionAction.ts Non-null assertion for eligible case update
web-client/src/presenter/actions/PendingItems/setupPropsForPrintablePendingReportAction.test.ts Made generic prop type optional to satisfy strictness
web-client/src/presenter/actions/EditDocketRecordEntry/strikeDocketEntryAction.ts Typed caught error as any to access .message
web-client/src/presenter/actions/DocketEntry/suggestSaveForLaterValidationAction.test.ts Non-null assertion for action output access
web-client/src/presenter/actions/CourtIssuedOrder/updateCreateOrderModalFormValueAction.ts Non-null assertions for order type map lookup
web-client/src/presenter/actions/CourtIssuedDocketEntry/clearCourtIssuedDocketEntryFormValuesAction.ts Non-null assertion for event code lookup
web-client/src/presenter/actions/CaseAssociation/validateEditRespondentCounselAction.ts Non-null assertion for counsel array access
web-client/src/presenter/actions/CaseAssociation/validateEditPetitionerCounselAction.ts Non-null assertion for practitioner array access
web-client/src/presenter/actions/CaseAssociation/setRespondentCounselFormAction.ts Non-null assertion for practitioner lookup
web-client/src/presenter/actions/CaseAssociation/setPetitionerCounselFormAction.ts Non-null assertion for practitioner lookup
web-client/src/presenter/actions/CaseAssociation/removeRespondentCounselFromCaseAction.ts Non-null assertion for practitioner lookup
web-client/src/presenter/actions/CaseAssociation/removePetitionerCounselFromCaseAction.ts Non-null assertion for practitioner lookup
web-client/integration-tests/permissions.test.ts Cast global.window for stricter spread typing
web-client/integration-tests/orderSearchJourneyDocketNumber.test.ts Cast global.window for stricter spread typing
web-client/integration-tests/journey/petitionsClerkCreateOrder.ts Cast first(draftDocuments) to raw docket entry for typing
web-client/integration-tests/journey/judgeViewsTrialSessionWorkingCopy.ts Non-null assertion for found case access
web-client/integration-tests/journey/docketClerkViewsNewTrialSession.ts Non-null assertion for found case access
web-client/integration-tests/journey/docketClerkUpdatesCaseStatusTo.ts Cast compute output to any to satisfy typing
web-client/integration-tests/caseJourney.test.ts Cast global.window for stricter spread typing
web-client/integration-tests-public/journey/unauthedUserSeesStrickenDocketEntry.ts Non-null assertions for found docket entry access
web-api/src/lambdas/notifications/connectLambda.ts Defaulted client connection id to empty string
web-api/src/lambdas/api/api.ts Updated serverless-express invocation to include callback
web-api/src/lambdas/api-public/api-public.ts Simplified handler export to direct serverless-express handler
web-api/src/genericHandler.ts Typed caught error as any to access properties
web-api/src/business/useCases/manualAssociation/associatePrivatePractitionerWithCaseInteractor.ts Added practitioner typing and explicit missing-user error
web-api/src/business/useCaseHelper/trialSessions/setNoticeOfChangeOfTrialJudge.ts Switched to shared imports and cast trial session info type
shared/src/tools/helpers.ts Added this: any typing for stream-like callback usage
shared/src/proxies/workitems/assignWorkItemsProxy.ts Added explicit parameter typing for assign work items proxy
shared/src/business/utilities/shouldAppendClinicLetter.ts Initialized clinicLetterKey to satisfy definite assignment
shared/src/business/utilities/shouldAppendClinicLetter.test.ts Updated expectation to match new default value
shared/src/business/utilities/pdfGenerator/documentTemplates/DocketRecord.tsx Added explicit React prop typing and docket entry typing
shared/src/business/utilities/getFormattedCaseDetail.ts Added FormattedCaseDetailDocketEntry type and refactored formatDocketEntry return typing
shared/src/business/utilities/getFormattedCaseDetail.formatDocketEntry.test.ts Updated test app context import and strict typing casts
shared/src/business/useCases/stampMotion/setDocumentTitleFromStampDataInteractor.ts Made disposition access optional for strict typing
shared/src/business/entities/cases/Case.updateStatistic.test.ts Non-null assertions to satisfy strict array access
shared/src/business/entities/cases/Case.updatePrivatePractitioner.test.ts Non-null assertions to satisfy strict array access
shared/src/business/entities/cases/Case.updateIrsPractitioner.test.ts Non-null assertions to satisfy strict array access
shared/src/business/entities/cases/Case.removeRepresentingFromPractitioners.test.ts Non-null assertions to satisfy strict array access
shared/src/business/entities/cases/Case.removePrivatePractitioner.test.ts Non-null assertions to satisfy strict array access
shared/src/business/entities/cases/Case.removeIrsPractitioner.test.ts Non-null assertions to satisfy strict array access
shared/src/business/entities/cases/Case.getSortableDocketNumber.test.ts Non-null assertions for numeric sort comparator
shared/src/business/entities/cases/Case.deleteStatistic.test.ts Non-null assertions to satisfy strict array access
shared/src/business/entities/cases/Case.attachPrivatePractitioner.test.ts Non-null assertions to satisfy strict array access
shared/src/business/entities/cases/Case.attachIrsPractitioner.test.ts Non-null assertion to satisfy strict array access
shared/src/business/entities/cases/Case.archiveDocketEntry.test.ts Optional chaining added to satisfy strictness in tests
shared/src/business/entities/caseAssociation/CaseAssociationRequestDocumentTypeD.ts Defaulted mapped names array to [] when filers undefined
shared/src/business/entities/caseAssociation/CaseAssociationRequestDocumentTypeB.ts Defaulted mapped names array to [] when filers undefined
eslint.config.mjs Added React version auto-detection setting

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

jimlerza and others added 3 commits March 7, 2026 03:17
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@jimlerza
Copy link
Collaborator Author

@copilot Please re-review this PR, thoroughly scrutinizing the claims in the What This PR Does NOT Change section of the PR's description:

  • No UI behavior or visual changes
  • No business logic modifications
  • No API contract changes
  • No database or persistence changes

Why do you think the blocked-cases and case-deadline-on-a-consolidated-group tests needed to change if there were no business logic or UI changes?

Copilot AI mentioned this pull request Mar 18, 2026
Copy link
Contributor

Copilot AI commented Mar 18, 2026

@jimlerza I've opened a new pull request, #9822, to work on those changes. Once the pull request is ready, I'll request review from you.

@jimlerza
Copy link
Collaborator Author

jimlerza commented Mar 18, 2026

For anyone following along, copilot answered my question here:

https://github.com/copilot/tasks/pull/PR_kwDOCN772M7Lktfy?session_id=5a9337b1-8689-4f82-a9d7-3916e33ca526

@jimlerza jimlerza merged commit 4d3c4f9 into staging Mar 19, 2026
47 checks passed
@jimlerza jimlerza deleted the 8791-ts-error-cleanup branch March 19, 2026 16:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants