Open trompx opened 1 month ago
drizzle-orm
0.31.0
drizzle-kit
0.20.13
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()], });
When I do the following query:
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; }[]>
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?
I should get the following type:
const getPosts: () => Promise<{ title: string; id: string; }[]>
Vscode - Linux
What version of
drizzle-orm
are you using?0.31.0
What version of
drizzle-kit
are you using?0.20.13
Describe the Bug
Hello.
I have some types problems using kysely with drizzle. I have the following config:
When I do the following query:
In vscode, I get the following type:
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?
Expected behavior
I should get the following type:
Environment & setup
Vscode - Linux