lukeed/clsxPublic

A tiny (239B) utility for constructing `className` strings conditionally.

fix: improve type test #99

Openbrunotiwants to merge 0 commits intomasterfromrefs/pull/99/head
  1. BR

    I was making some BEM CSS transformers for Vite and stumbled on a bug:

    The module.css will be transformed to something resembling this:

    ```javascript const ClassIdentifierMap = {} ClassIdentifierMap['block'] = new String('block') ClassIdentifierMap['block']['element'] = new String('block__element') ClassIdentifierMap['block']['element']['$hasError'] = new String('block__element--has-error')

    export default ClassIdentifierMap ```

    Using it as:

    ```javascript import classes from './Whatever.module.css'

    clsx(classes.block.element, hasError && classes.block.element.$hasError) ```

    It will always fail because it will check and fail to see that all those are strings, treat it as an object, and try to check the keys.

    This PR fixes it on both clsx and clsx/lite.

  2. Unknown GitHub usercommitted 5d0031d5aa252 years ago on GitHub

  3. brunoticonvert-to-draft2 years ago on GitHub

  4. BR
    Author

    Converted to draft to add tests

  5. Unknown GitHub usercommitted 06b1189fe0402 years ago on GitHub

  6. Unknown GitHub usercommitted 8757140c93d52 years ago on GitHub

  7. brunotiready-for-review2 years ago on GitHub

  8. BR
    Author

    Tests added!