Newt
Newt
DTDrizzle Team
Created by Newt on 4/15/2025 in #help
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:
{
"compilerOptions": {
"lib": ["ESNext"],
"module": "ESNext",
"target": "ESNext",
"moduleResolution": "bundler",
"esModuleInterop": true,
"strict": true,
"skipLibCheck": true,
"allowSyntheticDefaultImports": true,
"noEmit": true,
"allowImportingTsExtensions": true,
"noUncheckedIndexedAccess": true,
"baseUrl": ".",
"paths": {
"$server": ["./src/server.ts"],
"$lib/*": ["./src/lib/*"]
}
},
"include": ["src"]
}
{
"compilerOptions": {
"lib": ["ESNext"],
"module": "ESNext",
"target": "ESNext",
"moduleResolution": "bundler",
"esModuleInterop": true,
"strict": true,
"skipLibCheck": true,
"allowSyntheticDefaultImports": true,
"noEmit": true,
"allowImportingTsExtensions": true,
"noUncheckedIndexedAccess": true,
"baseUrl": ".",
"paths": {
"$server": ["./src/server.ts"],
"$lib/*": ["./src/lib/*"]
}
},
"include": ["src"]
}
Versions:
"drizzle-orm": "^0.41.0",
"drizzle-typebox": "^0.3.1",
"drizzle-orm": "^0.41.0",
"drizzle-typebox": "^0.3.1",
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:
Argument of type 'PgTableWithColumns<...>' is not assignable to parameter
of type 'Table<...>'. The types of '_.config.columns' are incompatible...
Argument of type 'PgTableWithColumns<...>' is not assignable to parameter
of type 'Table<...>'. The types of '_.config.columns' are incompatible...
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?
10 replies