typescript-go icon indicating copy to clipboard operation
typescript-go copied to clipboard

Drizzle queries fail typecheck

Open jansedlon opened this issue 7 months ago • 5 comments

I'm using Drizzle ORM in my project and when i enabled the experimental Typescript Native VSCode extension (and also before that when i built the extension from main), i have many places where the typechecker fails.

Do you need a repro or do you know about these issues?

Examples:

Image

Image

jansedlon avatar May 23 '25 06:05 jansedlon

A repro would be helpful.

jakebailey avatar May 23 '25 06:05 jakebailey

@jakebailey Here's the repro. I'm seeing more issues for example in Prisma but i'll wait when this gets fixed and see if it still occurs

jansedlon avatar May 23 '25 06:05 jansedlon

I get the same error. Seems to be because user code import the type from .d.ts but drizzle is internally importing the types from d.cts. This is the error it spits out.

Type 'import("/home/a/Documents/tsgo-repro/node_modules/drizzle-orm/sql/sql").SQL<unknown>' is not assignable to type 'import("/home/a/Documents/tsgo-repro/node_modules/drizzle-orm/sql/sql").SQL<unknown>'. Two different types with this name exist, but they are unrelated.
          Types have separate declarations of a private property 'shouldInlineParams'.

Deleting the .d.cts removes this error but then the type checking fails because it cannot find the getSQL() defnintion.

Removing the where from the repro @jansedlon gave, removes all errors, even with the d.cts files there.

aadito123 avatar May 27 '25 03:05 aadito123

@aadito123 Can confirm. But in the db.insert example there's no where and it still fails. Might be the same issue, just different source

jansedlon avatar May 27 '25 05:05 jansedlon

@jansedlon ya I was just giving context to the error. I'm getting errors on just about every drizzle operation in my codebase

aadito123 avatar May 27 '25 05:05 aadito123

seems to be fixed in the recent release

aadito123 avatar Jun 04 '25 03:06 aadito123

Yep, seems like it, closing, thank you TS team

jansedlon avatar Jun 04 '25 05:06 jansedlon