Skip to content
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

Revision 0.34.21 #1168

Merged
merged 4 commits into from
Feb 13, 2025
Merged

Revision 0.34.21 #1168

merged 4 commits into from
Feb 13, 2025

Conversation

sinclairzx81
Copy link
Owner

This PR reimplements Computed Record Type mapping, which was disabled in 0.34.20 due to compiler issues. The update moves the mapping logic out of the Record type and into the Computed module. The Record is now traversed like other normative types, whereas before, it was treated as a pseudo-Computed type (similar to Partial).

This PR only provides a solution for Record values, not keys. The issue with keys is that TypeBox needs to encode Record keys as string patternProperties, and dereferencing the key prior to encoding (treating Record as a computed type) is not feasible given the current complexity of Record mapping.

const A = Type.Module({
  T: Type.Object({ x: Type.Number() }),
  R: Type.Record(Type.String(), Type.Ref('T')) // Non-Computed Record Value
})

// A Partial Wrapping a Reference Results in Computed Type Traversal

const B = Type.Module({
  T: Type.Object({ x: Type.Number() }),
  R: Type.Record(Type.String(), Type.Partial(Type.Ref('T'))) // Computed Record Value
})

@sinclairzx81 sinclairzx81 merged commit 1bd8f78 into master Feb 13, 2025
18 checks passed
@sinclairzx81 sinclairzx81 deleted the record branch February 13, 2025 07:01
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.

1 participant