-
-
Notifications
You must be signed in to change notification settings - Fork 767
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BUG]: The inferred type of X cannot be named without a reference to ../../../../../node_modules/drizzle-zod/schema.types.internal.mjs #3732
Comments
Running into this as well, and the aforementioned workaround is not working either
|
"compilerOptions": {
"declaration": false,
"declarationMap": false,
"emitDeclarationOnly": false,
"noEmit": true
}, this seems to work for me |
Would love to solve this without setting |
getting this error in my api when I try to use this: messages: t
.jsonb()
.array()
.$type<CoreMessage[]>()
.notNull()
.default(sql`'{}'::jsonb[]`), |
Happened to me after updating drizzle-zod from Breaks all
|
+1, also running into this issue... import type { InferInsertModel, InferSelectModel } from "drizzle-orm";
import {
createInsertSchema,
createSelectSchema,
createUpdateSchema,
} from "drizzle-zod";
import { CallToAction } from "@acme/schema/call-to-action";
export type TCallToActionInsertSchema = InferInsertModel<typeof CallToAction>;
export type TCallToActionSelectSchema = InferSelectModel<typeof CallToAction>;
export type TCallToActionUpdateSchema = Partial<TCallToActionInsertSchema>;
export const ZCallToActionInsertSchema = createInsertSchema(CallToAction);
export const ZCallToActionSelectSchema = createSelectSchema(CallToAction);
export const ZCallToActionUpdateSchema = createUpdateSchema(CallToAction); all of the returns from the
When I try the |
Same here with |
Do you happen to have any updates on this? Is anyone working on PR to fix it? |
Any updates? |
Workaround without disabling declaration:
|
Awesome, almost worked for me. I have a tree, where a table references itself and has a
Edit: Looks like this is from a PG JSONB column in a table, which is typed using Edit 2: Workaround: Type the JSONB column as export const tLetters = pgTable(
'letters',
{
body: jsonb('body').$type<any[]>().notNull().default([]),
// ...
export type Letter = Omit<typeof tLetters.$inferSelect, 'body'> & {
body: LetterBody;
}; |
I got rid of this error by refining the field,
|
This worked great for me for anything without JSON fields. I also had a few JSON fields so @wbmrcb's suggestion helped for those too. Would love to see a proper fix to this soon though! |
Can someone provide steps to reproduce this bug? Mainly want a table and schema definition that causes this error alongside the full tsconfig.json file; as otherwise, I'm unable to reproduce. |
Just ran into this aswell. The aforementioned workarounds either dont work or are not viable with my setup. Would love to see this fixed. Using:
|
@kedom1337 Could you provide more info on how to reproduce this bug? (Read the comment above yours to see what I'm looking for). |
So much weird behavior, in addition to the inferred type issue. Also having a |
@L-Mario564 I just made a repro repo with a minimal example. Seems the issue shows up with You can find the repo here. Let me know if you run into issues replicating the bug using this: |
I think the common thread here is that this seems to happen in monorepo setups |
@jikyu I mean my example repo above isn't a monorepo -- it's a dead simple repo with 2 files. It occurs whenever emitting declarations on a project with module = esnext and moduleResolution = bundler. |
@slimshreydy I am getting this error in that exact same situation, although I am also in a monorepo and using declaration on that specific package (it's a package that is used to share types and schemas between backend and frontend) Reverting back to 0.5.1 also solved the issue for me (thanks @SpeedoPasanen ) |
@slimshreydy Thank you for providing the repo! Will take this from here. |
@Rick-Phoenix yep this seems to be an issue unique to 0.6.0+. That being said, 0.6.0+ adds support for arrays (finally!) so I really want to upgrade to that asap! |
I had a similar issue with trpc and drizzle after adding a json-typed column (postgres, pg-core).
Minimum example:
trpc router:
Which I could resolve by explicitly defining the json-column as a zod-object:
As there are already multiple comments in this thread with json examples, this might be a common cause. |
In my case I did not have any json columns in my tables |
Available in |
Thanks @AndriiSherman ! Tho it seems like 0.7.0 has the same issues. As mentioned by others too in #3645 (comment) , #4026 , and possibly #4016. For anyone coming across this: Downgrading |
Fwiw I have not had this same issue; upgrading to 0.7.0 fixed it for me. Here's my tsconfig for reference. (outDir/declaration properties are set because I used drizzle-zod as part of a package I publish for internal use)
|
Report hasn't been filed before.
What version of
drizzle-orm
are you using?0.38.0
What version of
drizzle-kit
are you using?0.30.0
Other packages
[email protected]
Describe the Bug
Since the latest update, all previously working drizzle-zod functions show a type error.
The inferred type of updateUserProfileSchema cannot be named without a reference to ../../../../../node_modules/drizzle-zod/schema.types.internal.mjs
Node.js v22.10.0
Bun v1.1.38
Turborepo v2.3.3
Workaround is disabling declaration and declarationMap in tsconfig.json:
The text was updated successfully, but these errors were encountered: