Skip to content

refactor(registry): extract Leaf<T,P> helper for LeafObject union#65

Merged
u8array merged 2 commits into
mainfrom
refactor/leaf-helper
May 15, 2026
Merged

refactor(registry): extract Leaf<T,P> helper for LeafObject union#65
u8array merged 2 commits into
mainfrom
refactor/leaf-helper

Conversation

@u8array
Copy link
Copy Markdown
Owner

@u8array u8array commented May 15, 2026

No description provided.

The 31 branches of `LeafObject` repeated the same
`LabelObjectBase & { type: 'X'; props: P }` pattern verbatim. Extract
a local `Leaf<T, P>` alias so each branch fits on one short line and
adding a new registry entry is a one-line union extension instead of
a 60-character repetition.

Pure mechanical edit; the resulting type is structurally identical
to the previous union (TypeScript inference treats the alias as
transparent), so no consumer sees a different shape.
Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request refactors the LeafObject union type in src/registry/index.ts by introducing a Leaf helper type, which significantly reduces boilerplate code. Feedback suggests improving type safety by constraining the generic props parameter to object and recommends moving this helper to a shared types file to further reduce duplication across the project.

Comment thread src/registry/index.ts Outdated
@u8array u8array merged commit 1c2d5c6 into main May 15, 2026
1 of 2 checks passed
@u8array u8array deleted the refactor/leaf-helper branch May 15, 2026 07:57
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