The inferred type of '<tableName>' cannot be named without a reference to '.pnpm/[email protected]

I'm trying to use the drizzle-zod but I keep getting this error... Any idea on where it comes from ? Thank you !
2 Replies
sevenwestonroads
sevenwestonroadsOP2y ago
Here's what's throwing the error; export const accountsInsertSchema = createInsertSchema(accounts); With accounts being a pgTable (defined without error). Here are my versions;
"drizzle-orm": "^0.25.4",
"drizzle-zod": "^0.4.1",
"drizzle-orm": "^0.25.4",
"drizzle-zod": "^0.4.1",
Ok I made it work; DISCLAIMER -> I'm using turborepo I uninstalled drizzle-zod globally, but installed it locally in my packages/database (ie. subfolder where my tables, types are defined) ------ But for the createInsertSchema I now got the following error
he inferred type of 'accountsSelectSchema' cannot be named without a reference to '.pnpm/[email protected]/node_modules/drizzle-orm/mysql-core'. This is likely not portable. A type annotation is necessary.ts(2742)
The inferred type of 'accountsSelectSchema' cannot be named without a reference to '.pnpm/[email protected]/node_modules/drizzle-orm/pg-core'. This is likely not portable. A type annotation is necessary.ts(2742)
The inferred type of 'accountsSelectSchema' cannot be named without a reference to '.pnpm/[email protected]/node_modules/drizzle-orm/sqlite-core'. This is likely not portable. A type annotation is necessary.ts(2742)
const accountsSelectSchema: ZodObject<Simplify<{ [K in keyof TTable["_"]["columns"]]: MaybeOptional<TTable["_"]["columns"][K], K extends keyof TRefine ? Assume<UnwrapValueOrUpdater<TRefine[K]>, ZodTypeAny> : GetZodType<...>, "select", TNoOptional>; }>, UnknownKeysParam, ZodTypeAny, {
...;
}, {
...;
}>
he inferred type of 'accountsSelectSchema' cannot be named without a reference to '.pnpm/[email protected]/node_modules/drizzle-orm/mysql-core'. This is likely not portable. A type annotation is necessary.ts(2742)
The inferred type of 'accountsSelectSchema' cannot be named without a reference to '.pnpm/[email protected]/node_modules/drizzle-orm/pg-core'. This is likely not portable. A type annotation is necessary.ts(2742)
The inferred type of 'accountsSelectSchema' cannot be named without a reference to '.pnpm/[email protected]/node_modules/drizzle-orm/sqlite-core'. This is likely not portable. A type annotation is necessary.ts(2742)
const accountsSelectSchema: ZodObject<Simplify<{ [K in keyof TTable["_"]["columns"]]: MaybeOptional<TTable["_"]["columns"][K], K extends keyof TRefine ? Assume<UnwrapValueOrUpdater<TRefine[K]>, ZodTypeAny> : GetZodType<...>, "select", TNoOptional>; }>, UnknownKeysParam, ZodTypeAny, {
...;
}, {
...;
}>
Dan
Dan2y ago
Did you try solutions from this thread? https://github.com/microsoft/TypeScript/issues/42873 I'm not sure what may cause it.
GitHub
The inferred type of "X" cannot be named without a reference to "Y"...
Bug Report 🔎 Search Terms inferred type cannot be named, symlink node_modules 🕗 Version & Regression Information I'm verifying the problem on the [email protected]. I've not tried older ...
Want results from more Discord servers?
Add your server