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 🌞🌞🌞
10 Replies
did you prisma db push?
I did yes
try to refresh
or reopen vscode
did you select those fields?
This happens from time to time; restarting Typescript is typically the solution
Just made a quick demo to demonstrate again that only the non-primitive types are on the variable of type from Router outputs :/
I have confirmed that it IS possibly to get non-primitive type from a Prisma model....
U can do that by using prisma generated types
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.
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