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

Mmmurto3/17/2023
I have the following:

  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.


What could be the problem?
Bbloberenober3/17/2023
This is a weird one. Could you post your tsconfig.json?
Mmmurto3/17/2023
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"]
}
Mmmurto3/17/2023
The db package has:

{
  "extends": "../../tsconfig.json",
  "include": [
    "./**/*.ts"
  ]
}

and the server package:

{
  "extends": "../../tsconfig.json",
  "include": ["src", "index.ts", "transformer.ts"]
}
Mmmurto3/17/2023
Here's the tsc log:

@dcmnt/api:type-check: > @dcmnt/api@0.1.0 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)
Mmmurto3/17/2023
Sorry bout the formatting 🙂
Bbloberenober3/17/2023
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
Bbloberenober3/17/2023
/Users/nn/Code/mm/dcmnt/packages/db/node_modules/drizzle-orm/sql/index
/Users/nn/Code/mm/dcmnt/node_modules/drizzle-orm/sql/index
Mmmurto3/18/2023
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.
Bbloberenober3/18/2023
If you have a monorepo, you should probably hoist the Drizzle dependency for all packages to reuse the same one