Skip to content

perf(types): extend UnionToTuple recursion capacity - #35

Merged
YLfjuk merged 1 commit into
mainfrom
perf/core25-union-tuple
Nov 16, 2026
Merged

YLfjuk merged 1 commit into
mainfrom
perf/core25-union-tuple

Conversation

@YLfjuk

@YLfjuk YLfjuk commented Nov 16, 2026

Copy link
Copy Markdown
Owner

UnionToTuple currently reaches TS2589 for a 50-member literal union on TypeScript 7.0.2. Use a private tail-recursive accumulator with the existing MemberOfUnion selector; preserve the single-parameter API, mutable tuple result and unspecified order. Add edge-case and 50-member compiler regressions plus a patch changeset.

Measured with Node 24.19.0, pnpm 11.22.0 and exactly TypeScript 7.0.2, three runs per explicit literal union at 10/30/50/100/200 members, alternating implementation order and separate uninstantiated controls. Baseline fails TS2589 at 50/100/200 in every run; candidate passes all inputs. At 10/30, control-adjusted instantiations are 1286/1290 and 8956/8960 baseline/candidate. This improves depth capacity, with four extra instantiations at comparable successful inputs, and makes no general speed claim. Check-time ranges at 30 are .010-.011/.009-.011 seconds; at 200 they are .493-1.350/.825-1.768, but failed baseline work is incomplete and timings are noisy. No maximum size or arbitrary input cap is introduced.

Evaluated @arktype/attest 0.58.0 externally with pinned TS 7.0.2. Its tsgo setup explicitly rejects the compiler: requires TypeScript 7.1+. Native extendedDiagnostics suffice; no dependency or lockfile changes.

Validation: uncached types package build passes all 100 files / 520 tests, strict tsc, publint and attw esm-only. Oxc changed-file lint/format and diff checks pass. Restoring the baseline reproduces TS2589 in the new regression; special-input tests pass. No ordering assertions, unrelated utilities or numeric profiling.

Reproduction artifacts on the implementation machine: C:/Users/yehon/.t3/core25-evidence/report.md, bench.mjs, results.json and raw logs. Run the script from this checkout with the pinned Node/TS environment. Independent correctness and benchmark review pending.

Base verified against fetched origin/main: 18ce908.

@changeset-bot

changeset-bot Bot commented Nov 16, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 3a0f1c2

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
@ylfjuk-core/types Patch
@ylfjuk/core Patch
@ylfjuk-core/utils Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@YLfjuk
YLfjuk marked this pull request as ready for review November 16, 2026 16:53
@YLfjuk
YLfjuk merged commit 68652a5 into main Nov 16, 2026
1 check passed
@YLfjuk
YLfjuk deleted the perf/core25-union-tuple branch November 16, 2026 16:53
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