lukeed/clsxPublic

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

clsx/lite accepts ClassDictionary (TypeScript)

SN

The TS type of the new `clxs/lite` function includes the `ClassDictionary` type, but why? Dictionaries are not evaluated by this function, so passing them is useless. Wouldn't it be better to exclude it so that TS users are aware of that restriction?

  1. LU

    I kept it the same because you should be able to simply modify your bundler's `alias` config to map `clsx` to `clsx/lite` w/o changes or new errors. Also, technically, `clsx/lite` still accepts the non-string input values, it just doesnt do anything with them

  2. SN
    Author

    Thanks for the explanation.

  3. sndrrthclosed2 years ago on GitHub

  4. SK

    > I kept it the same because you should be able to simply modify your bundler's alias config to map clsx to clsx/lite w/o changes or new errors.

    That will only hide errors in runtime, no? I don't understand the reasoning 🤔

  5. droid51referenced this in Lite Version: Improve Typescript Definition and Support for "moduleResolution": "Node" #942 years ago on GitHub