fix(router-core): model error component props as unknown#7868
fix(router-core): model error component props as unknown#7868leesb971204 wants to merge 1 commit into
Conversation
Signed-off-by: leesb971204 <leesb971204@gmail.com>
📝 WalkthroughWalkthroughThe public ChangesUnknown error component contract
Estimated code review effort: 3 (Moderate) | ~20 minutes Possibly related PRs
Suggested labels: Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@packages/vue-router/src/CatchBoundary.tsx`:
- Line 108: Update the error fallback in CatchBoundary to render
String(props.error) so thrown strings and numbers retain their messages, and
change the error prop declaration from null to unknown to preserve the correct
prop type.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 26e887ec-6a28-4ea4-ba22-076d074647e5
📒 Files selected for processing (27)
.changeset/error-component-props-unknown.mddocs/router/api/router/errorComponentComponent.mddocs/router/guide/data-loading.mddocs/router/guide/external-data-loading.mddocs/router/how-to/setup-testing.mddocs/router/how-to/use-environment-variables.mddocs/router/how-to/validate-search-params.mddocs/start/framework/react/guide/server-components.mdpackages/react-router/src/Match.tsxpackages/react-router/tests/errorComponent.test-d.tsxpackages/react-router/tests/errorComponent.test.tsxpackages/react-router/tests/issue-7638-invalidate-transition-error.test.tsxpackages/react-router/tests/lazy/error.tsxpackages/react-router/tests/loaders.test.tsxpackages/react-router/tests/router.test.tsxpackages/router-core/src/route.tspackages/solid-router/tests/errorComponent.test-d.tsxpackages/solid-router/tests/errorComponent.test.tsxpackages/solid-router/tests/link.test.tsxpackages/solid-router/tests/router.test.tsxpackages/solid-router/tests/server/errorComponent.test.tsxpackages/vue-router/src/CatchBoundary.tsxpackages/vue-router/src/Matches.tsxpackages/vue-router/tests/errorComponent.test-d.tsxpackages/vue-router/tests/errorComponent.test.tsxpackages/vue-router/tests/link.test.tsxpackages/vue-router/tests/router.test.tsx
| name: 'ErrorComponent', | ||
| props: { | ||
| error: Object, | ||
| error: null, |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
set -eu
rg -n 'error:\s*null|props\.error\?\.message|String\(props\.error\)' \
packages/vue-router/src/CatchBoundary.tsx \
packages/vue-router/src/Matches.tsx
rg -n 'InferPropType|extends \[null\]' . \
--glob '*vue*.d.ts' \
--glob '*.d.ts' || trueRepository: TanStack/router
Length of output: 369
🏁 Script executed:
#!/bin/bash
set -eu
sed -n '1,240p' packages/vue-router/src/CatchBoundary.tsx
printf '\n--- Matches ---\n'
sed -n '1,180p' packages/vue-router/src/Matches.tsxRepository: TanStack/router
Length of output: 10611
🏁 Script executed:
#!/bin/bash
set -eu
python3 - <<'PY'
from pathlib import Path
for path in [
Path('packages/vue-router/src/CatchBoundary.tsx'),
Path('packages/vue-router/src/Matches.tsx'),
]:
print(f"\n## {path}\n")
for i, line in enumerate(path.read_text().splitlines(), 1):
if 90 <= i <= 175:
print(f"{i:4}: {line}")
PYRepository: TanStack/router
Length of output: 6339
Render non-Error throws instead of dropping their message. props.error?.message hides thrown strings and numbers, and error: null weakens the prop type. Switch the fallback to String(props.error) and keep the prop typed as unknown.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@packages/vue-router/src/CatchBoundary.tsx` at line 108, Update the error
fallback in CatchBoundary to render String(props.error) so thrown strings and
numbers retain their messages, and change the error prop declaration from null
to unknown to preserve the correct prop type.
|
@LadyBluenotes |
Someone will review it when they've got the time. Please be patient |
fixes #7788
Summary by CodeRabbit
Bug Fixes
Errorvalues, instead of assuming an error message is always available.Documentation
messageorstack.Type Improvements
errorprop is typed asunknown, encouraging safer error handling.