The type-check of partial-select doesn't work well

description

On the code
import { sql } from "drizzle-orm";
import {
    mysqlTable,
    varchar,
} from "drizzle-orm/mysql-core";

const users = mysqlTable("users", {
    id: varchar("id", { length: 255 }).notNull().primaryKey(),
    name: varchar("name", { length: 255 })
});

export const getUsers = async () => {
    const result = await db.select({
      field1: users.id,
      field2: users.name,
    }).from(users);
    const { field1, field2 } = result[0];
    return result;
}


ref: https://orm.drizzle.team/docs/select#partial-select


I bumped into the type error.

Expected 0 arguments, but got 1.ts(2554)



drizzle-orm/mysql-core/db.d.ts
1. select(): MySqlSelectBuilder<undefined, TPreparedQueryHKT>;
2. select<TSelection extends SelectedFields>(fields: TSelection): MySqlSelectBuilder<TSelection, TPreparedQueryHKT>;

I want to use 2, but type check is executed as 1.

How can I fix this...??
Please help me.


version

    "@tidbcloud/serverless": "^0.2.0",
    "drizzle-orm": "^0.32.1",
Drizzle ORM is a lightweight and performant TypeScript ORM with developer experience in mind.
Was this page helpful?