Skip to content

Commit e97ae86

Browse files
authored
fix(react): Relax React Router 6 RouteObject typing. (#6274)
- Added `errorElement` type to both `NonIndexRouteObject` and `IndexRouteObject` - Also extended `RouteObject` with `Record<string, any>` to prevent such things breaking users' builds in the future.
1 parent de6b477 commit e97ae86

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

packages/react/src/types.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ export interface NonIndexRouteObject {
2020
caseSensitive?: boolean;
2121
children?: RouteObject[];
2222
element?: React.ReactNode | null;
23+
errorElement?: React.ReactNode | null;
2324
index?: any;
2425
path?: string;
2526
}
@@ -28,14 +29,15 @@ export interface IndexRouteObject {
2829
caseSensitive?: boolean;
2930
children?: undefined;
3031
element?: React.ReactNode | null;
32+
errorElement?: React.ReactNode | null;
3133
index: any;
3234
path?: string;
3335
}
3436

3537
// This type was originally just `type RouteObject = IndexRouteObject`, but this was changed
3638
// in https://github.com/remix-run/react-router/pull/9366, which was released with `6.4.2`
3739
// See https://github.com/remix-run/react-router/issues/9427 for a discussion on this.
38-
export type RouteObject = IndexRouteObject | NonIndexRouteObject;
40+
export type RouteObject = (IndexRouteObject | NonIndexRouteObject) & Record<string, any>;
3941

4042
export type Params<Key extends string = string> = {
4143
readonly [key in Key]: string | undefined;

0 commit comments

Comments
 (0)