TS2345: PgTableWithColumns<…> from buildable shared-lib not assignable to PgTable<TableConfig>

I’m working in an Nx monorepo with a shared-lib and a Node.js API. Both use Drizzle-ORM (same version), but my API imports tables from the shared-lib. When I try to join one of those tables, TypeScript complains about a type mismatch.
error TS2345: Argument of type
'PgTableWithColumns<...>'
is not assignable to parameter of type
'SQL<unknown> | Subquery<string, Record<string, unknown>> |
PgViewBase<string, boolean, ColumnsSelection> |
PgTable<TableConfig>'.

Type 'PgTableWithColumns<...>' is not assignable to type 'PgTable<TableConfig>'.
The types of '_.config.columns' are incompatible between these types.
Type '{ id: PgColumn<...>; title: PgColumn<...>; /* … */ }'
is not assignable to type
'Record<string, PgColumn<ColumnBaseConfig<…, string>, {}, {}>>'.
error TS2345: Argument of type
'PgTableWithColumns<...>'
is not assignable to parameter of type
'SQL<unknown> | Subquery<string, Record<string, unknown>> |
PgViewBase<string, boolean, ColumnsSelection> |
PgTable<TableConfig>'.

Type 'PgTableWithColumns<...>' is not assignable to type 'PgTable<TableConfig>'.
The types of '_.config.columns' are incompatible between these types.
Type '{ id: PgColumn<...>; title: PgColumn<...>; /* … */ }'
is not assignable to type
'Record<string, PgColumn<ColumnBaseConfig<…, string>, {}, {}>>'.
import { eq } from 'drizzle-orm';
import {
mealPlanItemsTable,
recipeCategoriesTable,
recipesTable,
} from '@myorg/shared-lib';

export async function getOverview(userId: string) {
return db
.select({ /* … */ })
.from(mealPlanItemsTable)
.innerJoin(
recipeCategoriesTable,
eq(mealPlanItemsTable.categoryId, recipeCategoriesTable.id)
)
.leftJoin(
recipesTable, // ← TS2345 triggers here
eq(mealPlanItemsTable.recipeId, recipesTable.id)
)
.where(eq(mealPlanItemsTable.userId, userId));
}
import { eq } from 'drizzle-orm';
import {
mealPlanItemsTable,
recipeCategoriesTable,
recipesTable,
} from '@myorg/shared-lib';

export async function getOverview(userId: string) {
return db
.select({ /* … */ })
.from(mealPlanItemsTable)
.innerJoin(
recipeCategoriesTable,
eq(mealPlanItemsTable.categoryId, recipeCategoriesTable.id)
)
.leftJoin(
recipesTable, // ← TS2345 triggers here
eq(mealPlanItemsTable.recipeId, recipesTable.id)
)
.where(eq(mealPlanItemsTable.userId, userId));
}
Why does TypeScript see a PgTableWithColumns<…> from my shared-lib as different from the PgTable<TableConfig> expected by .leftJoin, even though both come from the same Drizzle-ORM package? How can I fix this so shared-lib tables join cleanly in my API? "drizzle-kit": "^0.31.1", "drizzle-orm": "^0.44.0", "drizzle-seed": "^0.3.1", "drizzle-zod": "^0.8.2", "zod": "^3.25.42" I'm using zod/v4 everywhere.
15 Replies
JROCBABY
JROCBABYOP5mo ago
TS2345: Argument of type
'PgTableWithColumns<{ name: "recipes"; schema: undefined; columns: { id: PgColumn<{ name: "id"; tableName: "recipes"; dataType: "string"; columnType: "PgUUID"; data: string; driverParam: string; notNull: true; hasDefault: true; ... 6 more ...; generated: undefined }, {}>; /* …16 more columns… */; updatedAt: PgColumn<…> }>'
is not assignable to parameter of type
'SQL<unknown> | Subquery<string, Record<string, unknown>> | PgViewBase<string, boolean, ColumnsSelection> | PgTable<TableConfig>'.

