Then that means we have to define the interface twice: once in TypeScript and another in Zod?
(I do wish it could be the other way, though: Write only TypeScript, get runtime checks automatically.)
// Shared interface declaration:
interface MyApi {
hello(name: string): Promise<string>;
}
// On the client:
let api: RpcStub<MyApi> = newWebSocketRpcSession("wss://example.com/api");
// On the server:
class MyApiServer extends RpcTarget implements MyApi {
hello(name) {
return `Hello, ${name}!`
}
}But my expectation is you'd use Zod to define all your parameter types. Then you'd define your RpcTarget in plain TypeScript, but for the parameters on each method, reference the Zod-derived types.
Although perhaps that's not what you mean.
I found these through this https://github.com/moltar/typescript-runtime-type-benchmarks