Types don't infer correctly for tables with`references` method?

I'm using Drizzle with Expo SQLite in an Expo managed app. On my schema all of the tables that contain simple column data, i.e. primitive types like
text
or int, get typed correctly. Any time I create an association with the references method the generated type becomes { [x: string]: any }.

I'm using:
  • Expo SDK: 51
  • Expo SQLite: 14.0.6
  • drizzle-orm: 0.44.2
  • drizzle-kit: 0.31.1
I'll give an example directly from my schema.

In my schema I have the table movementTypes and a join table that connects it with another table called characters.

// schema.ts
export const movementTypes = sqliteTable('movementTypes', {
  id: int().primaryKey({ autoIncrement: true }),
  name: text().notNull(),
  label: text().notNull()
});

// Generated type for movementTypes as returned via InferSelectModel<typeof movementTypes>
// {
//   id: number;
//   name: string;
//   label: string;
// }

export const characterMovementTypes = sqliteTable('characterMovementTypes', {
  id: int().primaryKey({ autoIncrement: true }),
  movementTypeId: int()
    .notNull()
    .references(() => movementTypes.id),
  characterId: int()
    .notNull()
    .references(() => characters.id),
  speed: int().notNull()
});

// Generated type for movementTypes as returned via InferSelectModel<typeof characterMovementTypes>
// { [x: string]: any }


Even if I try to specify the type of the column with the $type<>() method, I'm still not getting the correct type returned for the table's model.

Is there a way to get this to generate correctly? I'd be happy with a solution that requires passing types as args or generated by the drizzle api.

Thanks in advance for any help!
Was this page helpful?