Skip to content

Commit

Permalink
fix: correctly include ambient types from vercel/node adapter (#12088)
Browse files Browse the repository at this point in the history
closes #12433
  • Loading branch information
eltigerchino authored Jan 17, 2025
1 parent 6774ebc commit 9bea757
Show file tree
Hide file tree
Showing 13 changed files with 43 additions and 33 deletions.
6 changes: 6 additions & 0 deletions .changeset/shaggy-walls-wave.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@sveltejs/adapter-vercel": patch
"@sveltejs/adapter-node": patch
---

fix: include ambient type declarations
2 changes: 1 addition & 1 deletion packages/adapter-cloudflare-workers/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@
"@sveltejs/kit": ["../kit/types/index"]
}
},
"include": ["**/*.js", "placeholders.d.ts"]
"include": ["**/*.js", "internal.d.ts"]
}
File renamed without changes.
2 changes: 1 addition & 1 deletion packages/adapter-cloudflare/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
}
1 change: 0 additions & 1 deletion packages/adapter-netlify/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { Adapter } from '@sveltejs/kit';
import './ambient.js';

export default function plugin(opts?: { split?: boolean; edge?: boolean }): Adapter;
File renamed without changes.
2 changes: 1 addition & 1 deletion packages/adapter-netlify/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@
"@sveltejs/kit": ["../kit/types/index"]
}
},
"include": ["*.js", "src/**/*.js", "ambient.d.ts"]
"include": ["*.js", "src/**/*.js", "internal.d.ts"]
}
36 changes: 10 additions & 26 deletions packages/adapter-node/ambient.d.ts
Original file line number Diff line number Diff line change
@@ -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<string>;
}

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;
}
}
}
19 changes: 19 additions & 0 deletions packages/adapter-node/internal.d.ts
Original file line number Diff line number Diff line change
@@ -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<string>;
}

declare module 'SERVER' {
export { Server } from '@sveltejs/kit';
}
3 changes: 2 additions & 1 deletion packages/adapter-node/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion packages/adapter-node/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
}
3 changes: 2 additions & 1 deletion packages/adapter-vercel/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@
"files",
"index.js",
"utils.js",
"index.d.ts"
"index.d.ts",
"ambient.d.ts"
],
"scripts": {
"lint": "prettier --check .",
Expand Down

0 comments on commit 9bea757

Please sign in to comment.