-
Notifications
You must be signed in to change notification settings - Fork 157
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
unevaluatedProperties
failed verification when combined with Type.Intersect
and Type.Union
#889
Comments
@eygsoft Hi! Thanks for reporting! Yes, this looks like a bug. At this stage, I don't think I'll be able to take a look into the issue until the weekend at the earliest (as I am currently tied up with some other work), however you may be able to workaround this issue if you can reshape the schematics into the following. const A = Type.Object({
a: Type.String(),
b: Type.String()
}, { additionalProperties: false })
const B = Type.Object({
a: Type.String(),
c: Type.String()
}, { additionalProperties: false })
const T = Type.Union([A, B]) // T = { a: string, b: string } | { a: string, c: string } This issue actually crosses over with some other areas of the library where I'm looking to implement a distributive evaluate similar to the following.... type T = (
{ x: number }
) & (
{ y: number } |
{ z: number }
)
// non-distributive: where passing y | z is observed as unevaluated properties
type A = {[K in keyof T]: T[K]} & {} // type A = { x: number }
// distributive: where y | z are distributed with outer property x
type E<T> = {[K in keyof T]: T[K]} & {}
type B = E<T> // type B = { x: number; y: number; } |
// { x: number; z: number; } Note that TypeBox observes the validating schematic as Will keep you posted on any changes here. |
Thank you. The method I used is exactly the solution you mentioned, and it works very well. I just discovered this issue and I hope this great project can be more perfect. Thank you again! |
@eygsoft Hiya, Hey, going to close this one out as the workaround sounded like it solved the issue. A lot of this work fits under the umbrella of evaluated types which is due before the end of the year (hopefully). This should provide better options for distributive union types inline with the types mentioned on this issue. Will be good when it lands :) Will close up for now. |
First of all, thank you very much. Recently, there is a requirement similar to
{ a: string } & ({ b: string } | { c: string })
:TypeBox version: 0.32.31
Finally, thank you again!
The text was updated successfully, but these errors were encountered: