sapper.d.ts 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. declare module "@sapper/app" {
  2. import { PageData } from "src/utils/session";
  3. // from sapper/runtime/src/app/types.ts
  4. // sapper doesn't export its types yet
  5. interface Redirect {
  6. statusCode: number
  7. location: string
  8. }
  9. // end
  10. function goto(href: string, opts?: { replaceState: boolean }): Promise<unknown>
  11. function prefetch(href: string): Promise<{ redirect?: Redirect; data?: unknown }>
  12. function prefetchRoutes(pathnames: string[]): Promise<unknown>
  13. function start(opts: { target: Element | null }): Promise<unknown>
  14. const stores: () => {
  15. page: PageStore<PageData>,
  16. preloading: boolean,
  17. session: Writable<unknown>
  18. };
  19. export {
  20. goto, prefetch, prefetchRoutes, start, stores,
  21. };
  22. }
  23. declare module "@sapper/server" {
  24. import { RequestHandler } from "express";
  25. interface MiddlewareOptions {
  26. session?: (req: Express.Request, res: Express.Response) => unknown
  27. ignore?: unknown
  28. }
  29. function middleware(opts?: MiddlewareOptions): RequestHandler
  30. export { middleware };
  31. }
  32. declare module "@sapper/service-worker" {
  33. const timestamp: number;
  34. const files: string[];
  35. const shell: string[];
  36. const routes: { pattern: RegExp }[];
  37. export {
  38. timestamp, files, files as assets, shell, routes,
  39. };
  40. }