© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
Drizzle TeamDT
Drizzle Team•6mo ago•
20 replies
jhechtf

Randomly losing types for tables.

I have a mono repo setup for a bill tracking project, it's OSS so you can view it at https://github.com/sungmanito/mono -- part of the monorepo are shared drizzle definitions because I end up using them in more than one place (https://github.com/sungmanito/mono/tree/main/packages/db)

Currently I've lost types for my queries. This is not the first time this has happened, but previously the culprit was that I had upgraded the drizzle-orm version in one package without updating the other(s). Each of the packages and apps are using drizzle-orm
0.44.2
0.44.2
, confirmed in my pnpm-lockfile that there are no other listed versions.

In the main web app I create a drizzle client:
import { drizzle } from 'drizzle-orm/node-postgres';
import { DB_URL } from '$env/static/private';
import Pg from 'pg';
import { exportedSchema } from '@sungmanito/db';

const client = new Pg.Pool({
  connectionString: DB_URL,
});

await client.connect();

export const db = drizzle(client, {
  logger: true,
  schema: exportedSchema,
});
import { drizzle } from 'drizzle-orm/node-postgres';
import { DB_URL } from '$env/static/private';
import Pg from 'pg';
import { exportedSchema } from '@sungmanito/db';

const client = new Pg.Pool({
  connectionString: DB_URL,
});

await client.connect();

export const db = drizzle(client, {
  logger: true,
  schema: exportedSchema,
});


and in the loader functions (sveltekit) I tend to do stuff like
import { db } from '$lib/server/db';
import { exportedSchema } from '@sungmanito/db';
export const load = async () => {
  const results = await db.select().from(exportedSchema.bills);
  return { results };
}
import { db } from '$lib/server/db';
import { exportedSchema } from '@sungmanito/db';
export const load = async () => {
  const results = await db.select().from(exportedSchema.bills);
  return { results };
}


More confusing, is if i take any of the table definitions and just include them in the repo, it works fine.

The types that come back for a typical query, like where I'm loading all the bills, their most recent payment status, and the name of the household associated with that bill, is this

 ({
    [x: string]: unknown;
} | {
    [x: string]: unknown;
} | {
    [x: string]: unknown;
} | {
    [x: string]: unknown;
} | {
    [x: string]: unknown;
} | {
    [x: string]: unknown;
} | {
    [x: string]: unknown;
} | {
    [x: string]: unknown;
})[]
 ({
    [x: string]: unknown;
} | {
    [x: string]: unknown;
} | {
    [x: string]: unknown;
} | {
    [x: string]: unknown;
} | {
    [x: string]: unknown;
} | {
    [x: string]: unknown;
} | {
    [x: string]: unknown;
} | {
    [x: string]: unknown;
})[]


When it should be something more like
{ id: string; billName: string; householdName: string; householdId: string; ...}[]
{ id: string; billName: string; householdName: string; householdId: string; ...}[]


Anyone got any ideas?

GitHub
GitHub - sungmanito/mono
Contribute to sungmanito/mono development by creating an account on GitHub.
GitHub - sungmanito/mono
GitHub
mono/packages/db at main · sungmanito/mono
Contribute to sungmanito/mono development by creating an account on GitHub.
mono/packages/db at main · sungmanito/mono
Drizzle TeamJoin
The official Discord for all Drizzle related projects, such as Drizzle ORM, Drizzle Kit, Drizzle Studio and more!
11,879Members
Resources
Was this page helpful?

Similar Threads

Recent Announcements

Similar Threads

Data types for tables
Drizzle TeamDTDrizzle Team / help
3y ago
Types don't infer correctly for tables with`references` method?
Drizzle TeamDTDrizzle Team / help
8mo ago
Losing kysely types (using Kyselify) - getting [x: string]: any
Drizzle TeamDTDrizzle Team / help
2y ago
Losing custom $types in pg jsonb using drizzle-zod
Drizzle TeamDTDrizzle Team / help
2y ago