Type 'PgTableWithColumns<…>' is not assignable to type 'PgTable<TableConfig>'.
The types of '_.config.columns' are incompatible between these types.
Type '{ id: PgColumn<{ name: "id"; tableName: "recipes"; … }, {}>; /* …16 more… */; updatedAt: PgColumn<…> }'
is not assignable to type
'Record<string, PgColumn<ColumnBaseConfig<ColumnDataType, string>, {}, {}>>'.
Property 'id' is incompatible with index signature.
Type 'PgColumn<{ name: "id"; tableName: "recipes"; … }, {}>' is not assignable to type 'PgColumn<ColumnBaseConfig<ColumnDataType, string>, {}, {}>'.
The types of 'table._.config.columns' are incompatible between these types.
Type
'Record<string, import("...drizzle-orm/pg-core/columns/common").PgColumn<import("/path/to/project/node_modules/drizzle-orm/column").ColumnBaseConfig<import("/path/to/project/node_modules/drizzle-orm/column-builder").ColumnDataType, string>, {}, {}>>'
is not assignable to
'Record<string, import("..drizzle-orm/pg-core/columns/common").PgColumn<import("/path/to/project/node_modules/drizzle-orm/column").ColumnBaseConfig<import("/path/to/project/node_modules/drizzle-orm/column-builder").ColumnDataType, string>, {}, {}>>'.
Property 'config' is protected but type 'Column<T, TRuntimeConfig, TTypeConfig>' is not a class derived from 'Column<T, TRuntimeConfig, TTypeConfig>'.
TS2345: Argument of type
'PgTableWithColumns<{ name: "recipes"; schema: undefined; columns: { id: PgColumn<{ name: "id"; tableName: "recipes"; dataType: "string"; columnType: "PgUUID"; data: string; driverParam: string; notNull: true; hasDefault: true; ... 6 more ...; generated: undefined }, {}>; /* …16 more columns… */; updatedAt: PgColumn<…> }>'
is not assignable to parameter of type
'SQL<unknown> | Subquery<string, Record<string, unknown>> | PgViewBase<string, boolean, ColumnsSelection> | PgTable<TableConfig>'.

Type 'PgTableWithColumns<…>' is not assignable to type 'PgTable<TableConfig>'.
The types of '_.config.columns' are incompatible between these types.
Type '{ id: PgColumn<{ name: "id"; tableName: "recipes"; … }, {}>; /* …16 more… */; updatedAt: PgColumn<…> }'
is not assignable to type
'Record<string, PgColumn<ColumnBaseConfig<ColumnDataType, string>, {}, {}>>'.
Property 'id' is incompatible with index signature.
Type 'PgColumn<{ name: "id"; tableName: "recipes"; … }, {}>' is not assignable to type 'PgColumn<ColumnBaseConfig<ColumnDataType, string>, {}, {}>'.
The types of 'table._.config.columns' are incompatible between these types.
Type
'Record<string, import("...drizzle-orm/pg-core/columns/common").PgColumn<import("/path/to/project/node_modules/drizzle-orm/column").ColumnBaseConfig<import("/path/to/project/node_modules/drizzle-orm/column-builder").ColumnDataType, string>, {}, {}>>'
is not assignable to
'Record<string, import("..drizzle-orm/pg-core/columns/common").PgColumn<import("/path/to/project/node_modules/drizzle-orm/column").ColumnBaseConfig<import("/path/to/project/node_modules/drizzle-orm/column-builder").ColumnDataType, string>, {}, {}>>'.
Property 'config' is protected but type 'Column<T, TRuntimeConfig, TTypeConfig>' is not a class derived from 'Column<T, TRuntimeConfig, TTypeConfig>'.
Queen Elizabeth II
check if it isn't anything like what i've had perchance #Type error when using drizzle-zod with sqlite table schema maybe it's completely different but it's a good thing to check first given that you're in a monorepo @JROCBABY
JROCBABY
JROCBABYOP5mo ago
hmm thanks, but for it it doesn't error in my schema's, my library builds fine, it's in my nodejs api where I get these errors
Queen Elizabeth II
right but as in trying to delete all node_modules folders
JROCBABY
JROCBABYOP5mo ago
Yeah I did that 5 times already regenerated my bun lock and everything
Queen Elizabeth II
oh right ok. and definitely only ran bun i at the top level? not in any of your workspaces
JROCBABY
JROCBABYOP5mo ago
yeah well that's what I thought it was, since NX is apparently unable to sync deps from the root with the workspaces, if they mismatch it starts creating node modules in your workspaces, what a great system so I removed those and manually aligned the deps but still the same
Queen Elizabeth II
yeah that's about as much as i know then lots of issues with drizzle-zod tags it seems
JROCBABY
JROCBABYOP5mo ago
nx is giving me so much pain, what a mess It's so sad that when working with js/ts that 90% of your time gets taken up by solving dumb errors, instead of, you know actually building cool stuff and it's been like that for over a decade
👾Rnbsov
👾Rnbsov5mo ago
use turborepo
Yabets
Yabets5mo ago
Did you get the solution?
JROCBABY
JROCBABYOP5mo ago
Yeah the issue is drizzle, it happens in 0.43.0 or something if you downgrade to 0.42 it works
JROCBABY
JROCBABYOP5mo ago
GitHub
[BUG]: Left Join PgColumn Incompatible After the Latest Version · ...
Report hasn&#39;t been filed before. I have verified that the bug I&#39;m about to report hasn&#39;t been filed before. What version of drizzle-orm are you using? 0.43.x What version of drizzle-kit...
Yabets
Yabets5mo ago
Thanks bro, that was very helpful.
JROCBABY
JROCBABYOP5mo ago
No worries man

Did you find this page helpful?