Typing is wrong in Fluent API on optional types when findUniqueOrThrow is used (null type becomes never) #18259
Labels
bug/1-unconfirmed
Bug should have enough information for reproduction, but confirmation has not happened yet.
kind/bug
A reported bug.
team/client
Issue for team Client.
topic: fluent api
Bug description
Now, let's try to access
optionalInfos
on aPerson
we know exists:Type of
optInfo
should beOptionalInfo | null
. But it incorrectly isOptionalInfo
.Using
findUnique
to accessPerson
instead offindUniqueOrThrow
correctly implies typing isOptionalInfo | null
.This comes from the fact the the
Null
type in Prisma Client seems to be set for the topmost call and then cascade to the rest of the call. This is not correct behavior for the fluent API.Related to, but not a duplicate of: #8929
How to reproduce
See Above
Expected behavior
In both cases, type should be
OptionalInfo | null
, or evenOptionalInfo | null | undefined
, to account for a Person not found.Environment & setup
Prisma Version
The text was updated successfully, but these errors were encountered: