-
-
Notifications
You must be signed in to change notification settings - Fork 128
Open
Description
Description and expected behavior
There is a mismatch between the TypeScript type generated for the base model and all of its delegated submodels.
Consider the following schema:
model Base {
id String @id @default(cuid(2))
type String
@@delegate(type)
}
model Foo extends Base {
foo Number
}
model Bar extends Base {
bar String
}
The types generated are as follows:
type Base = {
id: string
type: "Foo"
foo: number
} | {
id: string
type: "Bar"
bar: string
}
type Foo = {
id: string
type: string // Expected: "Foo"
foo: number
}
type Bar = {
id: string
type: string // Expected: "Bar"
bar: string
}The types of the submodels Foo and Bar lose their discriminator, while the Base union does not. As a workaround, I use the following pattern everywhere:
type Foo = Extract<Base, { type: "Foo" }>
type Bar = Extract<Base, { type: "Bar" }>Environment (please complete the following information):
- ZenStack version: 2.21.0
- Prisma version: 6.18.0
- Database type: PostgreSQL
Additional context
Metadata
Metadata
Assignees
Labels
No labels