Effect CommunityEC
Effect Community2y ago
4 replies
tobi88

Challenges in Implementing Custom Transport for Effect/RPC with Inspiration from rpc-http

I have been trying to implement a custom transport for effect/rpc and took some inspiration from rpc-http. Managed to get it to work, but managing resolver types is still a bit of struggle. The declaration here seems to be wrong (also not sure why the implementation returns as any): https://github.com/Effect-TS/effect/blob/d7688c0c72717fe7876c871567f6946dabfc0546/packages/rpc-http/src/HttpResolver.ts#L68

export const makeClient = <R extends Router.Router<any, any>>(
  baseUrl: string
): Serializable.SerializableWithResult.Context<Router.Router.Request<R>> extends never ?
  "HttpResolver.makeClient: request context is not `never`"
  : Resolver.Client<
    RequestResolver.RequestResolver<
      Rpc.Request<Router.Router.Request<R>>
    >
  > =>...


The conditional return type checks if Serializable.SerializableWithResult.Context<Router.Router.Request<R>> extends never, if it does the return type is the literal: "HttpResolver.makeClient: request context is not never". I guess it should be the other way round.
Was this page helpful?