Bert
Bert13mo ago

tRPC is butchering object types in return types

So if I have a mutation that returns this type
{ name?: string }
{ name?: string }
the type that tRPC infers for the mutation is
type R = ReturnType<typeof trpcClient.mut.mutate>
R = Promise<Record<"name", string | undefined>>
type R = ReturnType<typeof trpcClient.mut.mutate>
R = Promise<Record<"name", string | undefined>>
This is not the same, with exactOptionalPropertyTypes. Anyone familiar with this who can provide some info about it?
3 Replies
Nick
Nick13mo ago
Hm this might be a recent thing, there was some work done detecting record types. Could you provide a minimal repro and open a GitHub issue?
wleistra
wleistra13mo ago
@Bert make sure you are on version 10.44.0 or higher.
Bert
BertOP13mo ago
"@trpc/client": "^10.43.6", "@trpc/server": "^10.43.6", Yeah that fixed it. Thanks @wleistra (and @Nick Lucas for the effort)