drizzle-typebox loses typechecking when used from another package

I'm setting up a project with a monorepo (available at https://github.com/trilliumlab/trail-eyes-monorepo/blob/3459d8014508365d256db5cc8b088e880f8b29f6/)
I have a separate package for the database that can be shared with all my apps. I use typebox throughout the project, so the database package uses drizzle-typebox and createInsertSchema to generate my typebox schemas.

For some reason, it seems I lose typing from any schemas created with drizzle-typebox when I try to use them outside of the database package. This doesn't seem to happen with typebox schemas I create myself.

What I mean by this is I have a file in my database that I setup to have a function that takes a drizzle-typebox generated schema, a function with a regular typebox schema, and a function with an object with a regular typescript definition (https://github.com/trilliumlab/trail-eyes-monorepo/blob/3459d8014508365d256db5cc8b088e880f8b29f6/packages/database/src/database.ts). I then try passing an empty object to these 3 functions and the inference works as it should.

I then have a file in another package in my monorepo (https://github.com/trilliumlab/trail-eyes-monorepo/blob/3459d8014508365d256db5cc8b088e880f8b29f6/apps/scripts/src/db/import-routes.ts) This just calls the same 3 functions from above, but for some reason the first function shows no typescript error when I pass it {}, and other 2 behave as they should.

I'm sure it's just something with my typescript configuration, but it's weird to me that it only happens with drizzle-typebox and not regular typebox schemas. If anyone had any input that would be greatly appreciated :)
GitHub
Contribute to trilliumlab/trail-eyes-monorepo development by creating an account on GitHub.
Was this page helpful?