Skip to content

RpcTarget properties resolved in runtime is not what the type suggests #55

@EqualMa

Description

@EqualMa
import { RpcTarget, RpcStub, newMessagePortRpcSession } from "capnweb";

interface MyApi extends RpcTarget {
  myProp: number;
}

class MyApiImpl extends RpcTarget implements MyApi {
  myProp: number = 1;
}

const { port1, port2 } = new MessageChannel();

using stub: RpcStub<MyApi> = newMessagePortRpcSession<MyApi>(port1);

using _sessionFrom2To1 = newMessagePortRpcSession(port2, new MyApiImpl());

const myProp: number = await stub.myProp;

console.log(myProp);
// Expect: 1
//    Got: undefined

const myPropStr: string = await stub.myProp.toString();
console.log(myPropStr);
// Expect: "1"
//    Got: [object Function]

You can test this by running deno test.ts or node test.ts with Node >= 24

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions