Skip to content

fix: specify return type in DTS declarations #14054

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 1 addition & 7 deletions packages/kit/scripts/generate-dts.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { createBundle } from 'dts-buddy';
import { readFileSync, writeFileSync } from 'node:fs';
import { readFileSync } from 'node:fs';

await createBundle({
output: 'types/index.d.ts',
Expand Down Expand Up @@ -28,9 +28,3 @@ if (types.includes('__sveltekit/')) {
types
);
}

// this is hacky as all hell but it gets the tests passing. might be a bug in dts-buddy?
// prettier-ignore
writeFileSync('./types/index.d.ts', types.replace("declare module '$app/server' {", `declare module '$app/server' {
// @ts-ignore
import { LayoutParams as AppLayoutParams, RouteId as AppRouteId } from '$app/types'`));
1 change: 1 addition & 0 deletions packages/kit/src/runtime/app/server/event.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import('node:async_hooks')
*
* In environments without [`AsyncLocalStorage`](https://nodejs.org/api/async_context.html#class-asynclocalstorage), this must be called synchronously (i.e. not after an `await`).
* @since 2.20.0
* @returns {RequestEvent}
*/
export function getRequestEvent() {
const event = request_event ?? als?.getStore();
Expand Down
6 changes: 2 additions & 4 deletions packages/kit/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2616,8 +2616,6 @@ declare module '$app/paths' {
}

declare module '$app/server' {
// @ts-ignore
import { LayoutParams as AppLayoutParams, RouteId as AppRouteId } from '$app/types'
import type { RequestEvent, RemoteCommand, RemoteForm, RemotePrerenderFunction, RemoteQueryFunction } from '@sveltejs/kit';
import type { StandardSchemaV1 } from '@standard-schema/spec';
/**
Expand All @@ -2638,8 +2636,8 @@ declare module '$app/server' {
*
* In environments without [`AsyncLocalStorage`](https://nodejs.org/api/async_context.html#class-asynclocalstorage), this must be called synchronously (i.e. not after an `await`).
* @since 2.20.0
*/
export function getRequestEvent(): RequestEvent<AppLayoutParams<"/">, any>;
* */
export function getRequestEvent(): RequestEvent;
/**
* Creates a remote command. When called from the browser, the function will be invoked on the server via a `fetch` call.
*
Expand Down
Loading