P
Prisma7d ago
pilfer

The "omit" field type is not generated for Prisma client - v6.2.0

While attempting to play with the new omit exclusion feature (here: https://www.prisma.io/docs/orm/prisma-client/queries/excluding-fields#excluding-a-field-globally-using-omit), I found what may be a generator bug. I'm seeing the typescript error of, Object literal may only specify known properties, and 'omit' does not exist in type 'Subset<PrismaClientOptions, PrismaClientOptions>' when attempting to use new PrismaClient({ omit: { user: password } }). I'm using prisma version 6.2.0 and I have already regenerated the client multiple times. The generated node_modules/.prisma/client/index.d.ts file doesn't included the omit field, despite it existing here: https://github.com/prisma/prisma/blob/6.2.0/packages/client/src/runtime/getPrismaClient.ts#L134C2-L134C27 It does generate if I use the previewFeatures = ["omitApi"] feature flag, but npx prisma generate throws a warning of Preview feature "omitApi" is deprecated. The functionality can be used without specifying it as a preview feature.. Am I doing something wrong, or is this just a bug?
Excluding fields | Prisma Documentation
This page explains how to exclude sensitive fields from Prisma Client
GitHub
prisma/packages/client/src/runtime/getPrismaClient.ts at 6.2.0 · pr...
Next-generation ORM for Node.js & TypeScript | PostgreSQL, MySQL, MariaDB, SQL Server, SQLite, MongoDB and CockroachDB - prisma/prisma
20 Replies
Nurul
Nurul7d ago
Hey @pilfer Let me try
pilfer
pilferOP7d ago
With omitApi, in index.d.ts I'm seeing it generated in export interface PrismaClientOptions { ... as the last field. If I comment out that flag, it disappears 😄
Nurul
Nurul7d ago
It seems to work as expected for me in the latest version. I don't have omitApi in my schema.prisma
No description
Nurul
Nurul7d ago
// This is your Prisma schema file,
// learn more about it in the docs: https://pris.ly/d/prisma-schema

generator client {
provider = "prisma-client-js"
previewFeatures = ["prismaSchemaFolder", "strictUndefinedChecks"]
}

datasource db {
provider = "sqlite"
url = "file:../dev.db"
}

model Channel {
id String @id @default(cuid())
name String
lastMessage Message?
}

model Message {
id String @id @default(cuid())
text String
createdAt DateTime
channel Channel @relation(fields: [channelId], references: [id])
channelId String @unique
isRead Boolean @default(false)
}
// This is your Prisma schema file,
// learn more about it in the docs: https://pris.ly/d/prisma-schema

generator client {
provider = "prisma-client-js"
previewFeatures = ["prismaSchemaFolder", "strictUndefinedChecks"]
}

datasource db {
provider = "sqlite"
url = "file:../dev.db"
}

model Channel {
id String @id @default(cuid())
name String
lastMessage Message?
}

model Message {
id String @id @default(cuid())
text String
createdAt DateTime
channel Channel @relation(fields: [channelId], references: [id])
channelId String @unique
isRead Boolean @default(false)
}
pilfer
pilferOP7d ago
that's so weird - maybe there's something else in my env that is causing the issue I'm using a devenv.sh environment, node v22.10.0 - generating via npx prisma generate
Nurul
Nurul7d ago
Try deleting node_modules and reinstalling the dependencies?
pilfer
pilferOP7d ago
Already did haha Out of curiosity, what version of typescript are you using?
Nurul
Nurul7d ago
5.7.2
pilfer
pilferOP7d ago
same here. the only logical conclusion that we can responsibly draw from this experience is that my editor is in fact haunted by one or more ghosts
Nurul
Nurul7d ago
Haha, try restarting the Typescript server in your IDE?
pilfer
pilferOP7d ago
I tried that as well as removing the prisma npx command itself to no avail. I think we can chalk this up to a nonstandard dev env + ghosts lol
WikiRik
WikiRik7d ago
I'm running into the same issue. I did see that in some places of the code it does still reference the previewFeature through context.isPreviewFeatureOn('omitApi'). I cleared npm cache, deleted node_modules and reinstalled. It also is picked up by npx tsc so it's not just VSCode for me. I'll try an empty project as well
WikiRik
WikiRik7d ago
I'm getting it on a new project as well, by following the first four steps of the quickstart; https://www.prisma.io/docs/getting-started/quickstart-sqlite
Quickstart with TypeScript & SQLite | Prisma Documentation
Get started with Prisma ORM in 5 minutes. You will learn how to send queries to a SQLite database in a plain TypeScript script using Prisma Client.
WikiRik
WikiRik7d ago
Will create an issue for it
WikiRik
WikiRik7d ago
GitHub
Typing error when using omit without preview feature · Issue #25992...
Bug description TypeScript will throw an error when trying to use the global omit feature in 6.2.0 without the feature on. The error it throws is Object literal may only specify known properties, a...
pilfer
pilferOP7d ago
Nice - glad to know it wasn't just me! Thanks for raising the issue
Nurul
Nurul6d ago
@WikiRik Thank you for creating the issue. It seems like an issue our ORM team needs to look into. Although I wasn't able to reporduce it, I see a few users have reported the same thing, so there is obviously something going wrong which we need to check.
Nurul
Nurul6d ago
@pilfer @WikiRik Prisma release 6.2.1 is out. This should fix the issue you were observing https://github.com/prisma/prisma/releases/tag/6.2.1 Thank you for bringing this to our attention 🙏
GitHub
Release 6.2.1 · prisma/prisma
Today we are releasing the 6.2.1 patch release to address an issue with some of the omitApi preview feature checks having been accidentally omitted when making the feature GA. Now it is fully funct...
WikiRik
WikiRik6d ago
Works great for me, thanks for the quick work!
pilfer
pilferOP6d ago
Beautiful! Thank you @Nurul and team. What a pleasant surprise to wake up to ❤️

Did you find this page helpful?