Skip to content

Part 1: Fix Typescript errors (issue #508)#513

Merged
jmankoff merged 21 commits into
mainfrom
fix-Typescript-errors
Jul 18, 2026
Merged

Part 1: Fix Typescript errors (issue #508)#513
jmankoff merged 21 commits into
mainfrom
fix-Typescript-errors

Conversation

@agarg09

@agarg09 agarg09 commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Summary

Worked on resolving issue #508, specifically all the Typescript issues in type mismatch, null or empty cases, etc., as mentioned in-depth in the issue (and also when running npx tsc). Specifically (wordings taken exactly from the issue):

  • src/lib/addToCollection.ts (2 errors) — Line 52: ({ … } | null)[] not assignable to CollectionEntry[] — the .filter type predicate on line 68 is rejected by newer TypeScript strict predicate checking (TS2677). Fix: change predicate to entry is NonNullable<typeof entry>.

  • src/lib/api.ts (1 error) — Line 1971: Record<string, unknown>[] not assignable to CollectionEntry[] — the updateCollection entries override type needs widening to accept wire-format payloads.

  • src/components/ProductSubmission.tsx (5 errors: lines 274, 526, 536, 558, 562) — string | undefined passed where string is required. Each is a potentially undefined field (e.g. product.slug) being passed to a function that doesn't accept undefined. Add ?? '' or narrow upstream.

  • src/components/AdminDashboard.tsx (1 error: line 169) — { id: string; username: string | undefined } not assignable to { id: string; username: string } — add ?? '' or update the consuming type.

  • src/components/AdminUsersStats.tsx (1 error: line 400) — user.username possibly undefined — add ?? '' guard.

  • src/components/ProductEditors.tsx (1 error: line 143) — string | undefined not assignable to string.

  • src/components/RavelryOAuthDiagnostics.tsx (2 errors: lines 386, 406) — string | undefined passed where string required — add ?? '' or narrow.

  • src/__tests__/integration/submission-edit-flow.test.tsx (10 errors) — ownerAuth and moderatorAuth declared as nullable; add ! assertions or narrow with a guard before use.

  • src/__tests__/integration/submission-existing-product.test.tsx (3 errors) — same pattern with authUser.

  • src/__tests__/lib/user-stats.test.ts (8 errors) — result possibly null; add null check before assertions.

  • src/__tests__/components/UserProfile.integration.test.tsx (1 error: line 82) — string | undefined not assignable to string.

  • src/__tests__/components/ProductListItem.integration.test.tsx (1 error: line 50) and src/__tests__/components/ProductUpdated.integration.test.tsx (1 error: line 66) — both pass onClick prop which was removed from ProductListItemProps. Remove the prop from both test renders.

  • src/__tests__/components/ProductListPage.banned.test.tsx (1 error: line 73) — prop type mismatch; likely a recently added or removed prop on the page component.

  • src/__tests__/integration/user-workflows.test.tsx:103DEV_USERS.user.role is inferred as a literal type "regular_user"; cast to string where a wider type is expected.

  • src/__tests__/integration/user-workflows.test.tsx:388,414ProductEditors props shape mismatch; userAccount is UserAccount | undefined but component requires UserAccount.

  • src/__tests__/components/ProductUrls.test.tsx:30number passed where string expected.

  • src/__tests__/pages/ProductDetailPage.test.tsx:37 — same.

  • src/__tests__/accessibility/SearchBox.a11y.test.tsx:217delay removed from @testing-library/user-event typeOptions in a recent version. Remove the option or update to the new API (userEvent.setup({ delay: null })).

  • src/__tests__/lib/api.upload-image.test.ts:183instanceof used on a value typed as unknown; narrow to object first.

  • src/__tests__/lib/scraper.test.ts:68raw is unknown; add type assertion or narrowing.

  • src/__tests__/setup.ts:18 — unused @ts-expect-error directive; remove it.

This resolves the 65 Typescript issues to 21 Typescript issues. The remaining 21 Typescript issues will be put together in a second PR (easier for code reviews).

Type of Change

  • Bug fix
  • New feature
  • Refactor
  • Documentation update
  • Test update
  • CI/workflow update

Validation

  • Tests added or updated where relevant
  • Local tests run for changed behavior
  • Lint passes

Notes for Reviewers

There were some places where I had to change the variable name since it seemed that it had been renamed to something else, specifically:.

  • ProductListPage.banned.test.tsx:73 — renamed the prop onOpenCreateCollection → onOpenAddToCollection to match the component's actual prop name.
  • user-workflows.test.tsx:388 and :414 — renamed the prop userId={testUserId} → username={testUsername} on both render calls, since ProductEditorsProps doesn't have a userId field at all — it expects username.

All tests pass when running npm test, but just want to make sure this is okay!

@agarg09 agarg09 added the run-full-backend Trigger the required check to run the full backend. label Jul 17, 2026
@agarg09
agarg09 requested a review from jmankoff July 17, 2026 20:18

@jmankoff jmankoff 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.

Cleanup is the work people usually like least! Thanks for taking a hit for the team and doing this :) :).

@jmankoff
jmankoff merged commit 4b2cd88 into main Jul 18, 2026
4 of 5 checks passed
@jmankoff
jmankoff deleted the fix-Typescript-errors branch July 18, 2026 03:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

run-full-backend Trigger the required check to run the full backend.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants