Argument of type 'SQL<unknown>' is not assignable to parameter

I have the following:
const projects = await db
.select()
.from(project)
.where(eq(project.ownerId, userId));
const projects = await db
.select()
.from(project)
.where(eq(project.ownerId, userId));
and the eq() gives an error like:
Argument of type 'SQL<unknown>' is not assignable to parameter of type 'SQL<unknown> | ((aliases: { id: MySqlColumn<{ data: string; driverParam: string | number; notNull: true; hasDefault: true; tableName: "Project"; }>; name: MySqlColumn<{ data: string; driverParam: string | number; hasDefault: false; notNull: true; tableName: "Project"; }>; description: MySqlColumn<...>; createdAt: My...'.

Type 'Name' is not assignable to type 'Chunk'.
Property 'encoder' is missing in type 'Name' but required in type 'Param<unknown, unknown>'.ts(2345)
index.d.ts(80, 14): 'encoder' is declared here.
Argument of type 'SQL<unknown>' is not assignable to parameter of type 'SQL<unknown> | ((aliases: { id: MySqlColumn<{ data: string; driverParam: string | number; notNull: true; hasDefault: true; tableName: "Project"; }>; name: MySqlColumn<{ data: string; driverParam: string | number; hasDefault: false; notNull: true; tableName: "Project"; }>; description: MySqlColumn<...>; createdAt: My...'.

Type 'Name' is not assignable to type 'Chunk'.
Property 'encoder' is missing in type 'Name' but required in type 'Param<unknown, unknown>'.ts(2345)
index.d.ts(80, 14): 'encoder' is declared here.
What could be the problem?
5 Replies
Dan
Dan2y ago
This is a weird one. Could you post your tsconfig.json?
mmurto
mmurtoOP2y ago
Sure! The root one:
{
"compilerOptions": {
"target": "es2017",
"lib": ["dom", "dom.iterable", "esnext"],
"allowJs": true,
"skipLibCheck": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"noEmit": true,
"esModuleInterop": true,
"module": "esnext",
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"jsx": "preserve",
"incremental": true,
"noUncheckedIndexedAccess": true,
"paths": {
"@/*": [
"./*"
]
}
},
"include": [".eslintrc.cjs"]
}
{
"compilerOptions": {
"target": "es2017",
"lib": ["dom", "dom.iterable", "esnext"],
"allowJs": true,
"skipLibCheck": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"noEmit": true,
"esModuleInterop": true,
"module": "esnext",
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"jsx": "preserve",
"incremental": true,
"noUncheckedIndexedAccess": true,
"paths": {
"@/*": [
"./*"
]
}
},
"include": [".eslintrc.cjs"]
}
The db package has:
{
"extends": "../../tsconfig.json",
"include": [
"./**/*.ts"
]
}
{
"extends": "../../tsconfig.json",
"include": [
"./**/*.ts"
]
}
and the server package:
{
"extends": "../../tsconfig.json",
"include": ["src", "index.ts", "transformer.ts"]
}
{
"extends": "../../tsconfig.json",
"include": ["src", "index.ts", "transformer.ts"]
}
Here's the tsc log:
@dcmnt/api:type-check: > @dcmnt/[email protected] type-check /Users/nn/Code/mm/dcmnt/packages/api
@dcmnt/api:type-check: > tsc --noEmit
@dcmnt/api:type-check:
@dcmnt/api:type-check: src/service/project.ts(27,12): error TS2345: Argument of type 'SQL<unknown>' is not assignable to parameter of type 'SQL<unknown> | ((aliases: { id: MySqlColumn<{ data: string; driverParam: string | number; notNull: true; hasDefault: true; tableName: "Project"; }>; name: MySqlColumn<{ data: string; driverParam: string | number; hasDefault: false; notNull: true; tableName: "Project"; }>; description: MySqlColumn<...>; createdAt: My...'.
@dcmnt/api:type-check: Type 'import("/Users/nn/Code/mm/dcmnt/node_modules/drizzle-orm/sql/index").SQL<unknown>' is not assignable to type 'import("/Users/nn/Code/mm/dcmnt/packages/db/node_modules/drizzle-orm/sql/index").SQL<unknown>'.
@dcmnt/api:type-check: Types of property 'queryChunks' are incompatible.
@dcmnt/api:type-check: Type 'import("/Users/nn/Code/mm/dcmnt/node_modules/drizzle-orm/sql/index").Chunk[]' is not assignable to type 'import("/Users/nn/Code/mm/dcmnt/packages/db/node_modules/drizzle-orm/sql/index").Chunk[]'.
@dcmnt/api:type-check: Type 'import("/Users/nn/Code/mm/dcmnt/node_modules/drizzle-orm/sql/index").Chunk' is not assignable to type 'import("/Users/nn/Code/mm/dcmnt/packages/db/node_modules/drizzle-orm/sql/index").Chunk'.
@dcmnt/api:type-check: Type 'Name' is not assignable to type 'Chunk'.
@dcmnt/api:type-check: Property 'encoder' is missing in type 'Name' but required in type 'Param<unknown, unknown>'.
@dcmnt/api:type-check:  ELIFECYCLE  Command failed with exit code 2.
@dcmnt/api:type-check: ERROR: command finished with error: command (/Users/nn/Code/mm/dcmnt/packages/api) pnpm run type-check exited (1)
@dcmnt/api:type-check: > @dcmnt/[email protected] type-check /Users/nn/Code/mm/dcmnt/packages/api
@dcmnt/api:type-check: > tsc --noEmit
@dcmnt/api:type-check:
@dcmnt/api:type-check: src/service/project.ts(27,12): error TS2345: Argument of type 'SQL<unknown>' is not assignable to parameter of type 'SQL<unknown> | ((aliases: { id: MySqlColumn<{ data: string; driverParam: string | number; notNull: true; hasDefault: true; tableName: "Project"; }>; name: MySqlColumn<{ data: string; driverParam: string | number; hasDefault: false; notNull: true; tableName: "Project"; }>; description: MySqlColumn<...>; createdAt: My...'.
@dcmnt/api:type-check: Type 'import("/Users/nn/Code/mm/dcmnt/node_modules/drizzle-orm/sql/index").SQL<unknown>' is not assignable to type 'import("/Users/nn/Code/mm/dcmnt/packages/db/node_modules/drizzle-orm/sql/index").SQL<unknown>'.
@dcmnt/api:type-check: Types of property 'queryChunks' are incompatible.
@dcmnt/api:type-check: Type 'import("/Users/nn/Code/mm/dcmnt/node_modules/drizzle-orm/sql/index").Chunk[]' is not assignable to type 'import("/Users/nn/Code/mm/dcmnt/packages/db/node_modules/drizzle-orm/sql/index").Chunk[]'.
@dcmnt/api:type-check: Type 'import("/Users/nn/Code/mm/dcmnt/node_modules/drizzle-orm/sql/index").Chunk' is not assignable to type 'import("/Users/nn/Code/mm/dcmnt/packages/db/node_modules/drizzle-orm/sql/index").Chunk'.
@dcmnt/api:type-check: Type 'Name' is not assignable to type 'Chunk'.
@dcmnt/api:type-check: Property 'encoder' is missing in type 'Name' but required in type 'Param<unknown, unknown>'.
@dcmnt/api:type-check:  ELIFECYCLE  Command failed with exit code 2.
@dcmnt/api:type-check: ERROR: command finished with error: command (/Users/nn/Code/mm/dcmnt/packages/api) pnpm run type-check exited (1)
Sorry bout the formatting 🙂
Dan
Dan2y ago
Ah, there's the issue - you have two different vesions of Drizzle in different folders, and try to use them both in a same file /Users/nn/Code/mm/dcmnt/packages/db/node_modules/drizzle-orm/sql/index /Users/nn/Code/mm/dcmnt/node_modules/drizzle-orm/sql/index
mmurto
mmurtoOP2y ago
Thanks! I'll try to fix that, thought of it as well but the versions in package.json's were the same, so thought they resolved to the same.
Dan
Dan2y ago
If you have a monorepo, you should probably hoist the Drizzle dependency for all packages to reuse the same one
Want results from more Discord servers?
Add your server