This repository was archived by the owner on Jan 11, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 425
add types for stores #1601
Merged
Merged
add types for stores #1601
Changes from 6 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
0cead47
add types for stores
5f4097a
make middleware opts optional ts
0d60b9e
fix some types
60bb696
change Element to Node
fecc322
define session type
042c9a0
add session type to middleware
45d3855
Merge branch 'master' into thecomputerm/types
7f079e6
get PageContext from @sapper/common
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,14 +1,21 @@ | ||
declare module '@sapper/app' { | ||
import { Readable, Writable } from 'svelte/store'; | ||
import { PageContext } from '@sapper/app/types'; | ||
|
||
export interface Redirect { | ||
statusCode: number | ||
location: string | ||
} | ||
|
||
export function goto(href: string, opts: { noscroll?: boolean, replaceState?: boolean }): Promise<void>; | ||
export function goto(href: string, opts?: { noscroll?: boolean, replaceState?: boolean }): Promise<void>; | ||
export function prefetch(href: string): Promise<{ redirect?: Redirect; data?: unknown }>; | ||
export function prefetchRoutes(pathnames: string[]): Promise<void>; | ||
export function start(opts: { target: Node }): Promise<void>; | ||
export const stores: () => unknown; | ||
export function stores<Session = any>(): { | ||
preloading: Readable<boolean> | ||
page: Readable<PageContext> | ||
session: Writable<Session> | ||
}; | ||
} | ||
|
||
declare module '@sapper/server' { | ||
|
@@ -21,7 +28,7 @@ declare module '@sapper/server' { | |
ignore?: Ignore | ||
} | ||
|
||
export function middleware(opts: MiddlewareOptions): Handler; | ||
export function middleware<Session = unknown>(opts?: MiddlewareOptions<Session>): Handler; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think this works correctly unless we also parameterize |
||
} | ||
|
||
declare module '@sapper/service-worker' { | ||
|
@@ -39,15 +46,9 @@ declare module '@sapper/common' { | |
redirect: (statusCode: number, location: string) => void; | ||
} | ||
|
||
export interface Page { | ||
host: string; | ||
path: string; | ||
params: Record<string, string>; | ||
query: Record<string, string | string[]>; | ||
error?: Error; | ||
} | ||
export { PageContext as Page } from '@sapper/app/types'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also imported PageContext from |
||
|
||
export interface Preload { | ||
(this: PreloadContext, page: Page, session: any): object | Promise<object>; | ||
(this: PreloadContext, page: PageContext, session: any): object | Promise<object>; | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.