Type error: Type parameter has a circular constraint
Hi all! Trying to figure out this error I'm getting when running
next build
. Thought I'd drop it here in case anyone else has run into it or has any tips for debugging:
12 Replies
So, I think this is related to the zod integration, but still exploring.
have similar issues.
Also, some strange issues relating to zod happen.
For example a schema like
z.object({ key: z.string() })
becomes a type of { key?: string}
- the object keys become optional in type definitions.Your issue with keys being optional is likely due to not having strict: true set in your tsconfig. Can you check that?
Might as well throw in
strickNullCheck
in your tsconfig.👍 Ohhh, thank's! Yes, that fixed the issue.
In addition to you'r mentioned issue, I also get:
I was finally able to move past this error (so far) - by setting skipLibCheck on my NextJs project. It's obviously not ideal, but that's what I get for building a giant mono-repo with Nx.
Thanks, this worked for me too.
Yes, it's not ideal, but it is a workaround for now. But now I'm able to build again at all. I think it will be fixed in one of the next releases.
What makes you say that? Is there a GH issue I can follow? Just curious, were you using NextJS or in a monorepo? I’m just curious what the cause is
I'm using a monorepo without nextjs
my setup:
"typescript": "^5.1.6"
"mysql2": "^3.6.0",
"drizzle-orm": "^0.28.2",
"zod": "^3.21.4"
and tried with node 18 and 20
I did not open a github issue yet, as I was come across this thread here via google
Ok, just curious! Glad we’re both up and running again
Note that
skipLibCheck
is a common optimization setting that is turned on in monorepos, since you generally trust that the libraries that you are using are not going to be released with any type errors in them.skipLibCheck
should typically be enabled in your projects. You don't need to check the libraries' internal types, they may often break because of TS version mismatch, even though the public API will work fine.
The most common use case is when the library was built using a newer/different version of TS than the one used in your project.