Type Error when Generating Typebox
I'm encountering a type compatibility issue with Drizzle ORM and TypeBox. When using
createSchemaFactory
from drizzle-typebox with PostgreSQL tables, I'm getting type errors when trying to create schemas. But in Runtime it Works without any Problems, i also Tried to edit my tsconfig to:
Versions:
The error suggests that the PostgreSQL-specific column types (PgColumn) from my table definition aren't compatible with the generic Column type expected by the schema factory functions:
Has anyone encountered similar type mismatches when using PostgreSQL-specific types with the schema factory? Is there a proper way to handle this without type assertions?7 Replies
My Code:
Code:
table:
What is
table.agent
is it returning a pgTable type? Not sure I'm reading this right but it looks like you should be importing agent
and using it
this is my export ^^
Okay so it should be a pgTable. Just for the sake of elimination can you try passing the agent table directly.
Nope, still, but here is the FULL error:
https://pastebin.com/CFYsN01P
Pastebin
No overload matches this call. Overload 1 of 2, '(table: Table
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
So do you also think it's your jsonb columns?
I don't know how you'd fix this without typecasting or simplifying the type somehow
the thing is, in Runtime it works without problems, i just get Runtime Errors, i also tried the Examples and i also get Compile Errors there:
https://orm.drizzle.team/docs/typebox#select-schema
Also Tried to Update my TS Config like described here: https://discord.com/channels/1043890932593987624/1318443104927223818
Drizzle ORM - drizzle-typebox
Drizzle ORM is a lightweight and performant TypeScript ORM with developer experience in mind.