-
Notifications
You must be signed in to change notification settings - Fork 6
Port errata-form page JavaScript files to TypeScript (CORE-1205) #2774
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
Conversation
168a199
to
ea4d520
Compare
- Added comprehensive type definitions for all components - Converted 10 JavaScript files to TypeScript (.js -> .tsx/.ts) - Added proper typing for React components, hooks, and event handlers - Used inline type definitions and avoided 'any' type per guidelines - Maintained existing functionality while improving type safety Files converted: - errata-form.js -> errata-form.tsx - errata-form-context.js -> errata-form-context.tsx - form/form.js -> form/form.tsx - form/ErrorSourceSelector.js -> form/ErrorSourceSelector.tsx - form/ErrorTypeSelector.js -> form/ErrorTypeSelector.tsx - form/InvalidMessage.js -> form/InvalidMessage.tsx - form/FileUploader.js -> form/FileUploader.tsx - form/ErrorLocationSelector/*.js -> form/ErrorLocationSelector/*.tsx 🤖 Generated with [Claude Code](https://claude.ai/code) Lint issues selectedBook can be null Co-Authored-By: Claude <[email protected]>
7aa5c6a
to
29afc21
Compare
return ( | ||
<React.Fragment> | ||
<div className="question">Additional location information, if applicable</div> | ||
<label className="question" htmlFor="additional_location_information"> |
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.
Accessibility change: made this a label with a for
connection to the input
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.
Easier to see the changes in the individual commits.
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.
Easier to see changes in the individual commits
return ( | ||
<React.Fragment> | ||
<div className="question">Where in the book did you find the error?</div> | ||
<label className="question" htmlFor="toc-selector">Where in the book did you find the error?</label> |
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.
Accessibility issue (that also makes testing easier)
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.
Again, easier to see the changes in the individual commits
}} | ||
onValueUpdate={setTitle} | ||
label="What book were you in, again?" options={assertDefined(options)} /> | ||
label="What book were you in, again?" options={options ?? []} /> |
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.
Turned out it's not always defined
Notes
There are three commits:
Summary
any
typetype
tointerface
Files Converted
errata-form.js
→errata-form.tsx
- Main component with Book and SelectOption typeserrata-form-context.js
→errata-form-context.tsx
- Context with comprehensive ContextValue typeform/form.js
→form/form.tsx
- Form component with ApiResponse and semester typesform/ErrorSourceSelector.js
→form/ErrorSourceSelector.tsx
- Source selector with BookResource and BookInfo typesform/ErrorTypeSelector.js
→form/ErrorTypeSelector.tsx
- Type selector with proper event typingform/InvalidMessage.js
→form/InvalidMessage.tsx
- Invalid message utility with strict return typesform/FileUploader.js
→form/FileUploader.tsx
- File upload component with FileButtonPropsform/ErrorLocationSelector/ErrorLocationSelector.js
→.tsx
- Location selector with component prop typesform/ErrorLocationSelector/toc-selector.js
→.tsx
- TOC selector with TreeEntry and TocContent typesform/ErrorLocationSelector/test-data.js
→.ts
- Test data file (simple rename)Technical Details
All components maintain existing functionality while adding comprehensive type safety. TypeScript definitions include proper React component types, event handlers, hook return types, and API response structures.
Test Plan
Related to: https://openstax.atlassian.net/browse/CORE-1205
🤖 Generated with Claude Code