Skip to content

Conversation

@mnahkies
Copy link
Owner

@mnahkies mnahkies commented Dec 24, 2025

  • introduces a new intermediate type for intersection and union, making handling of compositions in schema/type builder easier to reason about
    • though oneOf is being treated as equivalent to anyOf for now
  • improves normalization process treat the base schema as part of an allOf/intersection when an object schema is part of a composite, fixing previous information loss
  • improves handling of oneOf / anyOf to support "looking up" property definitions from the parent object
    • this is still limited, eg: won't traverse up multiple-levels

after this change it appears EmptyObject is no-longer emitted by any of the integration-tests - which is generally a good sign


type IRTypeIntersection = {type: "type-intersection"; types: IRType[]}
type IRTypeUnion = {type: "type-union"; types: IRType[]}
type IRTypeOther = string
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Eventually will probably aim to leave the typescript types (and schema code) in a "non-stringy" representation all the way through to the emit phase.

This will be particularly important for contextual alterations (eg; readonly / writeonly modifiers)


// TODO: https://github.com/hapijs/joi/issues/3057
it.skip("can intersect unions", async () => {
it("can intersect unions", async () => {
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was somewhat forced to fix this, as integration tests started outputting intersected unions due to the richer anyOf / oneOf / allOf support.

The "fix" is rather hacky, but seems to work well enough

})
})

async function getActualFromModel(
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Plan to later properly flesh out a set of test cases using in-line IRModel's directly, for cases where $ref isn't required.

}

export interface IRModelObject extends IRModelBase {
allOf: MaybeIRModel[]
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

after this change, it's only the input normalization that has to deal with things being an object, composition or both at once.

@mnahkies mnahkies marked this pull request as ready for review December 29, 2025 16:01
@mnahkies mnahkies enabled auto-merge (squash) December 29, 2025 16:01
@mnahkies mnahkies merged commit 8c7de1f into main Dec 29, 2025
22 checks passed
@mnahkies mnahkies deleted the mn/fix/allOf branch December 29, 2025 16:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants