From 2302a9e6e5f9d657009af7d5883c97cba5bfc221 Mon Sep 17 00:00:00 2001 From: Ben McCann <322311+benmccann@users.noreply.github.com> Date: Thu, 7 Oct 2021 16:26:55 -0700 Subject: [PATCH] [fix] improve type of `init` (#2544) --- .changeset/five-bags-prove.md | 5 +++++ packages/kit/src/core/preview/index.js | 2 +- packages/kit/types/app.d.ts | 9 +-------- packages/kit/types/internal.d.ts | 9 +++++++++ 4 files changed, 16 insertions(+), 9 deletions(-) create mode 100644 .changeset/five-bags-prove.md diff --git a/.changeset/five-bags-prove.md b/.changeset/five-bags-prove.md new file mode 100644 index 000000000000..07fd2af940b5 --- /dev/null +++ b/.changeset/five-bags-prove.md @@ -0,0 +1,5 @@ +--- +'@sveltejs/kit': patch +--- + +[fix] improve type of `init` diff --git a/packages/kit/src/core/preview/index.js b/packages/kit/src/core/preview/index.js index c4d7a62bd034..5b1568ecc78b 100644 --- a/packages/kit/src/core/preview/index.js +++ b/packages/kit/src/core/preview/index.js @@ -35,7 +35,7 @@ export async function preview({ const app_file = resolve(cwd, `${SVELTE_KIT}/output/server/app.js`); - /** @type {import('types/app').App} */ + /** @type {import('types/internal').App} */ const app = await import(pathToFileURL(app_file).href); /** @type {import('sirv').RequestHandler} */ diff --git a/packages/kit/types/app.d.ts b/packages/kit/types/app.d.ts index 467c8b57369b..0fbe02bd9d7f 100644 --- a/packages/kit/types/app.d.ts +++ b/packages/kit/types/app.d.ts @@ -2,14 +2,7 @@ import { ReadOnlyFormData, RequestHeaders } from './helper'; import { ServerResponse } from './hooks'; export interface App { - init(options?: { - paths: { - base: string; - assets: string; - }; - prerendering: boolean; - read(file: string): Buffer; - }): void; + init(): void; render(incoming: IncomingRequest): Promise; } diff --git a/packages/kit/types/internal.d.ts b/packages/kit/types/internal.d.ts index ab2977dc2f47..8f9aa5105eb6 100644 --- a/packages/kit/types/internal.d.ts +++ b/packages/kit/types/internal.d.ts @@ -19,6 +19,15 @@ export interface PrerenderOptions { } export interface App extends PublicApp { + init(options?: { + paths: { + base: string; + assets: string; + }; + prerendering: boolean; + read(file: string): Buffer; + }): void; + render( incoming: IncomingRequest, options?: {