Skip to content

fix(types): allow undefined in ClassNames for exactOptionalPropertyTypes - #3017

Closed
jafari1995 wants to merge 4 commits into
gpbl:mainfrom
jafari1995:fix/classnames-undefined
Closed

jafari1995 wants to merge 4 commits into
gpbl:mainfrom
jafari1995:fix/classnames-undefined

Conversation

@jafari1995

Copy link
Copy Markdown

Summary

ClassNames typed every slot as string, so with exactOptionalPropertyTypes you couldn't pass string | undefined from helpers like clsx/cva. Styles already allows undefined — this lines ClassNames up with that.

Fixes #3015

Test plan

  • Updated the ClassNames value type to string | undefined
  • Added a compile-time check in props.test.tsx using string | undefined
  • CI typecheck

@jafari1995
jafari1995 requested a review from gpbl as a code owner September 10, 2026 16:29
@changeset-bot

changeset-bot Bot commented Sep 10, 2026 •

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 046f42c

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

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

Keep ClassNames values as string for internals, widen the prop type for
clsx/cva-style string | undefined, and skip undefined when merging so
defaults stay intact.
@jafari1995

Copy link
Copy Markdown
Author

Pushed a follow-up for the CI failures:

  • Keep `ClassNames` values as `string` (avoids breaking internal `classList` usage)
  • Widen the `classNames` prop to allow `string | undefined` under `exactOptionalPropertyTypes`
  • Filter out `undefined` when merging with defaults

Local `pnpm typecheck` is green.

@jafari1995

Copy link
Copy Markdown
Author

Closing this. Empty string covers the exactOptionalPropertyTypes case, and I'd rather not change the public types.

@jafari1995 jafari1995 closed this Oct 2, 2026
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.

Types: allow undefined in ClassNames values (classNames breaks under exactOptionalPropertyTypes)

2 participants