Skip to content

fix(web): import the types the server-functions declarations reference - #3103

Merged
ryansolid merged 3 commits into
solidjs:nextfrom
brenelz:fix/server-function-types-any
Aug 31, 2026
Merged

fix(web): import the types the server-functions declarations reference#3103
ryansolid merged 3 commits into
solidjs:nextfrom
brenelz:fix/server-function-types-any

Conversation

@brenelz

@brenelz brenelz commented Aug 29, 2026

Copy link
Copy Markdown
Contributor

Problem

Every GET/live/createServerReference-wrapped server function types as any for consumers of the published @solidjs/web package. Downstream this silently kills inference through anything built on server functions — e.g. a GET-wrapped queryFn makes TanStack Query's data come out any.

Cause

server-functions/src/client.ts and server.ts only re-export ServerFunction and ServerFunctionMetadata (export type { ... } from "./shared.js"), which creates no local binding — yet GET/live/createServerReference and several interfaces reference those names in annotations. Both files are // @ts-nocheck, so nothing flagged the dangling names; declaration emit shipped them unresolved:

types/server-functions/client.d.ts(161,82): error TS2304: Cannot find name 'ServerFunction'.

(visible with skipLibCheck: false). Under the usual skipLibCheck: true, TypeScript treats the unresolved reference as an error type, which behaves like any at 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 emitted types/ and types-cjs/ declarations carry the import and tsc --skipLibCheck false no longer reports TS2304 in them; in a consuming app, GET-wrapped functions infer their real return types again (checked against the solid-templates fullstack-tanstack template, where useQuery(...).data went from any back to the server function's return type).

🤖 Generated with Claude Code

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-bot

changeset-bot Bot commented Aug 29, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 4aa25e9

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 11 packages
Name Type
@solidjs/web Patch
@solidjs/babel-plugin Patch
@solidjs/element Patch
@solidjs/h Patch
@solidjs/html Patch
test-integration Patch
solid-js Patch
@solidjs/compiler Patch
@solidjs/universal Patch
@solidjs/signals Patch
@solidjs/diagnostics Patch

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

@codspeed-hq

codspeed-hq Bot commented Aug 29, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 136 untouched benchmarks
⏩ 132 skipped benchmarks1


Comparing brenelz:fix/server-function-types-any (4aa25e9) with next (5230666)

Open in CodSpeed

Footnotes

  1. 132 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

ryansolid and others added 2 commits August 30, 2026 00:32
…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>
@ryansolid

Copy link
Copy Markdown
Member

Good fix — the dangling references were real, and resolving them surfaced a latent declaration bug your CI run caught: the client live() reference was typed as returning Promise<LiveSource<T>> (via ServerFunction's call signature), but it actually hands back the reconnecting iterable synchronously. While the declaration chain collapsed to any, nothing noticed; the moment your fix made the types real, web's test-types failed on the live-retry spec.

I pushed 4aa25e9 onto this branch typing the client reference truthfully (LiveServerFunction — sync call, same id/url identity). Isomorphic consumers are unaffected since they await the call and awaiting the plain iterable is identity. CI should be green now; thanks for the PR — it hardened more than it set out to.

@ryansolid
ryansolid merged commit fe4bfa0 into solidjs:next Aug 31, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants