Skip to content

Version 1.4.2 - #1719

Merged
sinclairzx81 merged 4 commits into
mainfrom
object
Oct 17, 2026
Merged

sinclairzx81 merged 4 commits into
mainfrom
object

Conversation

@sinclairzx81

@sinclairzx81 sinclairzx81 commented Oct 17, 2026 •

Copy link
Copy Markdown
Owner

This PR resolves an issue of Pick and Omit dropping Optional and Readonly modifiers on shared properties when Intersect and Union are structurally collapsed. The update applies to the fast CollapseToObject path, retaining modifiers according to Intersection and Union rules. Updates are applied to Pick and Omit only. Index behaviors have been retained, but this PR does implement additional coverage to establish its Optional and Readonly property-indexing behavior.

This PR also makes updates that centralize property evaluation in EvaluatePropertyIntersect and EvaluatePropertyUnion. These functions are now shared by both Composite and CollapseToObject.

Fixes: #1718


Updates

The updates ensure modifiers are retained on Pick and Omit.

const { B } = Type.Script(`
  type A = {
    readonly p?: { a: number }
  } & {
    readonly p?: { b: number }
  }
  type B = Pick<A, 'p'>
`)

// --------------------------------
// 1.4.1
// --------------------------------
// const B: Type.TObject<{
//   p: Type.TObject<{
//     a: Type.TNumber;
//     b: Type.TNumber;
//   }>;
// }>

// --------------------------------
// 1.4.2
// --------------------------------
// const B: Type.TObject<{
//   p: Type.TReadonly<Type.TOptional<Type.TObject<{
//     a: Type.TNumber;
//     b: Type.TNumber;
//   }>>>;
// }>

@sinclairzx81
sinclairzx81 merged commit 7ac3c8d into main Oct 17, 2026
6 checks passed
@sinclairzx81
sinclairzx81 deleted the object branch October 17, 2026 08:11
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.

Omit / Pick / Index drop Optional and Readonly on a key shared by Intersect or Union members

1 participant