[APP-917] Automated typescript check - #3540
Conversation
…toHaveBeenLastCalledWith
# 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
| onBlur={onBlur} | ||
| onChange={onChange} | ||
| value={value} | ||
| value={value ?? undefined} |
There was a problem hiding this comment.
(nit, b): using undefined as the default here could cause the input to go from uncontrolled to controlled. Is null viable instead?
There was a problem hiding this comment.
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} |
There was a problem hiding this comment.
(nit, b): save controlled<->uncontrolled issue
| { | ||
| "compilerOptions": { | ||
| /* base vite config */ | ||
| "allowJs": true, |
There was a problem hiding this comment.
(q, nb): where do we have js in src? any way we could not?
There was a problem hiding this comment.
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
There was a problem hiding this comment.
heads up that I just deleted reportWebVitals.js, so once you merge in main, that should also go away
| "*": ["./src/*"] | ||
| } | ||
| }, | ||
| "types": ["vite/client", "node"] |
There was a problem hiding this comment.
(q, b): this code won't run in a node environment - why do we need to include node in the types?
|
|
||
| /* nbs additions */ | ||
| "plugins": [{ "name": "typescript-plugin-css-modules" }], | ||
| "ignoreDeprecations": "6.0", |
There was a problem hiding this comment.
(q, nb): what sort of things is this ignoring? should we create a follow on ticket to deal with them?
There was a problem hiding this comment.
I'm not sure. I removed it.
| "target": "ES2020", | ||
| "useDefineForClassFields": true, | ||
| "lib": ["ES2020", "DOM", "DOM.Iterable"], | ||
| "lib": ["ES2023", "DOM", "DOM.Iterable"], |
There was a problem hiding this comment.
(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?
There was a problem hiding this comment.
This was an interesting topic to investigate. In the end I included @vitejs/plugin-legacy to add in the polyfills then terser to minimize
There was a problem hiding this comment.
do we need the terser? looks like vite auto-minifies using oxc
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
# Conflicts: # apps/modernization-ui/src/index.tsx
|
|
||
| const asTableRow = (condition: Condition): TableBody => ({ | ||
| id: condition.id, | ||
| type ConditionTableBody = TableBody & { id: number }; |
There was a problem hiding this comment.
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 🙏
| const handleAddConditions = (conditions: number[]) => { | ||
| const handleAddConditions = (conditions: string[]) => { | ||
| const newConditions = conditions | ||
| .map((id) => String(id)) |
There was a problem hiding this comment.
(nit): shouldn't need this map anymore
| .map((id) => String(id)) |
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 UIworkflow to ensure type safety across the development lifecycle.To run type checking:
npm run typecheckTickets
Checklist before requesting a review