From 690778e01729ba1421175fe81348e81af3e78190 Mon Sep 17 00:00:00 2001 From: leesb971204 Date: Mon, 21 Jul 2025 09:32:59 +0900 Subject: [PATCH 1/3] fix: update ErrorRouteComponent to support generic error types Signed-off-by: leesb971204 --- packages/react-router/src/route.tsx | 6 ++++-- packages/solid-router/src/route.tsx | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/packages/react-router/src/route.tsx b/packages/react-router/src/route.tsx index f1a3553131e..a54364f65dd 100644 --- a/packages/react-router/src/route.tsx +++ b/packages/react-router/src/route.tsx @@ -49,7 +49,7 @@ import type { LinkComponentRoute } from './link' declare module '@tanstack/router-core' { export interface UpdatableRouteOptionsExtensions { component?: RouteComponent - errorComponent?: false | null | ErrorRouteComponent + errorComponent?: false | null | ErrorRouteComponent notFoundComponent?: NotFoundRouteComponent pendingComponent?: RouteComponent } @@ -555,7 +555,9 @@ export type AsyncRouteComponent = RouteTypes['component'] & { export type RouteComponent = AsyncRouteComponent<{}> -export type ErrorRouteComponent = AsyncRouteComponent +export type ErrorRouteComponent = AsyncRouteComponent< + ErrorComponentProps +> export type NotFoundRouteComponent = RouteTypes['component'] diff --git a/packages/solid-router/src/route.tsx b/packages/solid-router/src/route.tsx index ed8411a4bca..adeec3e67ce 100644 --- a/packages/solid-router/src/route.tsx +++ b/packages/solid-router/src/route.tsx @@ -49,7 +49,7 @@ import type { LinkComponentRoute } from './link' declare module '@tanstack/router-core' { export interface UpdatableRouteOptionsExtensions { component?: RouteComponent - errorComponent?: false | null | ErrorRouteComponent + errorComponent?: false | null | ErrorRouteComponent notFoundComponent?: NotFoundRouteComponent pendingComponent?: RouteComponent } @@ -499,7 +499,9 @@ export type AsyncRouteComponent = RouteTypes['component'] & { export type RouteComponent = AsyncRouteComponent<{}> -export type ErrorRouteComponent = AsyncRouteComponent +export type ErrorRouteComponent = AsyncRouteComponent< + ErrorComponentProps +> export type NotFoundRouteComponent = RouteTypes['component'] From 7e247ddee1ed8e02f593c211be4206e47db3df44 Mon Sep 17 00:00:00 2001 From: leesb971204 Date: Wed, 13 Aug 2025 16:43:26 +0900 Subject: [PATCH 2/3] fix: simplify ErrorRouteComponent type definition by removing generic parameter Signed-off-by: leesb971204 --- packages/react-router/src/route.tsx | 6 ++---- packages/router-core/src/route.ts | 4 ++-- packages/solid-router/src/route.tsx | 6 ++---- 3 files changed, 6 insertions(+), 10 deletions(-) diff --git a/packages/react-router/src/route.tsx b/packages/react-router/src/route.tsx index a54364f65dd..f1a3553131e 100644 --- a/packages/react-router/src/route.tsx +++ b/packages/react-router/src/route.tsx @@ -49,7 +49,7 @@ import type { LinkComponentRoute } from './link' declare module '@tanstack/router-core' { export interface UpdatableRouteOptionsExtensions { component?: RouteComponent - errorComponent?: false | null | ErrorRouteComponent + errorComponent?: false | null | ErrorRouteComponent notFoundComponent?: NotFoundRouteComponent pendingComponent?: RouteComponent } @@ -555,9 +555,7 @@ export type AsyncRouteComponent = RouteTypes['component'] & { export type RouteComponent = AsyncRouteComponent<{}> -export type ErrorRouteComponent = AsyncRouteComponent< - ErrorComponentProps -> +export type ErrorRouteComponent = AsyncRouteComponent export type NotFoundRouteComponent = RouteTypes['component'] diff --git a/packages/router-core/src/route.ts b/packages/router-core/src/route.ts index b89549cdc64..5d01b977f0e 100644 --- a/packages/router-core/src/route.ts +++ b/packages/router-core/src/route.ts @@ -1317,8 +1317,8 @@ export type ErrorRouteProps = { reset: () => void } -export type ErrorComponentProps = { - error: TError +export type ErrorComponentProps = { + error: Error info?: { componentStack: string } reset: () => void } diff --git a/packages/solid-router/src/route.tsx b/packages/solid-router/src/route.tsx index adeec3e67ce..ed8411a4bca 100644 --- a/packages/solid-router/src/route.tsx +++ b/packages/solid-router/src/route.tsx @@ -49,7 +49,7 @@ import type { LinkComponentRoute } from './link' declare module '@tanstack/router-core' { export interface UpdatableRouteOptionsExtensions { component?: RouteComponent - errorComponent?: false | null | ErrorRouteComponent + errorComponent?: false | null | ErrorRouteComponent notFoundComponent?: NotFoundRouteComponent pendingComponent?: RouteComponent } @@ -499,9 +499,7 @@ export type AsyncRouteComponent = RouteTypes['component'] & { export type RouteComponent = AsyncRouteComponent<{}> -export type ErrorRouteComponent = AsyncRouteComponent< - ErrorComponentProps -> +export type ErrorRouteComponent = AsyncRouteComponent export type NotFoundRouteComponent = RouteTypes['component'] From 524a5bcf399da8146c97ea7260cfe1859d0e4684 Mon Sep 17 00:00:00 2001 From: leesb971204 Date: Wed, 13 Aug 2025 16:44:37 +0900 Subject: [PATCH 3/3] docs(router): update errorComponentComponent.md Signed-off-by: leesb971204 --- .../framework/react/api/router/errorComponentComponent.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/router/framework/react/api/router/errorComponentComponent.md b/docs/router/framework/react/api/router/errorComponentComponent.md index 04399f124da..d54ac5cd557 100644 --- a/docs/router/framework/react/api/router/errorComponentComponent.md +++ b/docs/router/framework/react/api/router/errorComponentComponent.md @@ -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