I have some issues using drizzle as a package infering the types

Context: I have a monorepo using turbo, pnpm, honojs and drizzle. I have a server application and a package called database which exports the database client and the schemas When I import on this way: import * as schemas from '../schemas'; And import the createDatabaseClient method the db instance returns me this type:
const db: NeonHttpDatabase<any> & {
$client: NeonQueryFunction<false, false>;
}
const db: NeonHttpDatabase<any> & {
$client: NeonQueryFunction<false, false>;
}
When I import on this way: import { schemas } from '../schemas'; using an object with the schemas. And import the createDatabaseClient method the db instance returns me this type:
const db: NeonHttpDatabase<{
accountsTable: PgTableWithColumns<{
name: "accounts";
schema: undefined;
columns: {
id: PgColumn<{
name: "id";
tableName: "accounts";
dataType: "string";
columnType: "PgText";
data: string;
driverParam: string;
notNull: true;
const db: NeonHttpDatabase<{
accountsTable: PgTableWithColumns<{
name: "accounts";
schema: undefined;
columns: {
id: PgColumn<{
name: "id";
tableName: "accounts";
dataType: "string";
columnType: "PgText";
data: string;
driverParam: string;
notNull: true;
There's a way to not use the schemas object?
No description
2 Replies
W8
W82w ago
I got the same issue. You have to import schemas as an object, not as a global export.
Type the return of the function createDatabaseClient as:
export type Drizzle = NodePgDatabase<typeof schema> & { $client: NodePgClient; } I think it will work.
No description
No description
Cristian Sotomayor
hmm I'm going to try that! thanks

Did you find this page helpful?