-
-
Notifications
You must be signed in to change notification settings - Fork 428
add types for stores #1568
add types for stores #1568
Changes from 2 commits
570cdbc
3e7a4bc
16a3c81
724dd67
29ab870
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,53 @@ | ||
declare module "@sapper/app" | ||
declare module "@sapper/server" | ||
declare module "@sapper/service-worker" | ||
declare module "@sapper/app"; | ||
declare module "@sapper/server"; | ||
declare module "@sapper/service-worker"; | ||
|
||
interface Stores { | ||
preloading: { | ||
subscribe(preloading: boolean): () => void; | ||
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. There are ready-made types for Stores in svelte that you could reuse that give a more complete type definition for subscribe (there's an optional second parameter and a return value that are missing here): I think if you just do
you should get the correct definitions for For the page store, there is also already a
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. Done, Thanks. |
||
}; | ||
page: { | ||
subscribe(info: { | ||
error: boolean; | ||
host: string; | ||
path: string; | ||
params: object; | ||
query: object; | ||
}): () => void; | ||
}; | ||
session: { | ||
set(value: any): void; | ||
update(update: (existing) => {}): void; | ||
subscribe(value: any): () => void; | ||
}; | ||
} | ||
|
||
declare module "@sapper/app" { | ||
export interface Redirect { | ||
statusCode: number | ||
location: string | ||
statusCode: number; | ||
location: string; | ||
} | ||
|
||
export function goto(href: string, opts: { noscroll?: boolean, replaceState?: boolean }): Promise<void>; | ||
export function prefetch(href: string): Promise<{ redirect?: Redirect; data?: unknown }>; | ||
export function goto( | ||
href: string, | ||
opts: { noscroll?: boolean; replaceState?: boolean } | ||
): Promise<void>; | ||
export function prefetch( | ||
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. can you leave the method formatting the way it was? |
||
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(): Stores; | ||
} | ||
|
||
declare module "@sapper/server" { | ||
import { Handler, Req, Res } from '@sapper/internal/manifest-server'; | ||
import { Handler, Req, Res } from "@sapper/internal/manifest-server"; | ||
|
||
export type Ignore = string | RegExp | ((uri: string) => boolean) | Ignore[]; | ||
|
||
export interface MiddlewareOptions { | ||
session?: (req: Req, res: Res) => unknown | ||
ignore?: Ignore | ||
session?: (req: Req, res: Res) => unknown; | ||
ignore?: Ignore; | ||
} | ||
|
||
export function middleware(opts: MiddlewareOptions): Handler; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there were just removed in #1598. you might need to rebase against
master