Part 1: Fix Typescript errors (issue #508)#513
Merged
Conversation
jmankoff
approved these changes
Jul 18, 2026
jmankoff
left a comment
Contributor
There was a problem hiding this comment.
Cleanup is the work people usually like least! Thanks for taking a hit for the team and doing this :) :).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 toCollectionEntry[]— the.filtertype predicate on line 68 is rejected by newer TypeScript strict predicate checking (TS2677). Fix: change predicate toentry is NonNullable<typeof entry>.src/lib/api.ts(1 error) — Line 1971:Record<string, unknown>[]not assignable toCollectionEntry[]— theupdateCollectionentries override type needs widening to accept wire-format payloads.src/components/ProductSubmission.tsx(5 errors: lines 274, 526, 536, 558, 562) —string | undefinedpassed wherestringis 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.usernamepossibly undefined — add?? ''guard.src/components/ProductEditors.tsx(1 error: line 143) —string | undefinednot assignable tostring.src/components/RavelryOAuthDiagnostics.tsx(2 errors: lines 386, 406) —string | undefinedpassed wherestringrequired — add?? ''or narrow.src/__tests__/integration/submission-edit-flow.test.tsx(10 errors) —ownerAuthandmoderatorAuthdeclared as nullable; add!assertions or narrow with a guard before use.src/__tests__/integration/submission-existing-product.test.tsx(3 errors) — same pattern withauthUser.src/__tests__/lib/user-stats.test.ts(8 errors) —resultpossibly null; add null check before assertions.src/__tests__/components/UserProfile.integration.test.tsx(1 error: line 82) —string | undefinednot assignable tostring.src/__tests__/components/ProductListItem.integration.test.tsx(1 error: line 50) andsrc/__tests__/components/ProductUpdated.integration.test.tsx(1 error: line 66) — both passonClickprop which was removed fromProductListItemProps. 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:103—DEV_USERS.user.roleis inferred as a literal type"regular_user"; cast tostringwhere a wider type is expected.src/__tests__/integration/user-workflows.test.tsx:388,414—ProductEditorsprops shape mismatch;userAccountisUserAccount | undefinedbut component requiresUserAccount.src/__tests__/components/ProductUrls.test.tsx:30—numberpassed wherestringexpected.src/__tests__/pages/ProductDetailPage.test.tsx:37— same.src/__tests__/accessibility/SearchBox.a11y.test.tsx:217—delayremoved from@testing-library/user-eventtypeOptionsin a recent version. Remove the option or update to the new API (userEvent.setup({ delay: null })).src/__tests__/lib/api.upload-image.test.ts:183—instanceofused on a value typed asunknown; narrow to object first.src/__tests__/lib/scraper.test.ts:68—rawisunknown; add type assertion or narrowing.src/__tests__/setup.ts:18— unused@ts-expect-errordirective; 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
Validation
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:.
All tests pass when running
npm test, but just want to make sure this is okay!