Skip to content

fix: make kind non-enumerable#82

Merged
FlandiaYingman merged 2 commits intomainfrom
fix/type-kind
Feb 25, 2026
Merged

fix: make kind non-enumerable#82
FlandiaYingman merged 2 commits intomainfrom
fix/type-kind

Conversation

@MisterCommand
Copy link
Member

TypeBox v1 has a setting enumerableKind (default false) that makes ~kind non-enumerable on all standard types via Memory.Create(). However, the custom UnionOneOf function sets "~kind" directly on the object literal, making it enumerable — so Ajv sees it and rejects it in strict mode.

The fix is to make ~kind non-enumerable in UnionOneOf, matching how TypeBox v1 handles it internally.

The fix makes ~kind a non-enumerable property on the UnionOneOf schema object, matching how TypeBox v1 handles ~kind internally via Memory.Create(). Previously it was set as a regular enumerable property via object spread ({ ...options, "~kind": "UnionOneOf", oneOf }), which meant Ajv would see it during schema compilation and reject it in strict mode.

Copilot AI review requested due to automatic review settings February 25, 2026 01:06
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adjusts the custom UnionOneOf TypeBox schema helper so its internal ~kind marker matches TypeBox v1’s non-enumerable behavior, avoiding Ajv strict-mode schema rejection.

Changes:

  • Make ~kind non-enumerable on the UnionOneOf schema object via Object.defineProperty.
  • Minor modification to the file’s header attribution line.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@FlandiaYingman FlandiaYingman merged commit ec13fba into main Feb 25, 2026
13 checks passed
@FlandiaYingman FlandiaYingman deleted the fix/type-kind branch February 25, 2026 02:25
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.

3 participants