Skip to content

Commit

Permalink
Update Load and ErrorLoad types
Browse files Browse the repository at this point in the history
  • Loading branch information
seanlail committed Jul 1, 2021
1 parent a171fb9 commit 0548e43
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions packages/kit/types/page.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ export type LoadInput<

export type ErrorLoadInput<
PageParams extends Record<string, string> = Record<string, string>,
Context extends Record<string, any> = Record<string, any>
> = LoadInput<PageParams, Context> & {
Context extends Record<string, any> = Record<string, any>,
Session = any
> = LoadInput<PageParams, Context, Session> & {
status: number;
error: Error;
};
Expand All @@ -33,25 +34,35 @@ export type LoadOutput<

// Publicized Types
export type Load<
Input extends { context?: Record<string, any>; pageParams?: Record<string, string> } = {},
Input extends {
context?: Record<string, any>;
pageParams?: Record<string, string>;
session?: any;
} = {},
Output extends { context?: Record<string, any>; props?: Record<string, any> } = {}
> = (
input: LoadInput<
InferValue<Input, 'pageParams', Record<string, string>>,
InferValue<Input, 'context', Record<string, any>>
InferValue<Input, 'context', Record<string, any>>,
InferValue<Input, 'session', any>
>
) => MaybePromise<void | LoadOutput<
InferValue<Output, 'props', Record<string, any>>,
InferValue<Output, 'context', Record<string, any>>
>>;

export type ErrorLoad<
Input extends { context?: Record<string, any>; pageParams?: Record<string, string> } = {},
Input extends {
context?: Record<string, any>;
pageParams?: Record<string, string>;
session?: any;
} = {},
Output extends { context?: Record<string, any>; props?: Record<string, any> } = {}
> = (
input: ErrorLoadInput<
InferValue<Input, 'pageParams', Record<string, string>>,
InferValue<Input, 'context', Record<string, any>>
InferValue<Input, 'context', Record<string, any>>,
InferValue<Input, 'session', any>
>
) => MaybePromise<
LoadOutput<
Expand Down

0 comments on commit 0548e43

Please sign in to comment.