Repository navigation
fix(components): add missing override modifiers to ErrorBoundary - #2042
Open
liutingqiu wants to merge 1 commit into
Open
liutingqiu wants to merge 1 commit into
liutingqiu wants to merge 1 commit into
Conversation
tsconfig sets noImplicitOverride, but ErrorBoundary overrode the React base class state field, componentDidCatch and render without the modifier, producing three TS4114 errors under the repo's own compiler options. Add the modifiers and cover the component, which had no test file, including the fallback, onError and recovery paths.
|
@liutingqiu is attempting to deploy a commit to the 1nonly's projects Team on Vercel. A member of the Team first needs to authorize it. |
This branch has not been deployed
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.
Context
Follows #1880.
tsconfig.jsonsetsnoImplicitOverride: true, butsrc/components/ErrorBoundary.tsxoverrides three React base-class members without theoverridemodifier. With the repo's own compiler options, that file reports:The three members are the
statefield,componentDidCatch, andrender. This component is used bysrc/app/commitments/[id]/page.tsxto keep the health-metrics and attestation sections independently recoverable, so it is live code rather than a leftover.What changed
src/components/ErrorBoundary.tsx— added the threeoverridemodifiers. No behaviour change;overrideis a compile-time annotation only.src/components/ErrorBoundary.test.tsx(new, 5 tests) — the component had no test file at all. It now covers: children render normally with no panel; a child that throws produces therole="alert"panel and surfaces the thrown message; a caller-suppliedfallbackreplaces the built-in panel;onErrorreceives theErrorand itserrorInfo; and clicking "Try again" leaves the boundary operational rather than throwing out of the tree.How to verify
npm ci npx vitest run src/components/ErrorBoundary.test.tsx # 5 passed npm run format:check npx tsc --noEmitTo reproduce the defect and the fix in isolation (the full-repo
tscrun cannot show it — see the caveat below):Local results on this branch (Windows,
node v24.21.0— not the pinned Node 20 from.nvmrc, so CI on Node 20 is the authoritative run):src/components/ErrorBoundary.test.tsx: 5/5 pass.npx prettier --checkandnpx eslinton both files: clean.npm run test:coverage: the failing-test set is identical to unmodifiedmaster(192 items, no additions, no removals), and the new suite passes.npx tsc --noEmit: 58 errors, the same count as unmodifiedmaster.Caveat on the typecheck signal
You should know why the full-repo error count does not drop by three.
src/lib/backend/env.tsandsrc/components/create/ResumeDraftPrompt.tsxcurrently fail with syntax errors (TS1005/TS1109/TS1382etc.). A parse failure in a file suppresses type checking of the rest of the program, so the whole repo reports 58 errors regardless of this fix — that is also why none of these 58 mentionErrorBoundary. The per-file command above is what demonstrates the change, and the TS4114 errors will disappear from the full run once those parse errors are repaired. Fixing them is outside the scope of this issue.Closes #1880