drizzle-team / drizzle-team/drizzle-orm

[BUG]:124 type errors when running via NestJS

Open
#4,299 3 comments 1 reaction 0 assignees View on GitHub
bug
Dominant language
TypeScript
Stars
35.8k
Forks
1.6k
Avg merge
2d 7h
Merged PRs (30d)
4

Description

### Report hasn't been filed before.

- [x] I have verified that the bug I'm about to report hasn't been filed before.

### What version of `drizzle-orm` are you using?

0.40.1

### What version of `drizzle-kit` are you using?

0.30.5

### Other packages

_No response_

### Describe the Bug

When trying to run a NestJS app using Drizzle, I get 124 type errors, all related to Drizzle-ORM.

Should I be running an older version? Is 0.40.1 a dev branch or something? I can't imagine this many type errors making it through code review.

**package.json (all set to latest as of 3.20.2025):**
"dependencies": {
"@nestjs/common": "^11.0.12",
"@nestjs/config": "^4.0.1",
"@nestjs/core": "^11.0.12",
"@nestjs/platform-express": "^11.0.12",
"@types/cors": "^2.8.17",
"class-transformer": "^0.5.1",
"class-validator": "^0.14.1",
"cors": "^2.8.5",
"dotenv": "^16.4.7",
"drizzle-orm": "^0.40.1",
"pg": "^8.14.1",
"reflect-metadata": "^0.2.2",
"rxjs": "^7.8.2"
},
"devDependencies": {
"@eslint/eslintrc": "^3.3.0",
"@eslint/js": "^9.22.0",
"@nestjs/cli": "^11.0.5",
"@nestjs/schematics": "^11.0.2",
"@nestjs/testing": "^11.0.12",
"@swc/cli": "^0.6.0",
"@swc/core": "^1.11.11",
"drizzle-kit": "^0.30.5",
"@types/express": "^5.0.1",
"@types/jest": "^29.5.14",
"@types/node": "^22.13.10",
"@types/pg": "8.11.11",
"@types/supertest": "^6.0.2",
"eslint": "^9.22.0",
"globals": "^16.0.0",
"jest": "^29.7.0",
"source-map-support": "^0.5.21",
"supertest": "^7.1.0",
"ts-jest": "^29.2.6",
"ts-loader": "^9.5.2",
"ts-node": "^10.9.2",
"tsconfig-paths": "^4.2.0",
"typescript": "^5.8.2",
"typescript-eslint": "^8.27.0"
},

**tsconfig:**
"compilerOptions": {
"module": "NodeNext",
"declaration": true,
"removeComments": false,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"allowSyntheticDefaultImports": true,
"lib": [
"ES2023",
"DOM",
"DOM.Iterable",
"ESNext"
],
"moduleResolution": "nodenext",
"resolveJsonModule": true,
"target": "ESNext",
"strict": true,
"sourceMap": true,
"outDir": "./dist",
"baseUrl": "./",
"incremental": true,
"strictNullChecks": true,
"forceConsistentCasingInFileNames": true,
"noImplicitAny": true,
"strictBindCallApply": false,
"noFallthroughCasesInSwitch": false,
}
`

**List of errors:**
`
node_modules/drizzle-orm/gel-core/query-builders/query.d.cts:23:22 - error TS2420: Class 'GelRelationalQuery' incorrectly implements interface 'SQLWrapper'.
Property 'getSQL' is missing in type 'GelRelationalQuery' but required in type 'SQLWrapper'.

