File tree Expand file tree Collapse file tree 3 files changed +15
-4
lines changed Expand file tree Collapse file tree 3 files changed +15
-4
lines changed Original file line number Diff line number Diff line change
1
+ ---
2
+ " @remix-run/router " : patch
3
+ ---
4
+
5
+ Enhance the return type of ` Route.lazy ` to prohibit returning an empty object
Original file line number Diff line number Diff line change @@ -10,7 +10,6 @@ import type {
10
10
StaticHandlerContext ,
11
11
To ,
12
12
TrackedPromise ,
13
- LazyRouteFunction ,
14
13
} from "@remix-run/router" ;
15
14
import type { Action as NavigationType } from "@remix-run/router" ;
16
15
@@ -31,7 +30,7 @@ export interface IndexRouteObject {
31
30
errorElement ?: React . ReactNode | null ;
32
31
Component ?: React . ComponentType | null ;
33
32
ErrorBoundary ?: React . ComponentType | null ;
34
- lazy ?: LazyRouteFunction < IndexRouteObject > ;
33
+ lazy ?: AgnosticIndexRouteObject [ "lazy" ] ;
35
34
}
36
35
37
36
export interface NonIndexRouteObject {
@@ -49,7 +48,7 @@ export interface NonIndexRouteObject {
49
48
errorElement ?: React . ReactNode | null ;
50
49
Component ?: React . ComponentType | null ;
51
50
ErrorBoundary ?: React . ComponentType | null ;
52
- lazy ?: LazyRouteFunction < NonIndexRouteObject > ;
51
+ lazy ?: AgnosticNonIndexRouteObject [ "lazy" ] ;
53
52
}
54
53
55
54
export type RouteObject = IndexRouteObject | NonIndexRouteObject ;
Original file line number Diff line number Diff line change @@ -239,12 +239,19 @@ export const immutableRouteKeys = new Set<ImmutableRouteKey>([
239
239
"children" ,
240
240
] ) ;
241
241
242
+ type RequireOne < T , Key = keyof T > = Exclude <
243
+ {
244
+ [ K in keyof T ] : K extends Key ? Omit < T , K > & Required < Pick < T , K > > : never ;
245
+ } [ keyof T ] ,
246
+ undefined
247
+ > ;
248
+
242
249
/**
243
250
* lazy() function to load a route definition, which can add non-matching
244
251
* related properties to a route
245
252
*/
246
253
export interface LazyRouteFunction < R extends AgnosticRouteObject > {
247
- ( ) : Promise < Omit < R , ImmutableRouteKey > > ;
254
+ ( ) : Promise < RequireOne < Omit < R , ImmutableRouteKey > > > ;
248
255
}
249
256
250
257
/**
You can’t perform that action at this time.
0 commit comments