fix(web): import the types the server-functions declarations reference - #3103
Conversation
client.ts and server.ts only re-exported ServerFunction and
ServerFunctionMetadata (export type { ... } from), which creates no local
binding, while GET/live/createServerReference and several interfaces
reference them in annotations. With @ts-nocheck in both files nothing
flagged the dangling names, so declaration emit shipped them unresolved
and skipLibCheck turned every server function reference into a silent
any for consumers (a GET-wrapped queryFn typed its data as any).
🦋 Changeset detectedLatest commit: 4aa25e9 The changes in this PR will be included in the next version bump. This PR includes changesets to release 11 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Merging this PR will not alter performance
Comparing Footnotes
|
…sly — type it that way live(fn)(...) hands back the reconnecting iterable itself (the transport connects lazily on the first pull); only the server half's in-process call is async. The old declaration routed through ServerFunction, whose call signature promises Promise<T> — a mismatch invisible while the dangling declaration references this PR fixes kept the whole chain collapsed to any, and a type error the moment they resolve (the web test-types failure on this PR's CI). Isomorphic consumers still await the call; awaiting the client's plain iterable is identity. Co-authored-by: Cursor <cursoragent@cursor.com>
|
Good fix — the dangling references were real, and resolving them surfaced a latent declaration bug your CI run caught: the client I pushed 4aa25e9 onto this branch typing the client reference truthfully ( |
Problem
Every
GET/live/createServerReference-wrapped server function types asanyfor consumers of the published@solidjs/webpackage. Downstream this silently kills inference through anything built on server functions — e.g. aGET-wrappedqueryFnmakes TanStack Query'sdatacome outany.Cause
server-functions/src/client.tsandserver.tsonly re-exportServerFunctionandServerFunctionMetadata(export type { ... } from "./shared.js"), which creates no local binding — yetGET/live/createServerReferenceand several interfaces reference those names in annotations. Both files are// @ts-nocheck, so nothing flagged the dangling names; declaration emit shipped them unresolved:(visible with
skipLibCheck: false). Under the usualskipLibCheck: true, TypeScript treats the unresolved reference as an error type, which behaves likeanyat every call site.Fix
Add local
import type { ServerFunction, ServerFunctionMetadata } from "./shared.js"to both files, with a comment on why the re-export alone isn't enough. Types-only — no runtime change.Verified: after
pnpm run types, the emittedtypes/andtypes-cjs/declarations carry the import andtsc --skipLibCheck falseno longer reports TS2304 in them; in a consuming app,GET-wrapped functions infer their real return types again (checked against the solid-templatesfullstack-tanstacktemplate, whereuseQuery(...).datawent fromanyback to the server function's return type).🤖 Generated with Claude Code