23 export declare class GelRelationalQuery extends QueryPromise implements RunnableQuery, SQLWrapper {
~~~~~~~~~~~~~~~~~~

node_modules/drizzle-orm/sql/sql.d.cts:50:5
50 getSQL(): SQL;
~~~~~~~~~~~~~~
'getSQL' is declared here.

node_modules/drizzle-orm/gel-core/query-builders/query.d.ts:23:22 - error TS2420: Class 'GelRelationalQuery' incorrectly implements interface 'SQLWrapper'.
Property 'getSQL' is missing in type 'GelRelationalQuery' but required in type 'SQLWrapper'.

23 export declare class GelRelationalQuery extends QueryPromise implements RunnableQuery, SQLWrapper {
~~~~~~~~~~~~~~~~~~

node_modules/drizzle-orm/sql/sql.d.ts:50:5
50 getSQL(): SQL;
~~~~~~~~~~~~~~
'getSQL' is declared here.

node_modules/drizzle-orm/gel-core/roles.d.cts:7:22 - error TS2559: Type 'GelRole' has no properties in common with type 'GelRoleConfig'.

7 export declare class GelRole implements GelRoleConfig {
~~~~~~~

node_modules/drizzle-orm/gel-core/roles.d.ts:7:22 - error TS2559: Type 'GelRole' has no properties in common with type 'GelRoleConfig'.

7 export declare class GelRole implements GelRoleConfig {
~~~~~~~

node_modules/drizzle-orm/mysql-core/db.d.cts:1:38 - error TS2307: Cannot find module 'mysql2/promise' or its corresponding type declarations.

1 import type { ResultSetHeader } from 'mysql2/promise';
~~~~~~~~~~~~~~~~

node_modules/drizzle-orm/mysql-core/db.d.ts:1:38 - error TS2307: Cannot find module 'mysql2/promise' or its corresponding type declarations.

1 import type { ResultSetHeader } from 'mysql2/promise';
~~~~~~~~~~~~~~~~

node_modules/drizzle-orm/mysql-core/query-builders/delete.d.cts:36:22 - error TS2420: Class 'MySqlDeleteBase' incorrectly implements interface 'SQLWrapper'.
Property 'getSQL' is missing in type 'MySqlDeleteBase' but required in type 'SQLWrapper'.

36 export declare class MySqlDeleteBase extends QueryPromise> implements SQLWrapper {
~~~~~~~~~~~~~~~

node_modules/drizzle-orm/sql/sql.d.cts:50:5
50 getSQL(): SQL;
~~~~~~~~~~~~~~
'getSQL' is declared here.

node_modules/drizzle-orm/mysql-core/query-builders/delete.d.ts:36:22 - error TS2420: Class 'MySqlDeleteBase' incorrectly implements interface 'SQLWrapper'.
Property 'getSQL' is missing in type 'MySqlDeleteBase' but required in type 'SQLWrapper'.

36 export declare class MySqlDeleteBase extends QueryPromise> implements SQLWrapper {
~~~~~~~~~~~~~~~

node_modules/drizzle-orm/sql/sql.d.ts:50:5
50 getSQL(): SQL;
~~~~~~~~~~~~~~
'getSQL' is declared here.

node_modules/drizzle-orm/mysql-core/query-builders/select.d.cts:249:244 - error TS2344: Type 'string' does not satisfy the constraint 'keyof this & string'.
Type 'string' is not assignable to type 'keyof this & string'.
Type 'string' is not assignable to type 'keyof this'.
Type '"session"' is not assignable to type '"_" | "getSQL" | "as" | "union" | "intersect" | "except" | "offset" | "limit" | "for" | "where" | "orderBy" | "leftJoin" | "rightJoin" | "innerJoin" | "fullJoin" | "toSQL" | "$dynamic" | ... 4 more ... | "exceptAll"'.

249 union: >(rightSelection: ((setOperators: GetMySqlSetOperators) => SetOperatorRightSelect) | SetOperatorRightSelect) => MySqlSelectWithout;

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

node_modules/drizzle-orm/mysql-core/query-builders/select.d.cts:275:247 - error TS2344: Type 'string' does not satisfy the constraint 'keyof this & string'.
Type 'string' is not assignable to type 'keyof this & string'.
Type 'string' is not assignable to type 'keyof this'.
Type '"session"' is not assignable to type '"_" | "getSQL" | "as" | "union" | "intersect" | "except" | "offset" | "limit" | "for" | "where" | "orderBy" | "leftJoin" | "rightJoin" | "innerJoin" | "fullJoin" | "toSQL" | "$dynamic" | ... 4 more ... | "exceptAll"'.

275 unionAll: >(rightSelection: ((setOperators: GetMySqlSetOperators) => SetOperatorRightSelect) | SetOperatorRightSelect) => MySqlSelectWithout;

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

node_modules/drizzle-orm/mysql-core/query-builders/select.d.cts:301:248 - error TS2344: Type 'string' does not satisfy the constraint 'keyof this & string'.
Type 'string' is not assignable to type 'keyof this & string'.
Type 'string' is not assignable to type 'keyof this'.
Type '"session"' is not assignable to type '"_" | "getSQL" | "as" | "union" | "intersect" | "except" | "offset" | "limit" | "for" | "where" | "orderBy" | "leftJoin" | "rightJoin" | "innerJoin" | "fullJoin" | "toSQL" | "$dynamic" | ... 4 more ... | "exceptAll"'.

301 intersect: >(rightSelection: ((setOperators: GetMySqlSetOperators) => SetOperatorRightSelect) | SetOperatorRightSelect) => MySqlSelectWithout;

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

node_modules/drizzle-orm/mysql-core/query-builders/select.d.cts:342:251 - error TS2344: Type 'string' does not satisfy the constraint 'keyof this & string'.
Type 'string' is not assignable to type 'keyof this & string'.
Type 'string' is not assignable to type 'keyof this'.
Type '"session"' is not assignable to type '"_" | "getSQL" | "as" | "union" | "intersect" | "except" | "offset" | "limit" | "for" | "where" | "orderBy" | "leftJoin" | "rightJoin" | "innerJoin" | "fullJoin" | "toSQL" | "$dynamic" | ... 4 more ... | "exceptAll"'.

342 intersectAll: >(rightSelection: ((setOperators: GetMySqlSetOperators) => SetOperatorRightSelect) | SetOperatorRightSelect) => MySqlSelectWithout;

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

node_modules/drizzle-orm/mysql-core/query-builders/select.d.cts:368:245 - error TS2344: Type 'string' does not satisfy the constraint 'keyof this & string'.
Type 'string' is not assignable to type 'keyof this & string'.
Type 'string' is not assignable to type 'keyof this'.
Type '"session"' is not assignable to type '"_" | "getSQL" | "as" | "union" | "intersect" | "except" | "offset" | "limit" | "for" | "where" | "orderBy" | "leftJoin" | "rightJoin" | "innerJoin" | "fullJoin" | "toSQL" | "$dynamic" | ... 4 more ... | "exceptAll"'.

368 except: >(rightSelection: ((setOperators: GetMySqlSetOperators) => SetOperatorRightSelect) | SetOperatorRightSelect) => MySqlSelectWithout;

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

node_modules/drizzle-orm/mysql-core/query-builders/select.d.cts:409:248 - error TS2344: Type 'string' does not satisfy the constraint 'keyof this & string'.
Type 'string' is not assignable to type 'keyof this & string'.
Type 'string' is not assignable to type 'keyof this'.
Type '"session"' is not assignable to type '"_" | "getSQL" | "as" | "union" | "intersect" | "except" | "offset" | "limit" | "for" | "where" | "orderBy" | "leftJoin" | "rightJoin" | "innerJoin" | "fullJoin" | "toSQL" | "$dynamic" | ... 4 more ... | "exceptAll"'.

409 exceptAll: >(rightSelection: ((setOperators: GetMySqlSetOperators) => SetOperatorRightSelect) | SetOperatorRightSelect) => MySqlSelectWithout;

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

node_modules/drizzle-orm/mysql-core/query-builders/select.d.cts:561:22 - error TS2515: Non-abstract class 'MySqlSelectBase' does not implement inherited abstract member getSQL from class 'MySqlSelectQueryBuilderBase'.

561 export declare class MySqlSelectBase = TTableName extends string ? Record : {}, TDynamic extends boolean = false, TExcludedMethods extends string = never, TResult = SelectResult[], TSelectedFields = BuildSubquerySelection> extends MySqlSelectQueryBuilderBase {
~~~~~~~~~~~~~~~

node_modules/drizzle-orm/mysql-core/query-builders/select.d.ts:249:244 - error TS2344: Type 'string' does not satisfy the constraint 'keyof this & string'.
Type 'string' is not assignable to type 'keyof this & string'.
Type 'string' is not assignable to type 'keyof this'.
Type '"session"' is not assignable to type '"_" | "getSQL" | "as" | "union" | "intersect" | "except" | "offset" | "limit" | "for" | "where" | "orderBy" | "leftJoin" | "rightJoin" | "innerJoin" | "fullJoin" | "toSQL" | "$dynamic" | ... 4 more ... | "exceptAll"'.

249 union: >(rightSelection: ((setOperators: GetMySqlSetOperators) => SetOperatorRightSelect) | SetOperatorRightSelect) => MySqlSelectWithout;

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

node_modules/drizzle-orm/mysql-core/query-builders/select.d.ts:275:247 - error TS2344: Type 'string' does not satisfy the constraint 'keyof this & string'.
Type 'string' is not assignable to type 'keyof this & string'.
Type 'string' is not assignable to type 'keyof this'.
Type '"session"' is not assignable to type '"_" | "getSQL" | "as" | "union" | "intersect" | "except" | "offset" | "limit" | "for" | "where" | "orderBy" | "leftJoin" | "rightJoin" | "innerJoin" | "fullJoin" | "toSQL" | "$dynamic" | ... 4 more ... | "exceptAll"'.

275 unionAll: >(rightSelection: ((setOperators: GetMySqlSetOperators) => SetOperatorRightSelect) | SetOperatorRightSelect) => MySqlSelectWithout;

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

node_modules/drizzle-orm/mysql-core/query-builders/select.d.ts:301:248 - error TS2344: Type 'string' does not satisfy the constraint 'keyof this & string'.
Type 'string' is not assignable to type 'keyof this & string'.
Type 'string' is not assignable to type 'keyof this'.
Type '"session"' is not assignable to type '"_" | "getSQL" | "as" | "union" | "intersect" | "except" | "offset" | "limit" | "for" | "where" | "orderBy" | "leftJoin" | "rightJoin" | "innerJoin" | "fullJoin" | "toSQL" | "$dynamic" | ... 4 more ... | "exceptAll"'.

301 intersect: >(rightSelection: ((setOperators: GetMySqlSetOperators) => SetOperatorRightSelect) | SetOperatorRightSelect) => MySqlSelectWithout;

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

node_modules/drizzle-orm/mysql-core/query-builders/select.d.ts:342:251 - error TS2344: Type 'string' does not satisfy the constraint 'keyof this & string'.
Type 'string' is not assignable to type 'keyof this & string'.
Type 'string' is not assignable to type 'keyof this'.
Type '"session"' is not assignable to type '"_" | "getSQL" | "as" | "union" | "intersect" | "except" | "offset" | "limit" | "for" | "where" | "orderBy" | "leftJoin" | "rightJoin" | "innerJoin" | "fullJoin" | "toSQL" | "$dynamic" | ... 4 more ... | "exceptAll"'.

342 intersectAll: >(rightSelection: ((setOperators: GetMySqlSetOperators) => SetOperatorRightSelect) | SetOperatorRightSelect) => MySqlSelectWithout;

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

node_modules/drizzle-orm/mysql-core/query-builders/select.d.ts:368:245 - error TS2344: Type 'string' does not satisfy the constraint 'keyof this & string'.
Type 'string' is not assignable to type 'keyof this & string'.
Type 'string' is not assignable to type 'keyof this'.
Type '"session"' is not assignable to type '"_" | "getSQL" | "as" | "union" | "intersect" | "except" | "offset" | "limit" | "for" | "where" | "orderBy" | "leftJoin" | "rightJoin" | "innerJoin" | "fullJoin" | "toSQL" | "$dynamic" | ... 4 more ... | "exceptAll"'.

368 except: >(rightSelection: ((setOperators: GetMySqlSetOperators) => SetOperatorRightSelect) | SetOperatorRightSelect) => MySqlSelectWithout;

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

node_modules/drizzle-orm/mysql-core/query-builders/select.d.ts:409:248 - error TS2344: Type 'string' does not satisfy the constraint 'keyof this & string'.
Type 'string' is not assignable to type 'keyof this & string'.
Type 'string' is not assignable to type 'keyof this'.
Type '"session"' is not assignable to type '"_" | "getSQL" | "as" | "union" | "intersect" | "except" | "offset" | "limit" | "for" | "where" | "orderBy" | "leftJoin" | "rightJoin" | "innerJoin" | "fullJoin" | "toSQL" | "$dynamic" | ... 4 more ... | "exceptAll"'.

409 exceptAll: >(rightSelection: ((setOperators: GetMySqlSetOperators) => SetOperatorRightSelect) | SetOperatorRightSelect) => MySqlSelectWithout;

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

node_modules/drizzle-orm/mysql-core/query-builders/select.d.ts:561:22 - error TS2515: Non-abstract class 'MySqlSelectBase' does not implement inherited abstract member getSQL from class 'MySqlSelectQueryBuilderBase'.

561 export declare class MySqlSelectBase = TTableName extends string ? Record : {}, TDynamic extends boolean = false, TExcludedMethods extends string = never, TResult = SelectResult[], TSelectedFields = BuildSubquerySelection> extends MySqlSelectQueryBuilderBase {
~~~~~~~~~~~~~~~

node_modules/drizzle-orm/mysql-core/query-builders/select.types.d.cts:136:1149 - error TS2344: Type 'MySqlSetOperatorExcludedMethods' does not satisfy the constraint '"_" | "getSQL" | "as" | "union" | "intersect" | "except" | "offset" | "limit" | "for" | "where" | "orderBy" | "execute" | "leftJoin" | "rightJoin" | "innerJoin" | "fullJoin" | "toSQL" | ... 10 more ... | "iterator"'.
Type '"session"' is not assignable to type '"_" | "getSQL" | "as" | "union" | "intersect" | "except" | "offset" | "limit" | "for" | "where" | "orderBy" | "execute" | "leftJoin" | "rightJoin" | "innerJoin" | "fullJoin" | "toSQL" | ... 10 more ... | "iterator"'.

136 export type MySqlCreateSetOperatorFn = , TRest extends MySqlSetOperatorWithResult[], TPreparedQueryHKT extends PreparedQueryHKTBase = PreparedQueryHKTBase, TNullabilityMap extends Record = TTableName extends string ? Record : {}, TDynamic extends boolean = false, TExcludedMethods extends string = never, TResult extends any[] = SelectResult[], TSelectedFields extends ColumnsSelection = BuildSubquerySelection>(leftSelect: MySqlSetOperatorInterface, rightSelect: SetOperatorRightSelect, ...restSelects: SetOperatorRestSelect) => MySqlSelectWithout, false, MySqlSetOperatorExcludedMethods, true>;
`

---

I removed a large number of the errors due to a character limit on these reports, but there are currently 124.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.