Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ The `ErrorComponent` component accepts the following props:

### `props.error` prop

- Type: `TError` (defaults to `Error`)
- Type: `Error`
- The error that was thrown by the component's children

### `props.info` prop
Expand Down
4 changes: 2 additions & 2 deletions packages/router-core/src/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1317,8 +1317,8 @@ export type ErrorRouteProps = {
reset: () => void
}

export type ErrorComponentProps<TError = Error> = {
error: TError
export type ErrorComponentProps = {
error: Error
Comment on lines +1320 to +1321
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since the scope of the errorComponent covers both errors from the loader and errors from the component itself, using the Error type is appropriate

Copy link

@michaelbull michaelbull Sep 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems to undo the work of making it handle throwing of non-errors. What if my loader calls some third-party API that internally does throw "Some string" or throw 50? Loaders can throw more than just Errors, and in some situations the user is not in control of what could be thrown.

Copy link
Contributor Author

@leesb971204 leesb971204 Sep 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@michaelbull

That’s right. But since in most cases the error is returned as Error, I think it makes sense to set the type to Error by default, and if needed, the user can manually override the error type using something like declare. Please refer to the link.

info?: { componentStack: string }
reset: () => void
}
Expand Down