Drizzle TeamDT
Drizzle Team3y ago
12 replies
sam

TypeScript type errors when running in PNPM workspace

I changed nothing about my code other than doing a full clean build. Working code now failing with type errors.

I am on version:
"drizzle-orm": "^0.29.1",


I am getting this error:
`ts
frontend/src/server/list-files.ts(37,11): error TS2322: Type 'PgColumn<{ name: "state"; tableName: "place"; dataType: "string"; columnType: "PgVarchar"; data: string; driverParam: string; notNull: true; hasDefault: false; enumValues: [string, ...string[]]; baseColumn: never; }, {}, {}>' is not assignable to type 'SQL<unknown> | Aliased<unknown> | PgColumn<ColumnBaseConfig<ColumnDataType, string>, {}, {}> | PgTable<TableConfig> | SelectedFieldsFlat<...>'.
  Type 'PgColumn<{ name: "state"; tableName: "place"; dataType: "string"; columnType: "PgVarchar"; data: string; driverParam: string; notNull: true; hasDefault: false; enumValues: [string, ...string[]]; baseColumn: never; }, {}, {}>' is not assignable to type 'SelectedFieldsFlat<PgColumn<ColumnBaseConfig<ColumnDataType, string>, {}, {}>>'.
    Index signature for type 'string' is missing in type 'PgColumn<{ name: "state"; tableName: "place"; dataType: "string"; columnType: "PgVarchar"; data: string; driverParam: string; notNull: true; hasDefault: false; enumValues: [string, ...string[]]; baseColumn: never; }, {}, {}>'.


Index signature for type 'string' is missing in type 'PgColumn<{ name: "state"; tableName: "place"; dataType: "string"; columnType: "PgVarchar"; data: string; driverParam: string; notNull: true; hasDefault: false; enumValues: [string, ...string[]]; baseColumn: never; }, {}, {}>


const page = await db
  .select({
    state: place.state, // <- error here
    county: place.county, // <- and here, etc.
    city: place.city,
    transcriptFile: hearing.transcriptFile,
    transcriptFileTxt: hearing.transcriptFileTxt,
    minutesFile: hearing.minutesFile,
    minutesFileTxt: hearing.minutesFileTxt,
    date: hearing.date,
  })
  .from(hearing)


There's nothing strange about my schema that i can tell:
import {
  date,
  pgEnum,
  pgSchema,
  primaryKey,
  text,
  varchar,
} from "drizzle-orm/pg-core";

export const place = public_db.table("place", {
  placeId: varchar("place_id").notNull().primaryKey(),
  state: varchar("state", { length: 2 }).notNull(),
  county: text("county").notNull(),
  city: text("city"),
  createdAt: date("created_at").defaultNow(),
});

export const hearing = public_db.table(
  "hearing",
  {
    placeId: varchar("place_id")
      .notNull()
      .references(() => place.placeId),
    date: date("date").notNull(),
    boardType: BoardType("board_type").notNull(),
    commissioners: text("commissioners"),
    createdAt: date("created_at").defaultNow(),
    minutesFile: text("minutes_file"),
    minutesFileTxt: text("minutes_file_txt"),
    videoFile: text("video_file"),
    transcriptFile: text("transcript_file"),
    transcriptFileTxt: text("transcript_file_txt"),
  },
  (table) => ({
    pk: primaryKey({
      columns: [table.placeId, table.boardType, table.date],
    }),
  })
);
Was this page helpful?