Which project does this relate to?
Router
Describe the bug
The ErrorComponentProps type, that replaces the deprecated ErrorRouteProps, incorrectly models the error as an Error .
In our production app, our fetch behaviour does not throw an Error, but instead a detailed rich object that consumers can dig into.
In the simplest example, a route's loader could throw a primitive data type such as a string instead of an Error, however the props of the associated errorComponent (modelled as ErrorComponentProps) presume that the error will always be an Error.
Your Example Website or App
https://stackblitz.com/edit/github-gk2uhnxn?file=src%2Froutes%2Findex.tsx
Steps to Reproduce the Bug or Issue
Throw a non-Error data type in a loader, for example throw 'hello'.
Observe that the props of the loader's errorComponent incorrectly model the error prop as an Error type, even though we called throw with a typeof string.
Expected behavior
Preferably:
- export type ErrorComponentProps = {
- error: Error
+ export type ErrorComponentProps<E> = {
+ error: E
info?: { componentStack: string }
reset: () => void
}
or at least:
- export type ErrorComponentProps = {
- error: Error
+ export type ErrorComponentProps = {
+ error: unknown
info?: { componentStack: string }
reset: () => void
}
Screenshots or Videos
Platform
@tanstack/react-router@1.127.9
Additional context
Which project does this relate to?
Router
Describe the bug
The
ErrorComponentPropstype, that replaces the deprecatedErrorRouteProps, incorrectly models theerroras anError.In our production app, our fetch behaviour does not throw an
Error, but instead a detailed rich object that consumers can dig into.In the simplest example, a route's
loadercould throw a primitive data type such as astringinstead of anError, however the props of the associatederrorComponent(modelled asErrorComponentProps) presume that theerrorwill always be anError.Your Example Website or App
https://stackblitz.com/edit/github-gk2uhnxn?file=src%2Froutes%2Findex.tsx
Steps to Reproduce the Bug or Issue
Throw a non-
Errordata type in aloader, for examplethrow 'hello'.Observe that the props of the loader's
errorComponentincorrectly model theerrorprop as anErrortype, even though we calledthrowwith a typeofstring.Expected behavior
Preferably:
or at least:
Screenshots or Videos
Platform
@tanstack/react-router@1.127.9
Additional context