diff --git a/.changeset/twenty-singers-fetch.md b/.changeset/twenty-singers-fetch.md new file mode 100644 index 000000000..87f3c32c6 --- /dev/null +++ b/.changeset/twenty-singers-fetch.md @@ -0,0 +1,5 @@ +--- +"@solidjs/start": minor +--- + +move the RequestEventLocals definition into the App namespace for easier end user retyping diff --git a/examples/todomvc/src/global.d.ts b/examples/todomvc/src/global.d.ts index dc6f10c22..cee6301fa 100644 --- a/examples/todomvc/src/global.d.ts +++ b/examples/todomvc/src/global.d.ts @@ -1 +1,7 @@ -/// +declare module App { + interface RequestEventLocals { + /** + * Declare your getRequestEvent().locals here + */ + } +} \ No newline at end of file diff --git a/packages/start/env.d.ts b/packages/start/env.d.ts index 7fb838fd6..14f796189 100644 --- a/packages/start/env.d.ts +++ b/packages/start/env.d.ts @@ -4,6 +4,12 @@ /* eslint-disable @typescript-eslint/consistent-type-imports */ +declare namespace App { + export interface RequestEventLocals { + [key: string | symbol]: any; + } +} + interface ImportMetaEnv extends Record<`VITE_${string}`, any>, SolidStartMetaEnv { BASE_URL: string; MODE: string; diff --git a/packages/start/src/server/index.tsx b/packages/start/src/server/index.tsx index ce14d2cd3..96c5b54d5 100644 --- a/packages/start/src/server/index.tsx +++ b/packages/start/src/server/index.tsx @@ -3,16 +3,7 @@ export { StartServer } from "./StartServer"; export { createHandler } from "./handler"; export { getServerFunctionMeta } from "./serverFunction"; export type { - DocumentComponentProps, - Asset, - HandlerOptions, - ContextMatches, - ResponseStub, - FetchEvent, - RequestEventLocals, - PageEvent, APIEvent, - APIHandler, - ServerFunctionMeta + APIHandler, Asset, ContextMatches, DocumentComponentProps, FetchEvent, HandlerOptions, PageEvent, ResponseStub, ServerFunctionMeta } from "./types"; diff --git a/packages/start/src/server/types.ts b/packages/start/src/server/types.ts index c55bb730c..ef3b568c5 100644 --- a/packages/start/src/server/types.ts +++ b/packages/start/src/server/types.ts @@ -42,16 +42,15 @@ export interface ResponseStub { statusText?: string; headers: Headers; } + export interface FetchEvent { request: Request; response: ResponseStub; clientAddress?: string; - locals: RequestEventLocals; + locals: App.RequestEventLocals; nativeEvent: HTTPEvent; } -export interface RequestEventLocals { - [key: string | symbol]: any; -} + export interface PageEvent extends RequestEvent { manifest: any; assets: any;