Skip to content
This repository was archived by the owner on Jun 29, 2026. It is now read-only.

fix: make kind non-enumerable - #82

Merged
flandia merged 2 commits into
mainfrom
fix/type-kind
Feb 25, 2026
Merged

fix: make kind non-enumerable#82
flandia merged 2 commits into
mainfrom
fix/type-kind

Conversation

@MisterCommand

Copy link
Copy Markdown
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.

@MisterCommand
MisterCommand requested review from Copilot and flandia and removed request for Copilot February 25, 2026 01:04
@MisterCommand MisterCommand self-assigned this Feb 25, 2026
Copilot AI review requested due to automatic review settings February 25, 2026 01:06

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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.

Comment thread src/utils/typebox/union-oneof.ts
@flandia
flandia merged commit ec13fba into main Feb 25, 2026
13 checks passed
@flandia
flandia deleted the fix/type-kind branch February 25, 2026 02:25
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants