Skip to content

Commit 1ace001

Browse files
43081jeltigerchino
andauthored
fix: specify return type in DTS declarations (#14054)
If we specify the return type in the JSDoc for `getRequestEvent`, the DTS emit corrects itself and no longer pulls in a missing symbol. Maybe this means we don't need the generate hack? Co-authored-by: Chew Tee Ming <[email protected]>
1 parent 81624e0 commit 1ace001

File tree

3 files changed

+4
-11
lines changed

3 files changed

+4
-11
lines changed

packages/kit/scripts/generate-dts.js

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { createBundle } from 'dts-buddy';
2-
import { readFileSync, writeFileSync } from 'node:fs';
2+
import { readFileSync } from 'node:fs';
33

44
await createBundle({
55
output: 'types/index.d.ts',
@@ -28,9 +28,3 @@ if (types.includes('__sveltekit/')) {
2828
types
2929
);
3030
}
31-
32-
// this is hacky as all hell but it gets the tests passing. might be a bug in dts-buddy?
33-
// prettier-ignore
34-
writeFileSync('./types/index.d.ts', types.replace("declare module '$app/server' {", `declare module '$app/server' {
35-
// @ts-ignore
36-
import { LayoutParams as AppLayoutParams, RouteId as AppRouteId } from '$app/types'`));

packages/kit/src/runtime/app/server/event.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import('node:async_hooks')
1919
*
2020
* In environments without [`AsyncLocalStorage`](https://nodejs.org/api/async_context.html#class-asynclocalstorage), this must be called synchronously (i.e. not after an `await`).
2121
* @since 2.20.0
22+
* @returns {RequestEvent}
2223
*/
2324
export function getRequestEvent() {
2425
const event = request_event ?? als?.getStore();

packages/kit/types/index.d.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2616,8 +2616,6 @@ declare module '$app/paths' {
26162616
}
26172617

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

0 commit comments

Comments
 (0)