sapper.d.ts 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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 { goto, prefetch, prefetchRoutes, start, stores }
  24. }
  25. declare module '@sapper/server' {
  26. import { RequestHandler } from 'express'
  27. interface MiddlewareOptions {
  28. session?: (req: Express.Request, res: Express.Response) => unknown
  29. ignore?: unknown
  30. }
  31. function middleware(opts?: MiddlewareOptions): RequestHandler
  32. export { middleware }
  33. }
  34. declare module '@sapper/service-worker' {
  35. const timestamp: number
  36. const files: string[]
  37. const shell: string[]
  38. const routes: { pattern: RegExp }[]
  39. export { timestamp, files, files as assets, shell, routes }
  40. }