-
-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add a SvelteKit namespace for app-level types (#3569)
- Loading branch information
1 parent
c1f5a13
commit d7e60f5
Showing
6 changed files
with
48 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
declare namespace SvelteKit { | ||
interface Session { | ||
answer: number; | ||
calls: number; | ||
} | ||
|
||
interface Stuff { | ||
message: string; | ||
error: string; | ||
page: string; | ||
value: number; | ||
x: string; | ||
y: string; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,85 +1,40 @@ | ||
import { Fallthrough } from './endpoint'; | ||
import { Either, InferValue, MaybePromise } from './helper'; | ||
import { Either, MaybePromise } from './helper'; | ||
|
||
export interface LoadInput< | ||
PageParams extends Record<string, string> = Record<string, string>, | ||
Stuff extends Record<string, any> = Record<string, any>, | ||
Session = any | ||
> { | ||
export interface LoadInput<Params = Record<string, string>> { | ||
url: URL; | ||
params: PageParams; | ||
params: Params; | ||
fetch(info: RequestInfo, init?: RequestInit): Promise<Response>; | ||
session: Session; | ||
stuff: Stuff; | ||
session: SvelteKit.Session; | ||
stuff: Partial<SvelteKit.Stuff>; | ||
} | ||
|
||
export interface ErrorLoadInput< | ||
PageParams extends Record<string, string> = Record<string, string>, | ||
Stuff extends Record<string, any> = Record<string, any>, | ||
Session = any | ||
> extends LoadInput<PageParams, Stuff, Session> { | ||
export interface ErrorLoadInput<Params = Record<string, string>> extends LoadInput<Params> { | ||
status?: number; | ||
error?: Error; | ||
} | ||
|
||
export interface LoadOutput< | ||
Props extends Record<string, any> = Record<string, any>, | ||
Stuff extends Record<string, any> = Record<string, any> | ||
> { | ||
export interface LoadOutput<Props = Record<string, any>> { | ||
status?: number; | ||
error?: string | Error; | ||
redirect?: string; | ||
props?: Props; | ||
stuff?: Stuff; | ||
stuff?: Partial<SvelteKit.Stuff>; | ||
maxage?: number; | ||
} | ||
|
||
interface LoadInputExtends { | ||
stuff?: Record<string, any>; | ||
pageParams?: Record<string, string>; | ||
session?: any; | ||
params?: Record<string, string>; | ||
} | ||
|
||
interface LoadOutputExtends { | ||
stuff?: Record<string, any>; | ||
props?: Record<string, any>; | ||
} | ||
|
||
export interface Load< | ||
Input extends LoadInputExtends = Required<LoadInputExtends>, | ||
Output extends LoadOutputExtends = Required<LoadOutputExtends> | ||
> { | ||
( | ||
input: LoadInput< | ||
InferValue<Input, 'pageParams', Record<string, string>>, | ||
InferValue<Input, 'stuff', Record<string, any>>, | ||
InferValue<Input, 'session', any> | ||
> | ||
): MaybePromise< | ||
Either< | ||
Fallthrough, | ||
LoadOutput< | ||
InferValue<Output, 'props', Record<string, any>>, | ||
InferValue<Output, 'stuff', Record<string, any>> | ||
> | ||
> | ||
>; | ||
export interface Load<Params = Record<string, string>, Props = Record<string, any>> { | ||
(input: LoadInput<Params>): MaybePromise<Either<Fallthrough, LoadOutput<Props>>>; | ||
} | ||
|
||
export interface ErrorLoad< | ||
Input extends LoadInputExtends = Required<LoadInputExtends>, | ||
Output extends LoadOutputExtends = Required<LoadOutputExtends> | ||
> { | ||
( | ||
input: ErrorLoadInput< | ||
InferValue<Input, 'pageParams', Record<string, string>>, | ||
InferValue<Input, 'stuff', Record<string, any>>, | ||
InferValue<Input, 'session', any> | ||
> | ||
): MaybePromise< | ||
LoadOutput< | ||
InferValue<Output, 'props', Record<string, any>>, | ||
InferValue<Output, 'stuff', Record<string, any>> | ||
> | ||
>; | ||
export interface ErrorLoad<Params = Record<string, string>, Props = Record<string, any>> { | ||
(input: ErrorLoadInput<Params>): MaybePromise<LoadOutput<Props>>; | ||
} |