Skip to content

Conversation

OpenStaxClaude
Copy link
Contributor

@OpenStaxClaude OpenStaxClaude commented Sep 12, 2025

Notes

There are three commits:

  1. Claude did the initial port, and I fixed a few lint issues and such minor things
  2. Wrote tests for the ported code, and made adjustments related to testing issues
  3. Prettier (which marked some files deleted-and-created rather than changed)

Summary

  • Converted all 10 JavaScript files in the errata-form page to TypeScript
  • Added comprehensive type definitions following guidelines:
    • ✅ Avoided using any type
    • ✅ Preferred type to interface
    • ✅ Relied on type inference where possible
    • ✅ Used inline type definitions for function parameters

Files Converted

  • errata-form.jserrata-form.tsx - Main component with Book and SelectOption types
  • errata-form-context.jserrata-form-context.tsx - Context with comprehensive ContextValue type
  • form/form.jsform/form.tsx - Form component with ApiResponse and semester types
  • form/ErrorSourceSelector.jsform/ErrorSourceSelector.tsx - Source selector with BookResource and BookInfo types
  • form/ErrorTypeSelector.jsform/ErrorTypeSelector.tsx - Type selector with proper event typing
  • form/InvalidMessage.jsform/InvalidMessage.tsx - Invalid message utility with strict return types
  • form/FileUploader.jsform/FileUploader.tsx - File upload component with FileButtonProps
  • form/ErrorLocationSelector/ErrorLocationSelector.js.tsx - Location selector with component prop types
  • form/ErrorLocationSelector/toc-selector.js.tsx - TOC selector with TreeEntry and TocContent types
  • form/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

  • Verify errata form loads correctly
  • Test error type selection functionality
  • Test error source selection with different book types
  • Test location selection with TOC navigation
  • Test file upload functionality
  • Test form submission and validation
  • Verify no TypeScript compilation errors

Related to: https://openstax.atlassian.net/browse/CORE-1205

🤖 Generated with Claude Code

@RoyEJohnson RoyEJohnson force-pushed the core-1205-errata-form-typescript branch 2 times, most recently from 168a199 to ea4d520 Compare September 12, 2025 20:28
OpenStaxClaude and others added 3 commits September 17, 2025 11:41
- 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]>
Some adjustments for better accessibility were suggested by testing
@RoyEJohnson RoyEJohnson force-pushed the core-1205-errata-form-typescript branch from 7aa5c6a to 29afc21 Compare September 17, 2025 16:41
return (
<React.Fragment>
<div className="question">Additional location information, if applicable</div>
<label className="question" htmlFor="additional_location_information">
Copy link
Contributor

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

Copy link
Contributor

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.

Copy link
Contributor

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>
Copy link
Contributor

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)

Copy link
Contributor

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 ?? []} />
Copy link
Contributor

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

@RoyEJohnson RoyEJohnson requested a review from jivey September 17, 2025 17:00
@RoyEJohnson RoyEJohnson merged commit 3c80dbf into main Sep 22, 2025
1 check passed
@RoyEJohnson RoyEJohnson deleted the core-1205-errata-form-typescript branch September 22, 2025 18:27
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.

3 participants