Skip to content
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
5 changes: 5 additions & 0 deletions .changeset/olive-apes-clap.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@solidjs/start": patch
---

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.
6 changes: 3 additions & 3 deletions packages/start/src/server/handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { decorateHandler, decorateMiddleware } from "./fetchEvent.ts";
import { getSsrManifest } from "./manifest/ssr-manifest.ts";
import { matchAPIRoute } from "./routes.ts";
import { handleServerFunction } from "../fns/handler.ts";
import type { APIEvent, FetchEvent, HandlerOptions, PageEvent } from "./types.ts";
import type { APIEvent, FetchEvent, HandlerOptions, PageEvent, StartHandler } from "./types.ts";
import { getExpectedRedirectStatus } from "./util.ts";
import { toWebReadableStream } from "./web-stream.ts";
import { stripPathBase } from "./strip-path-base.ts";
Expand All @@ -22,7 +22,7 @@ export function createBaseHandler(
fn: (context: PageEvent) => JSX.Element,
options: HandlerOptions | ((context: PageEvent) => HandlerOptions | Promise<HandlerOptions>) = {},
routerLoad?: (event: FetchEvent) => Promise<void>,
): H3 {
): StartHandler {
const handler = defineHandler({
middleware: middleware.length ? middleware.map(decorateMiddleware) : undefined,
handler: decorateHandler(async (e: H3Event) => {
Expand Down Expand Up @@ -138,7 +138,7 @@ export function createHandler(
fn: (context: PageEvent) => JSX.Element,
options: HandlerOptions | ((context: PageEvent) => HandlerOptions | Promise<HandlerOptions>) = {},
routerLoad?: (event: FetchEvent) => Promise<void>,
): H3 {
): StartHandler {
return createBaseHandler(createPageEvent, fn, options, routerLoad);
}

Expand Down
1 change: 1 addition & 0 deletions packages/start/src/server/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export type {
PageEvent,
ResponseStub,
ServerFunctionMeta,
StartHandler,
} from "./types.ts";

/**
Expand Down
5 changes: 2 additions & 3 deletions packages/start/src/server/spa/handler.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import type { H3 } from "h3/generic";
import type { JSX } from "solid-js";

import { createBaseHandler } from "../handler.ts";
import { getSsrManifest } from "../manifest/ssr-manifest.ts";
import type { FetchEvent, HandlerOptions, PageEvent } from "../types.ts";
import type { FetchEvent, HandlerOptions, PageEvent, StartHandler } from "../types.ts";

/**
*
Expand All @@ -13,7 +12,7 @@ export function createHandler(
fn: (context: PageEvent) => JSX.Element,
options?: HandlerOptions | ((context: PageEvent) => HandlerOptions),
routerLoad?: (event: FetchEvent) => Promise<void>,
): H3 {
): StartHandler {
return createBaseHandler(createPageEvent, fn, options, routerLoad);
}

Expand Down
13 changes: 12 additions & 1 deletion packages/start/src/server/types.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,20 @@
import type { H3Event } from "h3";
import type { H3, H3Event } from "h3";
import type { JSX } from "solid-js";
import type { RequestEvent } from "solid-js/web";

// export const FETCH_EVENT = "$FETCH";

/**
* The h3 app instance returned by `createHandler`.
*
* Structurally identical to h3's `H3`, but declared here so that `export default
* createHandler(...)` in `entry-server.tsx` can be named through `@solidjs/start`.
* Referring to `H3` directly makes TypeScript emit a reference to h3's internal
* `H3$1` class, which is not portable when h3 is nested inside
* `node_modules/@solidjs/start/node_modules` (TS2742 / TS2883).
*/
export interface StartHandler extends H3 {}

export type DocumentComponentProps = {
assets?: JSX.Element;
scripts: JSX.Element;
Expand Down
Loading