Skip to content

feat: 4.1.0 - #328

Merged
tianenpang merged 8 commits into
mainfrom
canary
Nov 26, 2026
Merged

tianenpang merged 8 commits into
mainfrom
canary

Conversation

@tianenpang

@tianenpang tianenpang commented Nov 25, 2026 •

Copy link
Copy Markdown
Member

Resolves #325

Description

Syncs canary into main for the next release (v4.1.0):

  • defineVariants & VariantProps (feat(types): add defineVariants and let VariantProps read it #326): Adds a zero-runtime defineVariants helper (exported from ., /lite, and /config) so configs can be authored and typed outside tv() and passed to VariantProps. Tightens VariantProps with a type-only brand so {} and plain objects still error, preserves compoundSlots when provided, keeps internal option types unexported, and documents usage in README.md.
  • Props cache performance (perf(cache): use a Set for the props-cache variant key lookup #327 + follow-up): Keys the props cache strictly on variant axes and compound condition keys so pass-through props (id, aria-label, onClick, children) hit the cache instead of busting or serializing, and adds a string fast path to compound matching.
  • Cold vs. cached consistency fixes: Aligns cold and cached calls on compound matching (false/"false", 1/"1") and prototype-named variants, copies effective props on cached slot results so later mutations don't leak, fixes null/"null" and other cache-key collisions, and refreshes static results when non-variant compound defaults change in place.
  • Maintenance: Bumps dev dependencies, Node version (.nvmrc), and Biome schema (2.6.8).

Additional context

  • No breaking changes; all existing public APIs, exports, and cold-call contracts remain compatible with v4.0.2.
  • Test suite expanded from 956 to 1,029 passing tests (pnpm typecheck, pnpm lint, pnpm test, and pnpm build all pass).

What is the purpose of this pull request?

  • Bug fix
  • New Feature
  • Documentation update
  • Other

Performance impact

  • This change is not performance-sensitive.
  • I ran the full pnpm benchmark suite and reviewed the current TV versus released TV results.
  • Any confirmed regression above 5% is documented and intentionally bounded.

Before submitting the PR, please make sure you do the following

  • Read the Contributing Guidelines.
  • Follow the Style Guide.
  • Check that there isn't already a PR that solves the problem the same way to avoid creating a duplicate.
  • Provide a description in this PR that addresses what the PR is solving, or reference the issue that it solves (e.g. fixes #123).
  • Confirm that performance-sensitive changes follow the benchmark requirements.

@pkg-pr-new

pkg-pr-new Bot commented Nov 25, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

pnpm add https://pkg.pr.new/tailwind-variants@328

commit: c4ff387

tianenpang and others added 6 commits November 25, 2026 22:36
* feat(types): add defineVariants and let VariantProps read it

A tv() config kept in its own variable stops compiling once it has
compoundVariants: their values are inferred as string, which tv() rejects.
defineVariants is an identity helper with tv()'s generics that keeps the
literals, so the config is checked where it is written and passes back
into tv() unchanged.

- export TVOptions, the options type tv() and the lite tv() shared inline
- export defineVariants from the default, lite and config entries
- VariantProps accepts a defineVariants result, identical to its recipe's

* feat(types): keep written fields required on defineVariants options

The options defineVariants returns now carry only the fields that were
written, as required keys, and type each default as any value its variant
accepts, so app code can read one back:

  const size: 'sm' | 'lg' = buttonVariants.defaultVariants.size;

VariantProps reads the fields directly instead of matching the old shape.

* docs(types): call the defineVariants example config buttonTheme

HeroUI names its tv() recipes buttonVariants, so the same name on a config read the wrong way round.
@tianenpang tianenpang changed the title chore: canary feat: 4.1.0 Nov 26, 2026
@tianenpang
tianenpang merged commit 707e4cd into main Nov 26, 2026
8 checks passed
@tianenpang
tianenpang deleted the canary branch November 26, 2026 13:50
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.

Type-check a tv() config written outside the tv() call

3 participants