Type error when passing schema to drizzle

export const db: PostgresJsDatabase = drizzle(queryClient, {
schema: schema,
logger: true,
})
export const db: PostgresJsDatabase = drizzle(queryClient, {
schema: schema,
logger: true,
})
I am passing my schema like this
│  Type 'PostgresJsDatabase<typeof import("/Users/mooy/Desktop/projects/tracker/apps/api/src/db/schema/schema")>' is not assignable to type 'PostgresJsDatabase'. typescript (2322) [7, 14]
│ The types of '_.schema' are incompatible between these types.
│ Type 'ExtractTablesWithRelations<typeof import("/Users/mooy/Desktop/projects/tracker/apps/api/src/db/schema/schema")> | undefined' is not assignable to type 'ExtractTablesWithRelations<Record<string, never>> | undefined'.
│ Type 'ExtractTablesWithRelations<typeof import("/Users/mooy/Desktop/projects/tracker/apps/api/src/db/schema/schema")>' is not assignable to type 'ExtractTablesWithRelations<Record<string, never>>'.
│ Property 'key' is incompatible with index signature.
│ Type '{ tsName: "key"; dbName: "user_key"; columns: { id: PgColumn<{ name: "id"; tableName: "user_key"; dataType: "string"; columnType: "PgVarchar"; data: string; driverParam: string; notNull: true; hasDefault: false; enumValues: [...]; baseColumn: never; }, {}, {}>; userId: PgColumn<...>; hashedPassword: PgColumn<...>; }...' is not assignable to type '{ tsName: string; dbName: never; columns: never; relations: Record<string, Relation<string>>; primaryKey: AnyColumn[]; }'.
│ Types of property 'dbName' are incompatible.
│ Type 'string' is not assignable to type 'never'.
│  Type 'PostgresJsDatabase<typeof import("/Users/mooy/Desktop/projects/tracker/apps/api/src/db/schema/schema")>' is not assignable to type 'PostgresJsDatabase'. typescript (2322) [7, 14]
│ The types of '_.schema' are incompatible between these types.
│ Type 'ExtractTablesWithRelations<typeof import("/Users/mooy/Desktop/projects/tracker/apps/api/src/db/schema/schema")> | undefined' is not assignable to type 'ExtractTablesWithRelations<Record<string, never>> | undefined'.
│ Type 'ExtractTablesWithRelations<typeof import("/Users/mooy/Desktop/projects/tracker/apps/api/src/db/schema/schema")>' is not assignable to type 'ExtractTablesWithRelations<Record<string, never>>'.
│ Property 'key' is incompatible with index signature.
│ Type '{ tsName: "key"; dbName: "user_key"; columns: { id: PgColumn<{ name: "id"; tableName: "user_key"; dataType: "string"; columnType: "PgVarchar"; data: string; driverParam: string; notNull: true; hasDefault: false; enumValues: [...]; baseColumn: never; }, {}, {}>; userId: PgColumn<...>; hashedPassword: PgColumn<...>; }...' is not assignable to type '{ tsName: string; dbName: never; columns: never; relations: Record<string, Relation<string>>; primaryKey: AnyColumn[]; }'.
│ Types of property 'dbName' are incompatible.
│ Type 'string' is not assignable to type 'never'.
but it returns this error
1 Reply
acronie
acronieOP12mo ago
I am not facing any errors inside my schema files. import * as schema from "./schema/schema" If I remove the the PostgresJsType the error goes, but no type for the user stuff
Want results from more Discord servers?
Add your server