Invalid type inference when using helpers

im using helpers for primaryKey and current timestamp
column.helper.ts
import { integer, text } from "drizzle-orm/sqlite-core";

export const primaryKey = () =>
  text()
    .primaryKey()
    .$defaultFn(() => crypto.randomUUID());

export const timestamp = () =>
  integer({ mode: "timestamp" }).default(new Date()).notNull();


schema.ts
import { primaryKey, timestamp } from "@align/db/helpers/column.helper";
import { sqliteTable, text } from "drizzle-orm/sqlite-core";

export const waitlistMember = sqliteTable("waitlist_members", {
  id: primaryKey(),
  name: text().notNull(),
  email: text().unique().notNull(),
  joined_at: timestamp(),
});


i exported the types from my packages/db which has correct types. however the query i return, returns type any for the fields where i used the helpers. if i switch back to normally typing the column type instead of a helper it gives correct types
export const waitlistMember = sqliteTable("waitlist_members", {
  id: text().primaryKey().$defaultFn(() => crypto.randomUUID()),
  ...
});
// ^^^^ this returns type `string` when results of query is returned

export const waitlistMember = sqliteTable("waitlist_members", {
  id: primaryKey(),
  name: text().notNull(),
  email: text().unique().notNull(),
  joined_at: timestamp(),
});
// ^^^^ this returns type `any` when results of query is returned
399096242-bc738ae4-cd25-430d-b831-6ccfbc65a035.png
399096259-a715c94c-b8ae-43dc-8d12-e16a7da89d17.png
Was this page helpful?