drizzle-orm: [BUG]: Broken typings on Visual Studio Code@1.91.0 using Typescript@5.5
What version of drizzle-orm are you using?
0.31.1
What version of drizzle-kit are you using?
0.22.2
Describe the Bug
After the update of Visual Studio Code to the latest (1.91.0) version, typescript started throwing errors like ones below, for every query. I am working in the nx monorepo, so I had to install typescript in the root of the project and use workspace version of typescript to fix the error messages, but that’s just a temporary fix. By default this version of VSC uses typescript 5.5, everything works fine on 5.4.
No overload matches this call.
Overload 1 of 3, '(left: Column<ColumnBaseConfig<ColumnDataType, string>, object, object>, right: unknown): SQL<unknown>', gave the following error.
Argument of type 'PgColumn<{ name: "id"; tableName: "deal"; dataType: "string"; columnType: "PgVarchar"; data: string; driverParam: string; notNull: true; hasDefault: true; enumValues: [string, ...string[]]; baseColumn: never; }, {}, {}>' is not assignable to parameter of type 'Column<ColumnBaseConfig<ColumnDataType, string>, object, object>'.
Types of property 'table' are incompatible.
Property '[IsDrizzleTable]' is missing in type 'PgTable<TableConfig>' but required in type 'Table<TableConfig<Column<any, object, object>>>'.
Overload 2 of 3, '(left: Aliased<string>, right: string | SQLWrapper): SQL<unknown>', gave the following error.
Argument of type 'PgColumn<{ name: "id"; tableName: "deal"; dataType: "string"; columnType: "PgVarchar"; data: string; driverParam: string; notNull: true; hasDefault: true; enumValues: [string, ...string[]]; baseColumn: never; }, {}, {}>' is not assignable to parameter of type 'Aliased<string>'.
Type 'PgColumn<{ name: "id"; tableName: "deal"; dataType: "string"; columnType: "PgVarchar"; data: string; driverParam: string; notNull: true; hasDefault: true; enumValues: [string, ...string[]]; baseColumn: never; }, {}, {}>' is missing the following properties from type 'Aliased<string>': sql, fieldAlias
Overload 3 of 3, '(left: SQLWrapper, right: unknown): SQL<unknown>', gave the following error.
Argument of type 'PgColumn<{ name: "id"; tableName: "deal"; dataType: "string"; columnType: "PgVarchar"; data: string; driverParam: string; notNull: true; hasDefault: true; enumValues: [string, ...string[]]; baseColumn: never; }, {}, {}>' is not assignable to parameter of type 'SQLWrapper'.
The types returned by 'getSQL()' are incompatible between these types.
Type 'import("/Users/nightspite/Code/polubee/node_modules/.pnpm/drizzle-orm@0.31.1_postgres@3.4.3/node_modules/drizzle-orm/sql/sql").SQL<unknown>' is not assignable to type 'import("/Users/nightspite/Code/polubee/node_modules/.pnpm/drizzle-orm@0.31.1_react@18.2.0/node_modules/drizzle-orm/sql/sql").SQL<unknown>'.
Types have separate declarations of a private property 'shouldInlineParams'.ts(2769)
table.d.cts(29, 5): '[IsDrizzleTable]' is declared here.
Expected behavior
No error warnings
Environment & setup
macos sonoma 14.4.1 vsc 1.91.0 typescript 5.5 node 20 pnpm 8.6.10 nx 19.2.2 eslint 8.55.0
About this issue
- Original URL
- State: open
- Created 2 years ago
- Reactions: 19
- Comments: 15
I was able to solve this. Here’s my repo structure using turborepo and pnpm workspaces:
Previously:
dbpackage. I was referencing this package in thewebapp.drizzle-ormas a dependency (not dev-dependency) to bothdbpackage (obviously) andwebapp (cause I needeqandandoperators)drizzle-ormpackage in thepnpm-lock.yamlfile.New setup:
webapp and imported required operators from thedbpackage itself.Import changes done in
webapp:Before
After
I have crossed check that this works in both development mode and production build for remix app
I was able to resolve this same issue by deleting the lockfile, removing the
node_modulesdirectory and reinstalling.but it still got types errors if using callback like on
whereclause here:the errors:
but if the
eqanduserTableare imported from@repo/dbit is working:i just want to let you know @L-Mario564, sorry for tagging😄
It works for me, thanks!!