Non-primitive fields not showing on variables of type from RouterOutputs.

I get the type from RouterOutputs. When I initialize a variable of this type, the auto complete does not suggest the two non-primitive data type fields. Any ideas why? Any comments would be appreciated thanks 🌞🌞🌞
No description
10 Replies
erik.gh
erik.gh14mo ago
did you prisma db push?
cadams
cadamsOP14mo ago
I did yes
arete
arete14mo ago
try to refresh or reopen vscode
kewinzaq1
kewinzaq114mo ago
did you select those fields?
Circus
Circus14mo ago
This happens from time to time; restarting Typescript is typically the solution
cadams
cadamsOP14mo ago
Just made a quick demo to demonstrate again that only the non-primitive types are on the variable of type from Router outputs :/
No description
cadams
cadamsOP14mo ago
I have confirmed that it IS possibly to get non-primitive type from a Prisma model....
No description
H
H14mo ago
U can do that by using prisma generated types
H
H14mo ago
Prisma
Advanced type safety (Reference)
Prisma Client provides full type safety for queries, even for partial queries or included relations. This page explains how to leverage the generated types and utilities.
cadams
cadamsOP14mo ago
Thats a useful piece of documentation.... But it doesn't address the issue on RouterOutputs I have noted. Which is: RouterOutputs types ignore "complex data type" fields and only have primitive fields This seems like a critical issue. Could someone be an absolute goat and try reproduce this error please ? 🌞🙏🌞🙏🌞🙏 1. Create a model in prisma with complex data type e.g. User 2. Create a router that returns ctx.prisma.newmodel.findMany(); 3. Put that router in root.ts 4. run npx prisma db push 5. In any file, get the type : type NewType = RouterOutputs["newmodel"]["getAll"][number]; 6. Create a variable of this type : const foo = {} as NewType 7. See if the complex data type field is on the variable
Want results from more Discord servers?
Add your server