Replies: 2 comments
-
|
Hi @maxkrumpe! When you use a condition to optionally include a nested selection, Prisma cannot accurately infer the resulting payload type. Instead, it falls back to a less precise type. This is discussed in detail in this issue and this issue. For now, you can manually define a union or optional type that matches the possible payloads. There are a few workarounds mentioned in the linked issues as well. |
Beta Was this translation helpful? Give feedback.
-
|
Hi, As we have not heard back from you, we are closing this discussion to keep our discussions organized. Feel free to start a new discussion if this remains relevant. Thank you for being part of the community! |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Question
I would like to create a type for the dynamic payload based on my selector to share its type at multiple places.
I have created the helper function:
The issue is that the type is not inferred correctly because of the condition and will always define the type for "festivalDayMeals" to not contain the "meal".
The created type "Test" will look like:
If the condition is removed, the type will be inferred correctly and will contain "meal" in "festivalDayMeals":
Here the created type "Test" will look like:
Is there a way to solve this issue or is it a bug?
How to reproduce (optional)
Expected behavior (optional)
The correct type should be returned for example something like:
or
Information about Prisma Schema, Client Queries and Environment (optional)
OS: macOS
Database: PostgreSQL
Node.js version: v22.14.0
Run
prisma -vto see your Prisma version and paste itBeta Was this translation helpful? Give feedback.
All reactions