diff --git a/.changeset/shaggy-walls-wave.md b/.changeset/shaggy-walls-wave.md new file mode 100644 index 000000000000..fa29a15129d3 --- /dev/null +++ b/.changeset/shaggy-walls-wave.md @@ -0,0 +1,6 @@ +--- +"@sveltejs/adapter-vercel": patch +"@sveltejs/adapter-node": patch +--- + +fix: include ambient type declarations diff --git a/packages/adapter-cloudflare-workers/placeholders.d.ts b/packages/adapter-cloudflare-workers/internal.d.ts similarity index 100% rename from packages/adapter-cloudflare-workers/placeholders.d.ts rename to packages/adapter-cloudflare-workers/internal.d.ts diff --git a/packages/adapter-cloudflare-workers/tsconfig.json b/packages/adapter-cloudflare-workers/tsconfig.json index 1cb740d0614c..e4cdc5abd1b7 100644 --- a/packages/adapter-cloudflare-workers/tsconfig.json +++ b/packages/adapter-cloudflare-workers/tsconfig.json @@ -13,5 +13,5 @@ "@sveltejs/kit": ["../kit/types/index"] } }, - "include": ["**/*.js", "placeholders.d.ts"] + "include": ["**/*.js", "internal.d.ts"] } diff --git a/packages/adapter-cloudflare/placeholders.d.ts b/packages/adapter-cloudflare/internal.d.ts similarity index 100% rename from packages/adapter-cloudflare/placeholders.d.ts rename to packages/adapter-cloudflare/internal.d.ts diff --git a/packages/adapter-cloudflare/tsconfig.json b/packages/adapter-cloudflare/tsconfig.json index 7ebf502ced9e..b258035a3555 100644 --- a/packages/adapter-cloudflare/tsconfig.json +++ b/packages/adapter-cloudflare/tsconfig.json @@ -12,5 +12,5 @@ "@sveltejs/kit": ["../kit/types/index"] } }, - "include": ["index.js", "placeholders.d.ts", "src/worker.js"] + "include": ["index.js", "internal.d.ts", "src/worker.js"] } diff --git a/packages/adapter-netlify/index.d.ts b/packages/adapter-netlify/index.d.ts index aef282740b2f..6bdc8db882dc 100644 --- a/packages/adapter-netlify/index.d.ts +++ b/packages/adapter-netlify/index.d.ts @@ -1,4 +1,3 @@ import { Adapter } from '@sveltejs/kit'; -import './ambient.js'; export default function plugin(opts?: { split?: boolean; edge?: boolean }): Adapter; diff --git a/packages/adapter-netlify/ambient.d.ts b/packages/adapter-netlify/internal.d.ts similarity index 100% rename from packages/adapter-netlify/ambient.d.ts rename to packages/adapter-netlify/internal.d.ts diff --git a/packages/adapter-netlify/tsconfig.json b/packages/adapter-netlify/tsconfig.json index 1eeee8b0847d..cdc2d9ec2a62 100644 --- a/packages/adapter-netlify/tsconfig.json +++ b/packages/adapter-netlify/tsconfig.json @@ -15,5 +15,5 @@ "@sveltejs/kit": ["../kit/types/index"] } }, - "include": ["*.js", "src/**/*.js", "ambient.d.ts"] + "include": ["*.js", "src/**/*.js", "internal.d.ts"] } diff --git a/packages/adapter-node/ambient.d.ts b/packages/adapter-node/ambient.d.ts index acdc19bb2587..7fbdd5adb583 100644 --- a/packages/adapter-node/ambient.d.ts +++ b/packages/adapter-node/ambient.d.ts @@ -1,28 +1,12 @@ -declare module 'ENV' { - export function env(key: string, fallback?: any): string; -} - -declare module 'HANDLER' { - export const handler: import('polka').Middleware; -} - -declare module 'MANIFEST' { - import { SSRManifest } from '@sveltejs/kit'; - - export const base: string; - export const manifest: SSRManifest; - export const prerendered: Set; -} - -declare module 'SERVER' { - export { Server } from '@sveltejs/kit'; -} - -declare namespace App { - export interface Platform { - /** - * The original Node request object (https://nodejs.org/api/http.html#class-httpincomingmessage) - */ - req: import('http').IncomingMessage; +import http from 'node:http'; + +declare global { + namespace App { + export interface Platform { + /** + * The original Node request object (https://nodejs.org/api/http.html#class-httpincomingmessage) + */ + req: http.IncomingMessage; + } } } diff --git a/packages/adapter-node/internal.d.ts b/packages/adapter-node/internal.d.ts new file mode 100644 index 000000000000..fed0584d1851 --- /dev/null +++ b/packages/adapter-node/internal.d.ts @@ -0,0 +1,19 @@ +declare module 'ENV' { + export function env(key: string, fallback?: any): string; +} + +declare module 'HANDLER' { + export const handler: import('polka').Middleware; +} + +declare module 'MANIFEST' { + import { SSRManifest } from '@sveltejs/kit'; + + export const base: string; + export const manifest: SSRManifest; + export const prerendered: Set; +} + +declare module 'SERVER' { + export { Server } from '@sveltejs/kit'; +} diff --git a/packages/adapter-node/package.json b/packages/adapter-node/package.json index 3d66d62c86a0..6f9fe38f5c2c 100644 --- a/packages/adapter-node/package.json +++ b/packages/adapter-node/package.json @@ -29,7 +29,8 @@ "files": [ "files", "index.js", - "index.d.ts" + "index.d.ts", + "ambient.d.ts" ], "scripts": { "dev": "node -e \"fs.rmSync('files', { force: true, recursive: true })\" && rollup -cw", diff --git a/packages/adapter-node/tsconfig.json b/packages/adapter-node/tsconfig.json index 17a612157ece..790cb0a51563 100644 --- a/packages/adapter-node/tsconfig.json +++ b/packages/adapter-node/tsconfig.json @@ -13,5 +13,5 @@ "@sveltejs/kit": ["../kit/types/index"] } }, - "include": ["index.js", "src/**/*.js", "ambient.d.ts"] + "include": ["index.js", "src/**/*.js", "internal.d.ts"] } diff --git a/packages/adapter-vercel/package.json b/packages/adapter-vercel/package.json index 4e43e02401a6..43394dd6d10e 100644 --- a/packages/adapter-vercel/package.json +++ b/packages/adapter-vercel/package.json @@ -30,7 +30,8 @@ "files", "index.js", "utils.js", - "index.d.ts" + "index.d.ts", + "ambient.d.ts" ], "scripts": { "lint": "prettier --check .",