sapper.d.ts 1.4 KB

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