fix(node): export the structural RpcFunctionsHost type from devframe/node#112
Merged
Conversation
The devframe/node entry exported the implementation class RpcFunctionsHost, whose @internal members (_rpcGroup, _asyncStorage, _emitSessionDisconnected) leaked into the public type. This diverged from DevframeNodeContext.rpc and the devframe main entry, which use the structural RpcFunctionsHost type, so casting ctx.rpc as RpcFunctionsHost (imported from devframe/node) failed with TS2352 on devframe >=0.7.4. Rename the implementation to RpcFunctionsHostImpl (kept internal) and re-export the structural RpcFunctionsHost type from devframe/node so it matches ctx.rpc.
✅ Deploy Preview for devfra ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
Vite DevTools' 0.7.4 upgrade (vitejs/devtools#435) broke on
context.rpc as RpcFunctionsHost.DevframeNodeContext.rpcis typed as the structuralRpcFunctionsHost(exported from thedevframemain entry), butdevframe/nodeexported the implementation classRpcFunctionsHost, which additionally declares the@internalmembers_rpcGroup,_asyncStorage, and_emitSessionDisconnected.The two
RpcFunctionsHostexports had diverged, leaking the implementation's internal members into a public type. Any consumer importingRpcFunctionsHostfromdevframe/nodeand castingcontext.rpcto it hit:This worked in 0.7.3.
What
RpcFunctionsHost→RpcFunctionsHostImpl(kept internal — no longer re-exported fromdevframe/node).RpcFunctionsHosttype fromdevframe/node(the same type thedevframemain entry andDevframeNodeContext.rpcalready use), soimport { RpcFunctionsHost } from 'devframe/node'resolves to a type structurally compatible withcontext.rpc.createHostContextstill returnscontext.rpctyped as that structuralRpcFunctionsHost.context.ts,server.ts,auth/revoke.ts, tests) to the impl class where impl-only members are touched.DevframeNodeContext['rpc']equals the exportedRpcFunctionsHost, plus@ts-expect-errorguards that the@internalmembers stay off the public type (enforced bytsc --noEmit).devframe/nodeAPI snapshot.devframe/devframe/typesmodule specifiers (matching@devframes/hub), since augmenting a renamed re-export alias no longer merges after the interfaces moved into a bundled chunk in 0.7.4.Acceptance
ctx.rpc as RpcFunctionsHost(imported from eitherdevframeordevframe/node) type-checks.@internalmembers appear on the publicRpcFunctionsHosttype.DevframeNodeContext['rpc']is assignable to the exportedRpcFunctionsHost.Verified with
pnpm lint,pnpm typecheck,pnpm build, andvitest(739 tests pass).This PR was created with the help of an agent.