Skip to content

feat!: faster style-object types; sound pruning of unused options - #429

Merged
codecaaron merged 2 commits into
mainfrom
feat/leverage-batch-4
Nov 28, 2026
Merged

codecaaron merged 2 commits into
mainfrom
feat/leverage-batch-4

Conversation

@codecaaron

Copy link
Copy Markdown
Owner

Two changes, one commit each, on top of #428.

Style-object check time no longer grows with the property count

  • Nearly all check time went to the compiler working out the variance of the generic builder types. PropertyValues passed a generic argument into PropertyTypes, so each variance probe built a fresh union of every property's value type, at roughly quadratic cost in the number of properties.
  • PropertyValues now instantiates PropertyTypes only with fixed arguments, so every probe shares one cached lookup. asClass returns the new BuilderClassResolver<B>, whose object constraint is met by the declaration.

Median check time under TypeScript 7:

Project Before After Cost of 860 extra properties, before → after
Type-budget fixture 390 ms 100 ms +400 ms → +9 ms
Core published fixtures 158 ms 46 ms +131 ms → +27 ms
React published fixtures 729 ms 398 ms +431 ms → +44 ms

Under TypeScript 5.9 check time falls by about a third and still grows with the property count, at roughly half the old rate.

Every fixture passes unchanged on both compilers, with and without exactOptionalPropertyTypes; hover types and declaration output are the same apart from the changes above. scripts/type-budget/baseline.json is re-recorded.

addConditions rejects an alias without the _ prefix in core, react and effect-ui. The extractor only looks up condition aliases that start with _, so an unprefixed one was registered and never matched.

Pruning, located eliminations, no-unused-variant

Two gaps in production pruning:

  • A variant with no defaultVariant was left out of usage tracking and never pruned, so <Button size="sm"> kept the CSS for every other size.
  • A component whose renders set no state kept every state.

Both are now pruned when no render selects them. Everything kept deliberately is still kept: dynamic values, spreads, escaping or forwarded components, incomplete analysis, and development mode. e2e/vite-app CSS goes from 11,903 to 11,576 bytes.

  • Each record in report.eliminated_details gains file, prop, at (the position of the option's key, the state's key, or the compound call) and kept_elsewhere.
  • Builds with lintFiles write .animus/unused.json. animus/no-unused-variant reports each unused option, state and compound at its definition, and is silent once any analysed file differs from the build, since a use elsewhere can change the answer.
  • Kept: one in-process test for the contract that an option no render selects is pruned and one a render could select is kept; the e2e/rollup-app lint assertion now covers the unused option.
  • e2e/packed-app renders a disabled button, so its anm-states layer is still emitted and checked.

Release notes

  • Faster type-checking of style objects; adding CSS properties to the vocabulary barely affects it under TypeScript 7.
  • Breaking (types): addConditions rejects an alias name without the _ prefix. New exported types BuilderClassResolver and UnprefixedConditionAlias.
  • Breaking: production builds prune options of variants with no defaultVariant that no render selects, states no render sets, and compounds that need only such options. An app that applied those class names by hand loses the CSS.
  • report.eliminated_details records gain file, prop, at and kept_elsewhere.
  • New rule animus/no-unused-variant and artifact .animus/unused.json.

Verification

  • vp run verify:full passes at 52b73238: 55 of 55 tasks.
  • Parity baselines are refreshed under intent prune-unselected-options-20261128: removals only, in eleven production units, each checked against its renders. Code and diagnostics did not move.
  • verify:bench reports every row INVALID: the Vite app's CSS now differs from release 0.2.0, as do the loader and analysis outputs recorded on feat!: structured diagnostics, tighter types, CI hardening #427. scripts/bench/accepted-differences.json is not updated in this PR, so the gate measures nothing until it is.

🤖 Generated with Claude Code

codecaaron and others added 2 commits November 28, 2026 04:07
…y count

PropertyValues instantiated PropertyTypes with a generic argument, so every variance probe of the builder types built a fresh union of every property's value type. It now instantiates PropertyTypes only with fixed arguments, and asClass returns BuilderClassResolver so its object constraint is met by the declaration. Under TypeScript 7 the type-budget fixtures check in about 100 ms instead of 390, and 860 extra properties add 9 ms instead of 400. TypeScript 5.9 improves by about a third. Every fixture passes unchanged.

addConditions rejects an alias without the _ prefix in core, react and effect-ui; such aliases were never matched. The type-budget baseline is re-recorded.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…s; no-unused-variant

Variants without a defaultVariant were left out of usage tracking and never pruned, and a component whose renders set no state kept every state. Production builds now prune a variant option no render selects and a state no render sets, under the conditions already applied elsewhere: dynamic values, spreads, escapes, forwarded components, incomplete analysis and development mode keep everything.

Each elimination record carries the component's file, the prop, and the position of the eliminated option, state or compound. Builds with lintFiles write .animus/unused.json, and animus/no-unused-variant reports each at its definition while every analysed file still matches the build. The parity baselines are refreshed under intent prune-unselected-options-20261128: removals only, in eleven production units. The packed fixture renders a disabled button so its states layer is still exercised.

Verified at this commit: vp run verify:full (55 of 55 tasks). verify:bench reports every row invalid, because output now differs from release 0.2.0 by design; scripts/bench/accepted-differences.json is not updated here.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@codecaaron
codecaaron merged commit e4995b2 into main Nov 28, 2026
16 checks passed
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