1
- import { Location as Page , MaybePromise , InferValue } from './helper' ;
1
+ import { InferValue , Location as Page , MaybePromise , Rec } from './helper' ;
2
2
3
3
export interface LoadInput <
4
- PageParams extends Record < string , string > = Record < string , string > ,
5
- Context extends Record < string , any > = Record < string , any > ,
4
+ PageParams extends Rec < string > = Rec < string > ,
5
+ Context extends Rec = Rec ,
6
6
Session = any
7
7
> {
8
8
page : Page < PageParams > ;
@@ -12,18 +12,15 @@ export interface LoadInput<
12
12
}
13
13
14
14
export interface ErrorLoadInput <
15
- PageParams extends Record < string , string > = Record < string , string > ,
16
- Context extends Record < string , any > = Record < string , any > ,
15
+ PageParams extends Rec < string > = Rec < string > ,
16
+ Context extends Rec = Rec ,
17
17
Session = any
18
18
> extends LoadInput < PageParams , Context , Session > {
19
19
status ?: number ;
20
20
error ?: Error ;
21
21
}
22
22
23
- export interface LoadOutput <
24
- Props extends Record < string , any > = Record < string , any > ,
25
- Context extends Record < string , any > = Record < string , any >
26
- > {
23
+ export interface LoadOutput < Props extends Rec = Rec , Context extends Rec = Rec > {
27
24
status ?: number ;
28
25
error ?: string | Error ;
29
26
redirect ?: string ;
@@ -32,43 +29,44 @@ export interface LoadOutput<
32
29
maxage ?: number ;
33
30
}
34
31
35
- // Publicized Types
36
- export type Load <
37
- Input extends {
38
- context ?: Record < string , any > ;
39
- pageParams ?: Record < string , string > ;
40
- session ?: any ;
41
- } = { } ,
42
- Output extends { context ?: Record < string , any > ; props ?: Record < string , any > } = { }
43
- > = (
44
- input : LoadInput <
45
- InferValue < Input , 'pageParams' , Record < string , string > > ,
46
- InferValue < Input , 'context' , Record < string , any > > ,
47
- InferValue < Input , 'session' , any >
48
- >
49
- ) => MaybePromise < void | LoadOutput <
50
- InferValue < Output , 'props' , Record < string , any > > ,
51
- InferValue < Output , 'context' , Record < string , any > >
52
- > > ;
32
+ interface LoadInputExtends {
33
+ context ?: Rec ;
34
+ pageParams ?: Rec < string > ;
35
+ session ?: any ;
36
+ }
53
37
54
- export type ErrorLoad <
55
- Input extends {
56
- context ?: Record < string , any > ;
57
- pageParams ?: Record < string , string > ;
58
- session ?: any ;
59
- } = { } ,
60
- Output extends { context ?: Record < string , any > ; props ?: Record < string , any > } = { }
61
- > = (
62
- input : ErrorLoadInput <
63
- InferValue < Input , 'pageParams' , Record < string , string > > ,
64
- InferValue < Input , 'context' , Record < string , any > > ,
65
- InferValue < Input , 'session' , any >
66
- >
67
- ) => MaybePromise <
68
- LoadOutput <
69
- InferValue < Output , 'props' , Record < string , any > > ,
70
- InferValue < Output , 'context' , Record < string , any > >
71
- >
72
- > ;
38
+ interface LoadOutputExtends {
39
+ context ?: Rec ;
40
+ props ?: Rec ;
41
+ }
42
+
43
+ export interface Load <
44
+ Input extends LoadInputExtends = Required < LoadInputExtends > ,
45
+ Output extends LoadOutputExtends = Required < LoadOutputExtends >
46
+ > {
47
+ (
48
+ input : LoadInput <
49
+ InferValue < Input , 'pageParams' , Rec < string > > ,
50
+ InferValue < Input , 'context' , Rec > ,
51
+ InferValue < Input , 'session' , any >
52
+ >
53
+ ) : MaybePromise < void | LoadOutput <
54
+ InferValue < Output , 'props' , Rec > ,
55
+ InferValue < Output , 'context' , Rec >
56
+ > > ;
57
+ }
58
+
59
+ export interface ErrorLoad <
60
+ Input extends LoadInputExtends = Required < LoadInputExtends > ,
61
+ Output extends LoadOutputExtends = Required < LoadOutputExtends >
62
+ > {
63
+ (
64
+ input : ErrorLoadInput <
65
+ InferValue < Input , 'pageParams' , Rec < string > > ,
66
+ InferValue < Input , 'context' , Rec > ,
67
+ InferValue < Input , 'session' , any >
68
+ >
69
+ ) : MaybePromise < LoadOutput < InferValue < Output , 'props' , Rec > , InferValue < Output , 'context' , Rec > > > ;
70
+ }
73
71
74
72
export { Page } ;
0 commit comments