From ab5eb66743b165ce87ef32712453e4421621256f Mon Sep 17 00:00:00 2001 From: AirBorne04 Date: Sun, 5 May 2024 14:00:22 +0300 Subject: [PATCH 1/5] refactor RequestEventLocals into its own namespace for user retyping --- packages/start/env.d.ts | 5 +++++ packages/start/src/server/index.tsx | 11 +---------- packages/start/src/server/types.ts | 7 +++---- 3 files changed, 9 insertions(+), 14 deletions(-) diff --git a/packages/start/env.d.ts b/packages/start/env.d.ts index 58d5f5377..4a3070ccf 100644 --- a/packages/start/env.d.ts +++ b/packages/start/env.d.ts @@ -4,6 +4,11 @@ /* eslint-disable @typescript-eslint/consistent-type-imports */ +declare namespace App { + // eslint-disable-next-line @typescript-eslint/no-empty-interface + export interface RequestEventLocals { } +} + 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; From b09d26cd2c6d510fe020e5625349e87191ddb026 Mon Sep 17 00:00:00 2001 From: AirBorne04 Date: Sun, 5 May 2024 14:04:11 +0300 Subject: [PATCH 2/5] adding change set --- .changeset/twenty-singers-fetch.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/twenty-singers-fetch.md diff --git a/.changeset/twenty-singers-fetch.md b/.changeset/twenty-singers-fetch.md new file mode 100644 index 000000000..12255eff4 --- /dev/null +++ b/.changeset/twenty-singers-fetch.md @@ -0,0 +1,5 @@ +--- +"@solidjs/start": patch +--- + +move the RequestEventLocals definition into the App namespace for easier end user retyping From 07b44a6fdcafdfecb3740cc0e3e91ff4d64a95ee Mon Sep 17 00:00:00 2001 From: AirBorne04 Date: Sun, 5 May 2024 14:21:48 +0300 Subject: [PATCH 3/5] add placeholder for generic key value to RequestEventLocals --- packages/start/env.d.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/start/env.d.ts b/packages/start/env.d.ts index 4a3070ccf..146d11165 100644 --- a/packages/start/env.d.ts +++ b/packages/start/env.d.ts @@ -5,8 +5,9 @@ /* eslint-disable @typescript-eslint/consistent-type-imports */ declare namespace App { - // eslint-disable-next-line @typescript-eslint/no-empty-interface - export interface RequestEventLocals { } + export interface RequestEventLocals { + [key: string | symbol]: any; + } } interface ImportMetaEnv extends Record<`VITE_${string}`, any>, SolidStartMetaEnv { From 13e0c2ea8e9fc7a6d83d6939444d96b68350cde5 Mon Sep 17 00:00:00 2001 From: AirBorne04 Date: Fri, 21 Jun 2024 09:35:19 +0200 Subject: [PATCH 4/5] adding example declaration to the todommvc example --- examples/todomvc/src/global.d.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) 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 From bf5a65fbd8f5bec352595874538b2722116afe52 Mon Sep 17 00:00:00 2001 From: Daniel Date: Thu, 4 Jul 2024 09:18:37 +0200 Subject: [PATCH 5/5] Update changeset to minor --- .changeset/twenty-singers-fetch.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.changeset/twenty-singers-fetch.md b/.changeset/twenty-singers-fetch.md index 12255eff4..87f3c32c6 100644 --- a/.changeset/twenty-singers-fetch.md +++ b/.changeset/twenty-singers-fetch.md @@ -1,5 +1,5 @@ --- -"@solidjs/start": patch +"@solidjs/start": minor --- move the RequestEventLocals definition into the App namespace for easier end user retyping