© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
Drizzle TeamDT
Drizzle Team•2y ago
pvman

Losing kysely types (using Kyselify) - getting [x: string]: any

Hello.

I have some types problems using kysely with drizzle. I have the following config:

import { CamelCasePlugin, Kysely, PostgresDialect } from "kysely";
import { Kyselify } from "drizzle-orm/kysely";
import { createPool } from "#connectors/create-pool";
import {
  posts,
} from "#schema";

export interface KyselyDatabase {
  posts: Kyselify<typeof posts>;
}

export const db = new Kysely<KyselyDatabase>({
  dialect: new PostgresDialect({
    pool: createPool({
      max: 1,
    }),
  }),
  plugins: [new CamelCasePlugin()],
});
import { CamelCasePlugin, Kysely, PostgresDialect } from "kysely";
import { Kyselify } from "drizzle-orm/kysely";
import { createPool } from "#connectors/create-pool";
import {
  posts,
} from "#schema";

export interface KyselyDatabase {
  posts: Kyselify<typeof posts>;
}

export const db = new Kysely<KyselyDatabase>({
  dialect: new PostgresDialect({
    pool: createPool({
      max: 1,
    }),
  }),
  plugins: [new CamelCasePlugin()],
});


When I do the following query:
export const getPosts = async () => {
  const posts = await db
    .selectFrom("posts")
    .select(["title", "id"])
    .execute();
  return posts ?? null;
};
export const getPosts = async () => {
  const posts = await db
    .selectFrom("posts")
    .select(["title", "id"])
    .execute();
  return posts ?? null;
};


In vscode, I get the following type:
const getPosts: () => Promise<{
  [x: string]: any;
}[]>
const getPosts: () => Promise<{
  [x: string]: any;
}[]>


It doesn't infer the title and id types automatically so I have a bunch of type error in my code when using posts returned value. Am I doing something wrong or there is a problem with Kyselify?
Drizzle TeamJoin
The official Discord for all Drizzle related projects, such as Drizzle ORM, Drizzle Kit, Drizzle Studio and more!
11,879Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Not type-safe [x:string]: any
Drizzle TeamDTDrizzle Team / help
2y ago
Randomly losing types for tables.
Drizzle TeamDTDrizzle Team / help
6mo ago
Losing custom $types in pg jsonb using drizzle-zod
Drizzle TeamDTDrizzle Team / help
2y ago
[x: string]: never
Drizzle TeamDTDrizzle Team / help
12mo ago