-
Notifications
You must be signed in to change notification settings - Fork 5
CORE-1206: Port errata-summary page to TypeScript #2772
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CORE-1206: Port errata-summary page to TypeScript #2772
Conversation
0698ec6 to
a32acdc
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks alright but there are some typescript error suppressions for the sort function that I'm not sure about. Would using generics help?
a32acdc to
fbec7ed
Compare
| setSortFn(colSpec.sortFn); | ||
| setSortKey(colSpec.id); | ||
| setSortDir(1); | ||
| const sortAttributes = React.useMemo(() => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I changed this to only have onClick defined when sortable was set, which makes sense.
| // @ts-expect-error sortKey is guaranteed compatible with sortFn | ||
| sortFunctions[sortFn](a[sortKey], b[sortKey]) | ||
| const sortedData = [...data].sort((a, b) => | ||
| sortFunctions[sortFn](a[sortKey] as DisplayStatusValue, b[sortKey] as DisplayStatusValue) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These casts address TypeScript's complaints but honestly don't make a lot of sense to me. I don't see a way to use generics to fix it. TS considers the function parameters to necessarily be typed as DisplayStatusValue.
| const [sortFn, setSortFn] = useState<keyof typeof sortFunctions>('sortDate'); | ||
| const [sortKey, setSortKey] = useState<keyof ProcessedErrataItem>('date'); | ||
| const [sortDir, setSortDir] = useState<number>(-1); | ||
| const sortFunction = sortFunctions[sortFn]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved more of the higher functionality here to centralize and abstract it.
Convert JavaScript modules to TypeScript (.js to .tsx): - errata-summary.js → errata-summary.tsx - hero/hero.js → hero/hero.tsx - table/table.js → table/table.tsx Added comprehensive TypeScript interfaces and type annotations: - Props interfaces for all React components - State type definitions for hooks - Detailed interfaces for errata data structures - Type-safe sort functions and controllers - Proper return type annotations 🤖 Generated with [Claude Code](https://claude.ai/code) Refine TypeScript implementation per code review feedback - Replace all 'any' types with specific type unions - Convert all interface definitions to type definitions - Fix line lengths to be ≤120 characters - Improve type safety for sort functions and errata data 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
f1f28f3 to
e69aefa
Compare
Summary
This PR ports all JavaScript modules in the errata-summary page directory to TypeScript, changing file extensions from
.jsto.tsxand adding comprehensive type definitions.Files Converted
✅ Main Files Ported
src/app/pages/errata-summary/errata-summary.js→errata-summary.tsxsrc/app/pages/errata-summary/hero/hero.js→hero/hero.tsxsrc/app/pages/errata-summary/table/table.js→table/table.tsxTypeScript Improvements Added
🔧 Type Safety Enhancements
errata-summary.tsx:
RadioIteminterface for radio button configurationErrataDatainterface for data structureErrataSummaryPropsinterface for component propshero.tsx:
BookEntry,HeroData,HeroProps,HeroContentPropsPopTipProps,PopTipState,PopTipStyleResultinterfacesuseBookInfo,usePopTipStyle,usePopTipState)table.tsx:
ColumnSpecinterface for table column configurationRawErrataItemandProcessedErrataIteminterfaces for data transformationSortControllerinterface for sort functionality🚀 Benefits
Technical Details
Testing
The TypeScript compiler will validate all type annotations and catch potential issues. The dynamic import system (
ImportedPagecomponent) automatically resolves.tsxextensions.🤖 Generated with Claude Code