Skip to content

feat: reject another variant's fields in the enum's seal, and add [Tag] - #63

Merged
jo16oh merged 24 commits into
mainfrom
refactor/drop-enum-boundary-entry
Oct 14, 2026
Merged

jo16oh merged 24 commits into
mainfrom
refactor/drop-enum-boundary-entry

Conversation

@jo16oh

@jo16oh jo16oh commented Oct 14, 2026 •

Copy link
Copy Markdown
Owner

A payload whose tag is a union passed seal with every variant's fields, and the value kept the ones its variant does not declare:

Command.seal({ _tag: name === "new" ? "New" : "Fail", count: 2, message: "m" });
// → { _tag: "New", count: 2, message: "m" }
  • The enum's seal (Shape(payload) on a sealer, Shape.seal(payload) on a companion) rejects a field of another variant, both in an object literal and in an object passed through a variable, where TypeScript's excess property check does not reach
  • Tag is now a value as well as a type: the key on an enum companion that holds the two below
  • Shape[Tag].match(tag, handlers) builds from a tag that arrives without its payload, exhaustively
  • Shape[Tag].key returns the tag field's name, for a schema library's discriminator
  • The enums page gains "Build a value", a table of which call fits which input

@jo16oh jo16oh changed the title feat!: reject another variant's fields in the enum's seal, and add [Tag] feat: reject another variant's fields in the enum's seal, and add [Tag] Oct 14, 2026
@jo16oh
jo16oh merged commit aad57cc into main Oct 14, 2026
3 checks passed
@jo16oh
jo16oh deleted the refactor/drop-enum-boundary-entry branch October 14, 2026 07:47
@jo16oh jo16oh added the enhancement New feature or request label Oct 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant