From b25f2d052bbf22e832ac57cbf9e12c48ac922f96 Mon Sep 17 00:00:00 2001 From: Alois Klink Date: Tue, 5 Nov 2024 14:17:06 +0900 Subject: [PATCH 1/2] fix: use arrow func types over bound functions Using class method function types causes SvelteKit users to get TypeScript ESLint errors if they're using the [@typescript-eslint/unbound-method][1] rule (included by default in the `recommended-type-checked` config). [1]: https://typescript-eslint.io/rules/unbound-method/ --- .changeset/wet-dancers-kneel.md | 5 ++++ packages/kit/src/exports/public.d.ts | 34 ++++++++++++++-------------- packages/kit/types/index.d.ts | 34 ++++++++++++++-------------- 3 files changed, 39 insertions(+), 34 deletions(-) create mode 100644 .changeset/wet-dancers-kneel.md diff --git a/.changeset/wet-dancers-kneel.md b/.changeset/wet-dancers-kneel.md new file mode 100644 index 000000000000..2c3a34603489 --- /dev/null +++ b/.changeset/wet-dancers-kneel.md @@ -0,0 +1,5 @@ +--- +'@sveltejs/kit': patch +--- + +fix: use arrow function types over bound funcs diff --git a/packages/kit/src/exports/public.d.ts b/packages/kit/src/exports/public.d.ts index 77be062a3163..0dc6860f9dee 100644 --- a/packages/kit/src/exports/public.d.ts +++ b/packages/kit/src/exports/public.d.ts @@ -34,7 +34,7 @@ export interface Adapter { * This function is called after SvelteKit has built your app. * @param builder An object provided by SvelteKit that contains methods for adapting the app */ - adapt(builder: Builder): MaybePromise; + adapt: (builder: Builder) => MaybePromise; /** * Checks called during dev and build to determine whether specific features will work in production with this adapter */ @@ -49,7 +49,7 @@ export interface Adapter { * Creates an `Emulator`, which allows the adapter to influence the environment * during dev, build and prerendering */ - emulate?(): MaybePromise; + emulate?: () => MaybePromise; } export type LoadProperties | void> = input extends void @@ -685,7 +685,7 @@ export interface KitConfig { */ export type Handle = (input: { event: RequestEvent; - resolve(event: RequestEvent, opts?: ResolveOptions): MaybePromise; + resolve: (event: RequestEvent, opts?: ResolveOptions) => MaybePromise; }) => MaybePromise; /** @@ -791,14 +791,14 @@ export interface LoadEvent< * * `setHeaders` has no effect when a `load` function runs in the browser. */ - setHeaders(headers: Record): void; + setHeaders: (headers: Record) => void; /** * `await parent()` returns data from parent `+layout.js` `load` functions. * Implicitly, a missing `+layout.js` is treated as a `({ data }) => data` function, meaning that it will return and forward data from parent `+layout.server.js` files. * * Be careful not to introduce accidental waterfalls when using `await parent()`. If for example you only want to merge parent data into the returned output, call it _after_ fetching your other data. */ - parent(): Promise; + parent: () => Promise; /** * This function declares that the `load` function has a _dependency_ on one or more URLs or custom identifiers, which can subsequently be used with [`invalidate()`](https://svelte.dev/docs/kit/$app-navigation#invalidate) to cause `load` to rerun. * @@ -836,7 +836,7 @@ export interface LoadEvent< * * ``` */ - depends(...deps: Array<`${string}:${string}`>): void; + depends: (...deps: Array<`${string}:${string}`>) => void; /** * Use this function to opt out of dependency tracking for everything that is synchronously called within the callback. Example: * @@ -850,7 +850,7 @@ export interface LoadEvent< * } * ``` */ - untrack(fn: () => T): T; + untrack: (fn: () => T) => T; } export interface NavigationEvent< @@ -1059,7 +1059,7 @@ export interface RequestEvent< /** * The client's IP address, set by the adapter. */ - getClientAddress(): string; + getClientAddress: () => string; /** * Contains custom data that was added to the request within the [`server handle hook`](https://svelte.dev/docs/kit/hooks#Server-hooks-handle). */ @@ -1107,7 +1107,7 @@ export interface RequestEvent< * * You cannot add a `set-cookie` header with `setHeaders` — use the [`cookies`](https://svelte.dev/docs/kit/@sveltejs-kit#Cookies) API instead. */ - setHeaders(headers: Record): void; + setHeaders: (headers: Record) => void; /** * The requested URL. */ @@ -1140,20 +1140,20 @@ export interface ResolveOptions { * but they will always be split at sensible boundaries such as `%sveltekit.head%` or layout/page components. * @param input the html chunk and the info if this is the last chunk */ - transformPageChunk?(input: { html: string; done: boolean }): MaybePromise; + transformPageChunk?: (input: { html: string; done: boolean }) => MaybePromise; /** * Determines which headers should be included in serialized responses when a `load` function loads a resource with `fetch`. * By default, none will be included. * @param name header name * @param value header value */ - filterSerializedResponseHeaders?(name: string, value: string): boolean; + filterSerializedResponseHeaders?: (name: string, value: string) => boolean; /** * Determines what should be added to the `` tag to preload it. * By default, `js` and `css` files will be preloaded. * @param input the type of the file and its path */ - preload?(input: { type: 'font' | 'css' | 'js' | 'asset'; path: string }): boolean; + preload?: (input: { type: 'font' | 'css' | 'js' | 'asset'; path: string }) => boolean; } export interface RouteDefinition { @@ -1222,7 +1222,7 @@ export interface ServerLoadEvent< * * Be careful not to introduce accidental waterfalls when using `await parent()`. If for example you only want to merge parent data into the returned output, call it _after_ fetching your other data. */ - parent(): Promise; + parent: () => Promise; /** * This function declares that the `load` function has a _dependency_ on one or more URLs or custom identifiers, which can subsequently be used with [`invalidate()`](https://svelte.dev/docs/kit/$app-navigation#invalidate) to cause `load` to rerun. * @@ -1260,7 +1260,7 @@ export interface ServerLoadEvent< * * ``` */ - depends(...deps: string[]): void; + depends: (...deps: string[]) => void; /** * Use this function to opt out of dependency tracking for everything that is synchronously called within the callback. Example: * @@ -1274,7 +1274,7 @@ export interface ServerLoadEvent< * } * ``` */ - untrack(fn: () => T): T; + untrack: (fn: () => T) => T; } /** @@ -1345,7 +1345,7 @@ export type SubmitFunction< formElement: HTMLFormElement; controller: AbortController; submitter: HTMLElement | null; - cancel(): void; + cancel: () => void; }) => MaybePromise< | void | ((opts: { @@ -1358,7 +1358,7 @@ export type SubmitFunction< * @param options Set `reset: false` if you don't want the `
` values to be reset after a successful submission. * @param invalidateAll Set `invalidateAll: false` if you don't want the action to call `invalidateAll` after submission. */ - update(options?: { reset?: boolean; invalidateAll?: boolean }): Promise; + update: (options?: { reset?: boolean; invalidateAll?: boolean }) => Promise; }) => void) >; diff --git a/packages/kit/types/index.d.ts b/packages/kit/types/index.d.ts index 491de54d9698..5ef5872137b4 100644 --- a/packages/kit/types/index.d.ts +++ b/packages/kit/types/index.d.ts @@ -16,7 +16,7 @@ declare module '@sveltejs/kit' { * This function is called after SvelteKit has built your app. * @param builder An object provided by SvelteKit that contains methods for adapting the app */ - adapt(builder: Builder): MaybePromise; + adapt: (builder: Builder) => MaybePromise; /** * Checks called during dev and build to determine whether specific features will work in production with this adapter */ @@ -31,7 +31,7 @@ declare module '@sveltejs/kit' { * Creates an `Emulator`, which allows the adapter to influence the environment * during dev, build and prerendering */ - emulate?(): MaybePromise; + emulate?: () => MaybePromise; } export type LoadProperties | void> = input extends void @@ -667,7 +667,7 @@ declare module '@sveltejs/kit' { */ export type Handle = (input: { event: RequestEvent; - resolve(event: RequestEvent, opts?: ResolveOptions): MaybePromise; + resolve: (event: RequestEvent, opts?: ResolveOptions) => MaybePromise; }) => MaybePromise; /** @@ -773,14 +773,14 @@ declare module '@sveltejs/kit' { * * `setHeaders` has no effect when a `load` function runs in the browser. */ - setHeaders(headers: Record): void; + setHeaders: (headers: Record) => void; /** * `await parent()` returns data from parent `+layout.js` `load` functions. * Implicitly, a missing `+layout.js` is treated as a `({ data }) => data` function, meaning that it will return and forward data from parent `+layout.server.js` files. * * Be careful not to introduce accidental waterfalls when using `await parent()`. If for example you only want to merge parent data into the returned output, call it _after_ fetching your other data. */ - parent(): Promise; + parent: () => Promise; /** * This function declares that the `load` function has a _dependency_ on one or more URLs or custom identifiers, which can subsequently be used with [`invalidate()`](https://svelte.dev/docs/kit/$app-navigation#invalidate) to cause `load` to rerun. * @@ -818,7 +818,7 @@ declare module '@sveltejs/kit' { * * ``` */ - depends(...deps: Array<`${string}:${string}`>): void; + depends: (...deps: Array<`${string}:${string}`>) => void; /** * Use this function to opt out of dependency tracking for everything that is synchronously called within the callback. Example: * @@ -832,7 +832,7 @@ declare module '@sveltejs/kit' { * } * ``` */ - untrack(fn: () => T): T; + untrack: (fn: () => T) => T; } export interface NavigationEvent< @@ -1041,7 +1041,7 @@ declare module '@sveltejs/kit' { /** * The client's IP address, set by the adapter. */ - getClientAddress(): string; + getClientAddress: () => string; /** * Contains custom data that was added to the request within the [`server handle hook`](https://svelte.dev/docs/kit/hooks#Server-hooks-handle). */ @@ -1089,7 +1089,7 @@ declare module '@sveltejs/kit' { * * You cannot add a `set-cookie` header with `setHeaders` — use the [`cookies`](https://svelte.dev/docs/kit/@sveltejs-kit#Cookies) API instead. */ - setHeaders(headers: Record): void; + setHeaders: (headers: Record) => void; /** * The requested URL. */ @@ -1122,20 +1122,20 @@ declare module '@sveltejs/kit' { * but they will always be split at sensible boundaries such as `%sveltekit.head%` or layout/page components. * @param input the html chunk and the info if this is the last chunk */ - transformPageChunk?(input: { html: string; done: boolean }): MaybePromise; + transformPageChunk?: (input: { html: string; done: boolean }) => MaybePromise; /** * Determines which headers should be included in serialized responses when a `load` function loads a resource with `fetch`. * By default, none will be included. * @param name header name * @param value header value */ - filterSerializedResponseHeaders?(name: string, value: string): boolean; + filterSerializedResponseHeaders?: (name: string, value: string) => boolean; /** * Determines what should be added to the `` tag to preload it. * By default, `js` and `css` files will be preloaded. * @param input the type of the file and its path */ - preload?(input: { type: 'font' | 'css' | 'js' | 'asset'; path: string }): boolean; + preload?: (input: { type: 'font' | 'css' | 'js' | 'asset'; path: string }) => boolean; } export interface RouteDefinition { @@ -1204,7 +1204,7 @@ declare module '@sveltejs/kit' { * * Be careful not to introduce accidental waterfalls when using `await parent()`. If for example you only want to merge parent data into the returned output, call it _after_ fetching your other data. */ - parent(): Promise; + parent: () => Promise; /** * This function declares that the `load` function has a _dependency_ on one or more URLs or custom identifiers, which can subsequently be used with [`invalidate()`](https://svelte.dev/docs/kit/$app-navigation#invalidate) to cause `load` to rerun. * @@ -1242,7 +1242,7 @@ declare module '@sveltejs/kit' { * * ``` */ - depends(...deps: string[]): void; + depends: (...deps: string[]) => void; /** * Use this function to opt out of dependency tracking for everything that is synchronously called within the callback. Example: * @@ -1256,7 +1256,7 @@ declare module '@sveltejs/kit' { * } * ``` */ - untrack(fn: () => T): T; + untrack: (fn: () => T) => T; } /** @@ -1327,7 +1327,7 @@ declare module '@sveltejs/kit' { formElement: HTMLFormElement; controller: AbortController; submitter: HTMLElement | null; - cancel(): void; + cancel: () => void; }) => MaybePromise< | void | ((opts: { @@ -1340,7 +1340,7 @@ declare module '@sveltejs/kit' { * @param options Set `reset: false` if you don't want the `` values to be reset after a successful submission. * @param invalidateAll Set `invalidateAll: false` if you don't want the action to call `invalidateAll` after submission. */ - update(options?: { reset?: boolean; invalidateAll?: boolean }): Promise; + update: (options?: { reset?: boolean; invalidateAll?: boolean }) => Promise; }) => void) >; From 743d807f92bbc4ebd4b16ed09d8b2501b316251b Mon Sep 17 00:00:00 2001 From: Alois Klink Date: Thu, 21 Nov 2024 15:22:04 +0900 Subject: [PATCH 2/2] fix: convert more public types to arrow funcs Convert the rest of the public types in `src/exports/public.d.ts` to use arrow function types instead of bound function types. I kept the following types in `public.d.ts` using non-arrow functions, since - These functions are for user inputs, which might rely on these functions being bound, and so it might be a breaking change to change these types: - [`Emulator['platform']`][1] - functions in `KitConfig` - Class methods that rely on `this`: - [`Server`][2] [1]: https://github.com/sveltejs/kit/blob/b25f2d052bbf22e832ac57cbf9e12c48ac922f96/packages/kit/src/exports/public.d.ts#L272-L276 [2]: https://github.com/sveltejs/kit/blob/b25f2d052bbf22e832ac57cbf9e12c48ac922f96/packages/kit/src/exports/public.d.ts#L1174-L1178 --- packages/kit/src/exports/public.d.ts | 52 +++++++++++------------ packages/kit/src/runtime/server/cookie.js | 4 +- packages/kit/types/index.d.ts | 52 +++++++++++------------ 3 files changed, 54 insertions(+), 54 deletions(-) diff --git a/packages/kit/src/exports/public.d.ts b/packages/kit/src/exports/public.d.ts index 0dc6860f9dee..c835389be299 100644 --- a/packages/kit/src/exports/public.d.ts +++ b/packages/kit/src/exports/public.d.ts @@ -93,9 +93,9 @@ export interface Builder { /** Print messages to the console. `log.info` and `log.minor` are silent unless Vite's `logLevel` is `info`. */ log: Logger; /** Remove `dir` and all its contents. */ - rimraf(dir: string): void; + rimraf: (dir: string) => void; /** Create `dir` and any required parent directories. */ - mkdirp(dir: string): void; + mkdirp: (dir: string) => void; /** The fully resolved `svelte.config.js`. */ config: ValidatedConfig; @@ -110,59 +110,59 @@ export interface Builder { * @param fn A function that groups a set of routes into an entry point * @deprecated Use `builder.routes` instead */ - createEntries(fn: (route: RouteDefinition) => AdapterEntry): Promise; + createEntries: (fn: (route: RouteDefinition) => AdapterEntry) => Promise; /** * Find all the assets imported by server files belonging to `routes` */ - findServerAssets(routes: RouteDefinition[]): string[]; + findServerAssets: (routes: RouteDefinition[]) => string[]; /** * Generate a fallback page for a static webserver to use when no route is matched. Useful for single-page apps. */ - generateFallback(dest: string): Promise; + generateFallback: (dest: string) => Promise; /** * Generate a module exposing build-time environment variables as `$env/dynamic/public`. */ - generateEnvModule(): void; + generateEnvModule: () => void; /** * Generate a server-side manifest to initialise the SvelteKit [server](https://svelte.dev/docs/kit/@sveltejs-kit#Server) with. * @param opts a relative path to the base directory of the app and optionally in which format (esm or cjs) the manifest should be generated */ - generateManifest(opts: { relativePath: string; routes?: RouteDefinition[] }): string; + generateManifest: (opts: { relativePath: string; routes?: RouteDefinition[] }) => string; /** * Resolve a path to the `name` directory inside `outDir`, e.g. `/path/to/.svelte-kit/my-adapter`. * @param name path to the file, relative to the build directory */ - getBuildDirectory(name: string): string; + getBuildDirectory: (name: string) => string; /** Get the fully resolved path to the directory containing client-side assets, including the contents of your `static` directory. */ - getClientDirectory(): string; + getClientDirectory: () => string; /** Get the fully resolved path to the directory containing server-side code. */ - getServerDirectory(): string; + getServerDirectory: () => string; /** Get the application path including any configured `base` path, e.g. `my-base-path/_app`. */ - getAppPath(): string; + getAppPath: () => string; /** * Write client assets to `dest`. * @param dest the destination folder * @returns an array of files written to `dest` */ - writeClient(dest: string): string[]; + writeClient: (dest: string) => string[]; /** * Write prerendered files to `dest`. * @param dest the destination folder * @returns an array of files written to `dest` */ - writePrerendered(dest: string): string[]; + writePrerendered: (dest: string) => string[]; /** * Write server-side code to `dest`. * @param dest the destination folder * @returns an array of files written to `dest` */ - writeServer(dest: string): string[]; + writeServer: (dest: string) => string[]; /** * Copy a file or directory. * @param from the source file or directory @@ -171,20 +171,20 @@ export interface Builder { * @param opts.replace a map of strings to replace * @returns an array of files that were copied */ - copy( + copy: ( from: string, to: string, opts?: { filter?(basename: string): boolean; replace?: Record; } - ): string[]; + ) => string[]; /** * Compress files in `directory` with gzip and brotli, where appropriate. Generates `.gz` and `.br` files alongside the originals. * @param {string} directory The directory containing the files to be compressed */ - compress(directory: string): Promise; + compress: (directory: string) => Promise; } export interface Config { @@ -214,13 +214,13 @@ export interface Cookies { * @param name the name of the cookie * @param opts the options, passed directly to `cookie.parse`. See documentation [here](https://github.com/jshttp/cookie#cookieparsestr-options) */ - get(name: string, opts?: import('cookie').CookieParseOptions): string | undefined; + get: (name: string, opts?: import('cookie').CookieParseOptions) => string | undefined; /** * Gets all cookies that were previously set with `cookies.set`, or from the request headers. * @param opts the options, passed directly to `cookie.parse`. See documentation [here](https://github.com/jshttp/cookie#cookieparsestr-options) */ - getAll(opts?: import('cookie').CookieParseOptions): Array<{ name: string; value: string }>; + getAll: (opts?: import('cookie').CookieParseOptions) => Array<{ name: string; value: string }>; /** * Sets a cookie. This will add a `set-cookie` header to the response, but also make the cookie available via `cookies.get` or `cookies.getAll` during the current request. @@ -232,11 +232,11 @@ export interface Cookies { * @param value the cookie value * @param opts the options, passed directly to `cookie.serialize`. See documentation [here](https://github.com/jshttp/cookie#cookieserializename-value-options) */ - set( + set: ( name: string, value: string, opts: import('cookie').CookieSerializeOptions & { path: string } - ): void; + ) => void; /** * Deletes a cookie by setting its value to an empty string and setting the expiry date in the past. @@ -245,7 +245,7 @@ export interface Cookies { * @param name the name of the cookie * @param opts the options, passed directly to `cookie.serialize`. The `path` must match the path of the cookie you want to delete. See documentation [here](https://github.com/jshttp/cookie#cookieserializename-value-options) */ - delete(name: string, opts: import('cookie').CookieSerializeOptions & { path: string }): void; + delete: (name: string, opts: import('cookie').CookieSerializeOptions & { path: string }) => void; /** * Serialize a cookie name-value pair into a `Set-Cookie` header string, but don't apply it to the response. @@ -258,11 +258,11 @@ export interface Cookies { * @param value the cookie value * @param opts the options, passed directly to `cookie.serialize`. See documentation [here](https://github.com/jshttp/cookie#cookieserializename-value-options) */ - serialize( + serialize: ( name: string, value: string, opts: import('cookie').CookieSerializeOptions & { path: string } - ): string; + ) => string; } /** @@ -945,7 +945,7 @@ export interface BeforeNavigate extends Navigation { /** * Call this to prevent the navigation from starting. */ - cancel(): void; + cancel: () => void; } /** @@ -1195,7 +1195,7 @@ export interface SSRManifest { client: NonNullable; nodes: SSRNodeLoader[]; routes: SSRRoute[]; - matchers(): Promise>; + matchers: () => Promise>; /** A `[file]: size` map of all assets imported by server code */ server_assets: Record; }; diff --git a/packages/kit/src/runtime/server/cookie.js b/packages/kit/src/runtime/server/cookie.js index 7acd24417848..04c8e4a83f22 100644 --- a/packages/kit/src/runtime/server/cookie.js +++ b/packages/kit/src/runtime/server/cookie.js @@ -52,7 +52,7 @@ export function get_cookies(request, url, trailing_slash) { /** * @param {string} name - * @param {import('cookie').CookieParseOptions} opts + * @param {import('cookie').CookieParseOptions} [opts] */ get(name, opts) { const c = new_cookies[name]; @@ -89,7 +89,7 @@ export function get_cookies(request, url, trailing_slash) { }, /** - * @param {import('cookie').CookieParseOptions} opts + * @param {import('cookie').CookieParseOptions} [opts] */ getAll(opts) { const decoder = opts?.decode || decodeURIComponent; diff --git a/packages/kit/types/index.d.ts b/packages/kit/types/index.d.ts index 5ef5872137b4..1705bec0c1f4 100644 --- a/packages/kit/types/index.d.ts +++ b/packages/kit/types/index.d.ts @@ -75,9 +75,9 @@ declare module '@sveltejs/kit' { /** Print messages to the console. `log.info` and `log.minor` are silent unless Vite's `logLevel` is `info`. */ log: Logger; /** Remove `dir` and all its contents. */ - rimraf(dir: string): void; + rimraf: (dir: string) => void; /** Create `dir` and any required parent directories. */ - mkdirp(dir: string): void; + mkdirp: (dir: string) => void; /** The fully resolved `svelte.config.js`. */ config: ValidatedConfig; @@ -92,59 +92,59 @@ declare module '@sveltejs/kit' { * @param fn A function that groups a set of routes into an entry point * @deprecated Use `builder.routes` instead */ - createEntries(fn: (route: RouteDefinition) => AdapterEntry): Promise; + createEntries: (fn: (route: RouteDefinition) => AdapterEntry) => Promise; /** * Find all the assets imported by server files belonging to `routes` */ - findServerAssets(routes: RouteDefinition[]): string[]; + findServerAssets: (routes: RouteDefinition[]) => string[]; /** * Generate a fallback page for a static webserver to use when no route is matched. Useful for single-page apps. */ - generateFallback(dest: string): Promise; + generateFallback: (dest: string) => Promise; /** * Generate a module exposing build-time environment variables as `$env/dynamic/public`. */ - generateEnvModule(): void; + generateEnvModule: () => void; /** * Generate a server-side manifest to initialise the SvelteKit [server](https://svelte.dev/docs/kit/@sveltejs-kit#Server) with. * @param opts a relative path to the base directory of the app and optionally in which format (esm or cjs) the manifest should be generated */ - generateManifest(opts: { relativePath: string; routes?: RouteDefinition[] }): string; + generateManifest: (opts: { relativePath: string; routes?: RouteDefinition[] }) => string; /** * Resolve a path to the `name` directory inside `outDir`, e.g. `/path/to/.svelte-kit/my-adapter`. * @param name path to the file, relative to the build directory */ - getBuildDirectory(name: string): string; + getBuildDirectory: (name: string) => string; /** Get the fully resolved path to the directory containing client-side assets, including the contents of your `static` directory. */ - getClientDirectory(): string; + getClientDirectory: () => string; /** Get the fully resolved path to the directory containing server-side code. */ - getServerDirectory(): string; + getServerDirectory: () => string; /** Get the application path including any configured `base` path, e.g. `my-base-path/_app`. */ - getAppPath(): string; + getAppPath: () => string; /** * Write client assets to `dest`. * @param dest the destination folder * @returns an array of files written to `dest` */ - writeClient(dest: string): string[]; + writeClient: (dest: string) => string[]; /** * Write prerendered files to `dest`. * @param dest the destination folder * @returns an array of files written to `dest` */ - writePrerendered(dest: string): string[]; + writePrerendered: (dest: string) => string[]; /** * Write server-side code to `dest`. * @param dest the destination folder * @returns an array of files written to `dest` */ - writeServer(dest: string): string[]; + writeServer: (dest: string) => string[]; /** * Copy a file or directory. * @param from the source file or directory @@ -153,20 +153,20 @@ declare module '@sveltejs/kit' { * @param opts.replace a map of strings to replace * @returns an array of files that were copied */ - copy( + copy: ( from: string, to: string, opts?: { filter?(basename: string): boolean; replace?: Record; } - ): string[]; + ) => string[]; /** * Compress files in `directory` with gzip and brotli, where appropriate. Generates `.gz` and `.br` files alongside the originals. * @param directory The directory containing the files to be compressed */ - compress(directory: string): Promise; + compress: (directory: string) => Promise; } export interface Config { @@ -196,13 +196,13 @@ declare module '@sveltejs/kit' { * @param name the name of the cookie * @param opts the options, passed directly to `cookie.parse`. See documentation [here](https://github.com/jshttp/cookie#cookieparsestr-options) */ - get(name: string, opts?: import('cookie').CookieParseOptions): string | undefined; + get: (name: string, opts?: import('cookie').CookieParseOptions) => string | undefined; /** * Gets all cookies that were previously set with `cookies.set`, or from the request headers. * @param opts the options, passed directly to `cookie.parse`. See documentation [here](https://github.com/jshttp/cookie#cookieparsestr-options) */ - getAll(opts?: import('cookie').CookieParseOptions): Array<{ name: string; value: string }>; + getAll: (opts?: import('cookie').CookieParseOptions) => Array<{ name: string; value: string }>; /** * Sets a cookie. This will add a `set-cookie` header to the response, but also make the cookie available via `cookies.get` or `cookies.getAll` during the current request. @@ -214,11 +214,11 @@ declare module '@sveltejs/kit' { * @param value the cookie value * @param opts the options, passed directly to `cookie.serialize`. See documentation [here](https://github.com/jshttp/cookie#cookieserializename-value-options) */ - set( + set: ( name: string, value: string, opts: import('cookie').CookieSerializeOptions & { path: string } - ): void; + ) => void; /** * Deletes a cookie by setting its value to an empty string and setting the expiry date in the past. @@ -227,7 +227,7 @@ declare module '@sveltejs/kit' { * @param name the name of the cookie * @param opts the options, passed directly to `cookie.serialize`. The `path` must match the path of the cookie you want to delete. See documentation [here](https://github.com/jshttp/cookie#cookieserializename-value-options) */ - delete(name: string, opts: import('cookie').CookieSerializeOptions & { path: string }): void; + delete: (name: string, opts: import('cookie').CookieSerializeOptions & { path: string }) => void; /** * Serialize a cookie name-value pair into a `Set-Cookie` header string, but don't apply it to the response. @@ -240,11 +240,11 @@ declare module '@sveltejs/kit' { * @param value the cookie value * @param opts the options, passed directly to `cookie.serialize`. See documentation [here](https://github.com/jshttp/cookie#cookieserializename-value-options) */ - serialize( + serialize: ( name: string, value: string, opts: import('cookie').CookieSerializeOptions & { path: string } - ): string; + ) => string; } /** @@ -927,7 +927,7 @@ declare module '@sveltejs/kit' { /** * Call this to prevent the navigation from starting. */ - cancel(): void; + cancel: () => void; } /** @@ -1177,7 +1177,7 @@ declare module '@sveltejs/kit' { client: NonNullable; nodes: SSRNodeLoader[]; routes: SSRRoute[]; - matchers(): Promise>; + matchers: () => Promise>; /** A `[file]: size` map of all assets imported by server code */ server_assets: Record; };