Skip to content

[APP-917] Automated typescript check - #3540

Merged
brick-green merged 60 commits into
mainfrom
bg/app-917/automated-typescript-check
Aug 11, 2026
Merged

[APP-917] Automated typescript check#3540
brick-green merged 60 commits into
mainfrom
bg/app-917/automated-typescript-check

Conversation

@brick-green

@brick-green brick-green commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Description

This PR addresses several existing TypeScript errors across component, test, and configuration files. In addition, it establishes a dedicated type-checking step in the Verify Modernization UI workflow to ensure type safety across the development lifecycle.

To run type checking: npm run typecheck

Tickets

Checklist before requesting a review

  • PR focuses on a single story
  • Code has been fully tested to meet acceptance criteria
  • PR is reasonably small and reviewable (Generally less than 10 files and 500 changed lines)
  • All new functions/classes/components reasonably small
  • Functions/classes/components focused on one responsibility
  • Code easy to understand and modify (clarity over concise/clever)
  • PRs containing TypeScript follow the Do's and Don'ts
  • PR does not contain hardcoded values (Uses constants)
  • All code is covered by unit or feature tests

# Conflicts:
#	apps/modernization-ui/src/apps/deduplication/patient-merge/details/merge-preview/components/administrative-comments/AdministrativeComments.tsx
#	apps/modernization-ui/src/apps/deduplication/patient-merge/details/merge-preview/components/ethnicity/PreviewEthnicity.tsx
#	apps/modernization-ui/src/apps/deduplication/patient-merge/details/merge-preview/components/mortality/PreviewMortality.tsx
#	apps/modernization-ui/src/apps/deduplication/patient-merge/details/merge-preview/components/sex-and-birth/PreviewSexAndBirth.tsx
#	apps/modernization-ui/src/apps/page-builder/components/DeleteQuestion/DeleteQuestion.tsx
#	apps/modernization-ui/src/apps/page-builder/components/SaveTemplate/SaveTemplate.spec.tsx
#	apps/modernization-ui/src/apps/page-builder/page/management/edit/tabs/AddEditTab/AddEditTab.spec.tsx
#	apps/modernization-ui/src/apps/report/run/filters/advanced/validator.spec.ts
#	apps/modernization-ui/src/components/MediaBlockBody/MediaBlockBody.tsx
#	apps/modernization-ui/src/components/TabNavigation/TabNavigation.stories.tsx
#	apps/modernization-ui/src/components/TopBanner/Banner/banner.tsx
#	apps/modernization-ui/src/components/TopBanner/BannerButton/BannerButton.tsx
#	apps/modernization-ui/src/components/TopBanner/BannerContent/BannerContent.tsx
#	apps/modernization-ui/src/components/TopBanner/BannerFlag/BannerFlag.tsx
#	apps/modernization-ui/src/components/TopBanner/BannerGuidance/BannerGuidance.tsx
#	apps/modernization-ui/src/components/TopBanner/BannerHeader/BannerHeader.tsx
#	apps/modernization-ui/src/components/TopBanner/BannerIcon/BannerIcon.tsx
#	apps/modernization-ui/src/components/TopBanner/TopBanner.tsx
#	apps/modernization-ui/src/design-system/card/section/Section.stories.tsx
Comment thread apps/modernization-ui/tsconfig.app.json Outdated
Comment thread apps/modernization-ui/tsconfig.app.json Outdated
onBlur={onBlur}
onChange={onChange}
value={value}
value={value ?? undefined}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

(nit, b): using undefined as the default here could cause the input to go from uncontrolled to controlled. Is null viable instead?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I checked NumericInput types, and its value prop was typed as value?: number (it doesn't accept null). So I updated NumericInput to accept number | null.

id={name}
name={name}
value={value}
value={value ?? undefined}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

(nit, b): save controlled<->uncontrolled issue

Comment thread apps/modernization-ui/tsconfig.app.json Outdated
{
"compilerOptions": {
/* base vite config */
"allowJs": true,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

(q, nb): where do we have js in src? any way we could not?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Just checked again and it was only reportWebVitals.js called in index.tsx. But the output wasn't even logged anywhere so I commented out the line in index and removed the option in tsconfig

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

heads up that I just deleted reportWebVitals.js, so once you merge in main, that should also go away

Comment thread apps/modernization-ui/tsconfig.app.json Outdated
"*": ["./src/*"]
}
},
"types": ["vite/client", "node"]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

(q, b): this code won't run in a node environment - why do we need to include node in the types?

Comment thread apps/modernization-ui/tsconfig.app.json Outdated

/* nbs additions */
"plugins": [{ "name": "typescript-plugin-css-modules" }],
"ignoreDeprecations": "6.0",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

(q, nb): what sort of things is this ignoring? should we create a follow on ticket to deal with them?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I'm not sure. I removed it.

"target": "ES2020",
"useDefineForClassFields": true,
"lib": ["ES2020", "DOM", "DOM.Iterable"],
"lib": ["ES2023", "DOM", "DOM.Iterable"],

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

(q, b): reading https://stackoverflow.com/questions/42093758/need-clarification-of-the-target-and-lib-compiler-options it seems like the lib appeases typescript, but doesn't guarantee polyfills are available for things that are in 2023, but not in our target of 2020 - do we know if vite or something else includes those polyfills for us? or is it safer to leave this at 2020?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This was an interesting topic to investigate. In the end I included @vitejs/plugin-legacy to add in the polyfills then terser to minimize

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

do we need the terser? looks like vite auto-minifies using oxc

https://vite.dev/config/build-options#build-minify

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

ah, I see it's not in the version of vite we have right now

https://vite.dev/config/build-options#build-minify

do we need to set it as a build option for minification? maybe with a comment as to why and that we can probably remove once we update vite?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

hmm I don't think we need a separate minifier. Looks like to me that the default for vite version 8+ is oxc and we're on "vite": "^8.0.16". So I'll remove terser.


const asTableRow = (condition: Condition): TableBody => ({
id: condition.id,
type ConditionTableBody = TableBody & { id: number };

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I lead you astray here, condition's id is absolutely a string (and not always a number at all (e.g. DE-41665 is in our db) - we should have this be string and make sure the usage matches all that - apologies 🙏

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done :)

const handleAddConditions = (conditions: number[]) => {
const handleAddConditions = (conditions: string[]) => {
const newConditions = conditions
.map((id) => String(id))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

(nit): shouldn't need this map anymore

Suggested change
.map((id) => String(id))

@mcmcgrath13 mcmcgrath13 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🧹

@brick-green
brick-green merged commit 9488177 into main Aug 11, 2026
2 checks passed
@brick-green
brick-green deleted the bg/app-917/automated-typescript-check branch August 11, 2026 20:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants