Describe the bug
Hi, thanks for this awesome library. I don't know if it worked in previous versions of typescript, but when I pass only one type argument I get an error:
import { createBirpc } from "birpc";
const serverFunctions = {
hiFromServer(name: string) {
return `Hi ${name} from server`;
},
};
const clientFunctions = {
hiFromClient(name: string) {
return `Hi ${name} from client`;
},
};
const birpc = createBirpc<typeof serverFunctions>(
clientFunctions, // <--- Error
{
on(fn) {
},
post(data, ...extras) {
},
});
Argument of type '{ hiFromClient(name: string): string; }' is not assignable to parameter of type 'Record<string, never>'.
Property 'hiFromClient' is incompatible with index signature.
Type '(name: string) => string' is not assignable to type 'never'. TS(2345)
So it basically can't infer the right type when you set default generic value to Record<string, never>.
So examples from README doesn't work.
Fix
Changing generic parameters default type here and in relevant places should fix it.
It works with any of this constraints instead:
LocalFunctions extends object = Record<string, unknown>
LocalFunctions extends object = Record<string, any>
LocalFunctions extends object = object
Reproduction
Provided above
System Info
TypeScript version 5.9.3
birpc 2.7.0
Used Package Manager
npm
Validations
Contributions
Describe the bug
Hi, thanks for this awesome library. I don't know if it worked in previous versions of typescript, but when I pass only one type argument I get an error:
So it basically can't infer the right type when you set default generic value to
Record<string, never>.So examples from README doesn't work.
Fix
Changing generic parameters default type here and in relevant places should fix it.
It works with any of this constraints instead:
Reproduction
Provided above
System Info
Used Package Manager
npm
Validations
Contributions