Skip to content

Commit 36cc4ad

Browse files
committed
rename Index to Rec
1 parent c30f788 commit 36cc4ad

File tree

2 files changed

+18
-20
lines changed

2 files changed

+18
-20
lines changed

packages/kit/types/helper.d.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ export type Location<Params extends Record<string, string> = Record<string, stri
2626
query: URLSearchParams;
2727
};
2828

29-
export type Index<T = any> = Record<string, T>;
3029
export type InferValue<T, Key extends keyof T, Default> = T extends Record<Key, infer Val>
3130
? Val
3231
: Default;
3332
export type MaybePromise<T> = T | Promise<T>;
33+
export type Rec<T = any> = Record<string, T>;

packages/kit/types/page.d.ts

+17-19
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import { Location as Page, MaybePromise, InferValue, Index } from './helper';
1+
import { InferValue, Location as Page, MaybePromise, Rec } from './helper';
22

33
export interface LoadInput<
4-
PageParams extends Index<string> = Index<string>,
5-
Context extends Index = Index,
4+
PageParams extends Rec<string> = Rec<string>,
5+
Context extends Rec = Rec,
66
Session = any
77
> {
88
page: Page<PageParams>;
@@ -12,15 +12,15 @@ export interface LoadInput<
1212
}
1313

1414
export interface ErrorLoadInput<
15-
PageParams extends Index<string> = Index<string>,
16-
Context extends Index = Index,
15+
PageParams extends Rec<string> = Rec<string>,
16+
Context extends Rec = Rec,
1717
Session = any
1818
> extends LoadInput<PageParams, Context, Session> {
1919
status?: number;
2020
error?: Error;
2121
}
2222

23-
export interface LoadOutput<Props extends Index = Index, Context extends Index = Index> {
23+
export interface LoadOutput<Props extends Rec = Rec, Context extends Rec = Rec> {
2424
status?: number;
2525
error?: string | Error;
2626
redirect?: string;
@@ -30,14 +30,14 @@ export interface LoadOutput<Props extends Index = Index, Context extends Index =
3030
}
3131

3232
interface LoadInputExtends {
33-
context?: Index;
34-
pageParams?: Index<string>;
33+
context?: Rec;
34+
pageParams?: Rec<string>;
3535
session?: any;
3636
}
3737

3838
interface LoadOutputExtends {
39-
context?: Index;
40-
props?: Index;
39+
context?: Rec;
40+
props?: Rec;
4141
}
4242

4343
export interface Load<
@@ -46,13 +46,13 @@ export interface Load<
4646
> {
4747
(
4848
input: LoadInput<
49-
InferValue<Input, 'pageParams', Index<string>>,
50-
InferValue<Input, 'context', Index>,
49+
InferValue<Input, 'pageParams', Rec<string>>,
50+
InferValue<Input, 'context', Rec>,
5151
InferValue<Input, 'session', any>
5252
>
5353
): MaybePromise<void | LoadOutput<
54-
InferValue<Output, 'props', Index>,
55-
InferValue<Output, 'context', Index>
54+
InferValue<Output, 'props', Rec>,
55+
InferValue<Output, 'context', Rec>
5656
>>;
5757
}
5858

@@ -62,13 +62,11 @@ export interface ErrorLoad<
6262
> {
6363
(
6464
input: ErrorLoadInput<
65-
InferValue<Input, 'pageParams', Index<string>>,
66-
InferValue<Input, 'context', Index>,
65+
InferValue<Input, 'pageParams', Rec<string>>,
66+
InferValue<Input, 'context', Rec>,
6767
InferValue<Input, 'session', any>
6868
>
69-
): MaybePromise<
70-
LoadOutput<InferValue<Output, 'props', Index>, InferValue<Output, 'context', Index>>
71-
>;
69+
): MaybePromise<LoadOutput<InferValue<Output, 'props', Rec>, InferValue<Output, 'context', Rec>>>;
7270
}
7371

7472
export { Page };

0 commit comments

Comments
 (0)