fix(types): keep crossws out of the devframe/types declaration graph - #369
Conversation
devframe/types (and node/auth/handler behind it) imported the crossws Peer type, so any consumer of the types entry - e.g. @vitejs/devtools/config - had to load the DOM, Bun, and Cloudflare type libs crossws's declarations require, breaking downstream skipLibCheck: false compilations (vitejs/vite CI). The WS peer escape hatch is now typed by a local structural DevframeWsPeer mirroring the crossws Peer surface, and a regression test typechecks the shipped dist/types declarations with lib ES2022 + @types/node only.
◈ PR Lens
Architecture 7 components touched across 4 lanes. Inside the changed components — 1 viewComponent view — RPC transport and type definitions Internal structural types and neutrality tests decoupling devframe from crossws Data flow No data-flow sequence changed in this PR. Drill down
|
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Problem
@vitejs/devtoolsv0.7.2 started importingdevframe/typesfrom its config surface, and vitejs/vite's strict typecheck CI (skipLibCheck: false) began failing withCannot find name 'HeadersInit',Cannot find module 'bun',Cannot find module '@cloudflare/workers-types', etc.The
devframe/typesdeclaration graph reachedcrosswsthrough two type-level imports of the WS peer type:src/types/rpc.tsimported the session types fromdevframe/rpc/transports/ws-server(whose declarations importcrosswsandcrossws/adapters/node)src/types/devframe.ts→src/node/auth/handler.tsimportedDevframeRpcConnectionfrom the same entrycrossws's own declarations require the DOM, Bun, and Cloudflare type libs, so every downstream consumer of
devframe/typesinherited that requirement.Fix
DevframeRpcConnection.peer/DevframeNodeRpcSessionMeta.peerare now typed by a local structuralDevframeWsPeerthat mirrors the transport-independent slice of crossws'sPeer(id, send, pub/sub, close, backpressure) using only ES lib types. Code needing the full crossws API can still importPeerfromcrosswsand cast, opting into its lib requirements explicitly.types/rpc.tsandnode/auth/handler.tsimport the session types fromrpc/transports/sessiondirectly, so the bundleddist/typeschunk graph no longer touches the ws-server chunk. External type imports ofdevframe/typesare now onlybirpc,cac,@standard-schema/spec, andnostics.test/types-lib-neutral.test.ts) typechecks the shippeddist/types/index.d.mtswithlib: ES2022+@types/nodeonly andskipLibCheck: false— the exact failure mode of the Vite CI (verified it reproduces theHeadersInit/bunerrors when pointed at a crossws-importing entry).Note on API surface
tsnapi flags the
peerfield as narrowed (crosswsPeer→ structuralDevframeWsPeer); the snapshot was updated withTSNAPI_ALLOW_BREAKING=1. A consumer readingpeer.request/peer.websockettypes-first now needs an explicit crossws cast. The entries that genuinely wrap crossws (rpc/transports/ws-server,ws-bun,ws-deno) keep their real crossws types.This PR was created with the help of an agent.