drizzle-orm: [BUG]: Splitting database schemas into a separate package in monorepo causes TS2345 Property `[IsDrizzleTable]` is missing in type

What version of drizzle-orm are you using?

0.29.0

What version of drizzle-kit are you using?

0.20.4 (but not relevant)

Describe the Bug

  1. Copy/paste the example drizzle adapter code from https://github.com/nextauthjs/next-auth/blob/693a0723a7bad2b0950e4c6006a99c98852c4beb/packages/adapter-drizzle/src/lib/pg.ts into my own project
  2. Note that the example code works (leave aside the deprecated primaryKey(col1, col2), which I fixed).
  3. My project is a monorepo, so the database schemas (which were in Prisma) are in a separate package. Move the table definitions for users, accounts, sessions, and verificationTokens into a separate package, where tsc --build is producing a dist/ folder and package.json’s exports references dist/index.d.ts etc., then import the table definitions in the original app package which is making the insert calls.
  4. Receive the following error: TS2345 and Property [isDrizzleTable] is missing in type:

image

the compiled .d.ts looks like this:

image

Expected behavior

Not to have the tsc error. I expect the types to be portable.

Environment & setup

I use a monorepo with pnpm and syncpack and have confirmed that both the main app package and the database schema package are using the same 0.29.0 version of drizzle-orm.

About this issue

  • Original URL
  • State: open
  • Created 7 months ago
  • Reactions: 1
  • Comments: 31

Most upvoted comments

I consulted the team, They’re looking into the bundler thing. I wasn’t aware of that and the consequences, mostly because it hasn’t affected my own setup. We’ll see.

ok @Angelelz I think I have a reproduction for you: https://github.com/ari-becker/drizzle-1558-repro

  1. run pnpm install
  2. run pnpm build:tsc

There’s a lot of errors (hazard of copy/pasting/deleting) but the relevant one is the second one:

image

and just to verify again that versions match:

image

Just submitted a pr to your reproduction. Please see my notes there. Take a look and let me know if we can close this issue.

Fixed!

It was because I was using different versions of drizzle orm inside my workspaces. So if you update all the drizzle orms to the same version it will work nicely!!