drizzle-team / drizzle-team/drizzle-orm
[BUG]: Generic functions which take a `PgTableWithColumns` don't compile on 0.32 and above
- Dominant language
- TypeScript
- Stars
- 35.8k
- Forks
- 1.6k
- Avg merge
- 2d 7h
- Merged PRs (30d)
- 4
Description
### Report hasn't been filed before.
- [x] I have verified that the bug I'm about to report hasn't been filed before.
### What version of `drizzle-orm` are you using?
0.40.0
### What version of `drizzle-kit` are you using?
0.30.5
### Other packages
TypeScript 5.4.5
### Describe the Bug
After upgrading Drizzle from 0.31.4 to 0.40.0, I'm seeing TypeScript errors.
I have some helper functions which look like this:
```ts
async function setColumn(
table: PgTableWithColumns,
id: string,
) {
await db.update(table).set({ column: 'someValue' }).where(eq(table.id, id))
}
```
On 0.31.4, this compiles correctly, and IntelliSense works. On 0.32 and later, I'm getting the following error:
```
TS2353: Object literal may only specify known properties, and 'images' does not exist in type '{ [Key in keyof PgTableWithColumns["$inferInsert"]]?: SQL | PgColumn, {}, {}> | (PgTableWithColumns<...>["_"]["columns"][Key]["_"]["notNull"] extends true ? PgTableWithColumns<...>["_"]["columns"][Key]["_"]["data"] : PgTableWithColumns<...>["_"]["columns"][Key]["_...
```
How do I get the code above to compile with newer versions of Drizzle? What's the correct way to write such generic functions?
Contributor guide
Assessment
This issue has not been assessed yet.