-
-
Notifications
You must be signed in to change notification settings - Fork 720
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(react-router): add NotFoundErrorData interface for improved type safety #3112
base: main
Are you sure you want to change the base?
Conversation
One of those two things should be correct
View your CI Pipeline Execution ↗ for commit 1eafefc.
☁️ Nx Cloud last updated this comment at |
might be worth extending the existing Register interface already used for registering the router type, rather than adding a new interface for the same purpose |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add this into the reference docs for notFound
.
Here's a demo of this PR, throwing type-safe
notFound
errors: https://stackblitz.com/edit/tanstack-router-fyrpy35d?file=src%2Froutes%2Findex.tsxCurrently the
notFound()
function accepts a params object with the shape ofNotFoundError
that is then passed as props to thenotFoundComponent
.Arbitrary data can be send through this mechanism with the
data?: any
key ofNotFoundError
, but thisany
prevents us from creating type-safe "not found" errors.This PR proposes that users should be able to define their own
data
shape through the global augmentation of a new interfaceNotFoundErrorData
. For example:This PR uses this new interface in a way that will preserve
data?: any
as the default if it is not globally augmented:Closes #3113