Skip to content

Commit ab1f90d

Browse files
authored
Merge branch 'main' into fix-2229-await-stream-shell-payload
2 parents 2b3bf6d + e26cef0 commit ab1f90d

5 files changed

Lines changed: 23 additions & 7 deletions

File tree

‎.changeset/olive-apes-clap.md‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@solidjs/start": patch
3+
---
4+
5+
Fix TS2883/TS2742 when emitting declarations for `entry-server.tsx`. `createHandler` now returns `StartHandler`, a type owned by `@solidjs/start`, instead of h3's `H3`, so the inferred type of `export default createHandler(...)` no longer has to be named through a nested `node_modules/@solidjs/start/node_modules/h3` path.

‎packages/start/src/server/handler.ts‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import { decorateHandler, decorateMiddleware } from "./fetchEvent.ts";
1717
import { getSsrManifest } from "./manifest/ssr-manifest.ts";
1818
import { matchAPIRoute } from "./routes.ts";
1919
import { handleServerFunction } from "../fns/handler.ts";
20-
import type { APIEvent, FetchEvent, HandlerOptions, PageEvent } from "./types.ts";
20+
import type { APIEvent, FetchEvent, HandlerOptions, PageEvent, StartHandler } from "./types.ts";
2121
import { getExpectedRedirectStatus } from "./util.ts";
2222
import { toWebReadableStream } from "./web-stream.ts";
2323
import { stripPathBase } from "./strip-path-base.ts";
@@ -29,7 +29,7 @@ export function createBaseHandler(
2929
fn: (context: PageEvent) => JSX.Element,
3030
options: HandlerOptions | ((context: PageEvent) => HandlerOptions | Promise<HandlerOptions>) = {},
3131
routerLoad?: (event: FetchEvent) => Promise<void>,
32-
): H3 {
32+
): StartHandler {
3333
const handler = defineHandler({
3434
middleware: middleware.length ? middleware.map(decorateMiddleware) : undefined,
3535
handler: decorateHandler(async (e: H3Event) => {
@@ -134,7 +134,7 @@ export function createHandler(
134134
fn: (context: PageEvent) => JSX.Element,
135135
options: HandlerOptions | ((context: PageEvent) => HandlerOptions | Promise<HandlerOptions>) = {},
136136
routerLoad?: (event: FetchEvent) => Promise<void>,
137-
): H3 {
137+
): StartHandler {
138138
return createBaseHandler(createPageEvent, fn, options, routerLoad);
139139
}
140140

‎packages/start/src/server/index.tsx‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ export type {
1515
PageEvent,
1616
ResponseStub,
1717
ServerFunctionMeta,
18+
StartHandler,
1819
} from "./types.ts";
1920

2021
/**

‎packages/start/src/server/spa/handler.ts‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
import type { H3 } from "h3/generic";
21
import type { JSX } from "solid-js";
32

43
import { createBaseHandler } from "../handler.ts";
54
import { getSsrManifest } from "../manifest/ssr-manifest.ts";
6-
import type { FetchEvent, HandlerOptions, PageEvent } from "../types.ts";
5+
import type { FetchEvent, HandlerOptions, PageEvent, StartHandler } from "../types.ts";
76

87
/**
98
*
@@ -13,7 +12,7 @@ export function createHandler(
1312
fn: (context: PageEvent) => JSX.Element,
1413
options?: HandlerOptions | ((context: PageEvent) => HandlerOptions),
1514
routerLoad?: (event: FetchEvent) => Promise<void>,
16-
): H3 {
15+
): StartHandler {
1716
return createBaseHandler(createPageEvent, fn, options, routerLoad);
1817
}
1918

‎packages/start/src/server/types.ts‎

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,20 @@
1-
import type { H3Event } from "h3";
1+
import type { H3, H3Event } from "h3";
22
import type { JSX } from "solid-js";
33
import type { RequestEvent } from "solid-js/web";
44

55
// export const FETCH_EVENT = "$FETCH";
66

7+
/**
8+
* The h3 app instance returned by `createHandler`.
9+
*
10+
* Structurally identical to h3's `H3`, but declared here so that `export default
11+
* createHandler(...)` in `entry-server.tsx` can be named through `@solidjs/start`.
12+
* Referring to `H3` directly makes TypeScript emit a reference to h3's internal
13+
* `H3$1` class, which is not portable when h3 is nested inside
14+
* `node_modules/@solidjs/start/node_modules` (TS2742 / TS2883).
15+
*/
16+
export interface StartHandler extends H3 {}
17+
718
export type DocumentComponentProps = {
819
assets?: JSX.Element;
920
scripts: JSX.Element;

0 commit comments

Comments
 (0)