You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have same issue with 9 types in OneOf<...>. Clearly it something wrong with OneOf definition.
I using [email protected].
Edited: looks like there is already an issue with this problem: #1019
Yup see my comment on #1019 for more explanation (and #894 for even more explanation, if you’re willing). It’s not necessarily that OneOf<> is wrong; just that TypeScript doesn’t have a good built-in for XOR comparisons, which are essential parts of OpenAPI schemas. So we do the best we can given the tools we have.
However, I’m applying the fix suggested in #1019 by falling back to unions at a complexity of > 5 determined arbitrarily. Ideally, when the union is too complex, it will naturally act as an XOR without the helper type. But at simpler unions, the XOR is needed.
Description
I have a response where the generated types looks like this:
The typescript compiler errors at the usage of
OneOf
with the following error:Type instantiation is excessively deep and possibly infinite
.Would it be possible to detect where issues like this could occur and use unions instead?
So in my case it would be something like:
The text was updated successfully, but these errors were encountered: