lukeed/clsxPublic

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

fix(types): Avoid `any` #22

Closedkylegachclosed 1 commit intomasterfromrefs/pull/22/head
  1. KY

    The current types trigger the [@typescript-eslint/no-unsafe-assignment rule](https://github.com/typescript-eslint/typescript-eslint/blob/v3.4.0/packages/eslint-plugin/docs/rules/no-unsafe-assignment.md).

    I believe this change covers all cases.

  2. KY
    Author

    Thanks for the super helpful project! πŸ™‚

  3. CC

    # [Codecov](https://codecov.io/gh/lukeed/clsx/pull/22?src=pr&el=h1) Report > Merging [#22](https://codecov.io/gh/lukeed/clsx/pull/22?src=pr&el=desc) into [master](https://codecov.io/gh/lukeed/clsx/commit/c5b2b21ab8aea48ff0b48649f386a2c7280fabf2&el=desc) will **not change** coverage. > The diff coverage is `n/a`.

    [![Impacted file tree graph](https://codecov.io/gh/lukeed/clsx/pull/22/graphs/tree.svg?width=650&height=150&src=pr&token=EYANLEDHtq)](https://codecov.io/gh/lukeed/clsx/pull/22?src=pr&el=tree)

    ```diff @@ Coverage Diff @@ ## master #22 +/- ## ========================================= Coverage 100.00% 100.00% ========================================= Files 1 1 Lines 22 22 ========================================= Hits 22 22 ```

    ------

    [Continue to review full report at Codecov](https://codecov.io/gh/lukeed/clsx/pull/22?src=pr&el=continue). > **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta) > `Ξ” = absolute <relative> (impact)`, `ΓΈ = not affected`, `? = missing data` > Powered by [Codecov](https://codecov.io/gh/lukeed/clsx/pull/22?src=pr&el=footer). Last update [c5b2b21...b110995](https://codecov.io/gh/lukeed/clsx/pull/22?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).

  4. LU

    Thank you :)

    Unfortunately I can't accept this. It is, in fact, any. It literally reacts to any data type and only makes a determination based on the truthiness of the value. Functions, dates, regexps, ...etc are all valid. I don't want to redefine all other TS types just to avoid an eslint rule.

    Appreciate the consideration, but `any` _is_ a valid choice in some cases. (You also probably shouldn't be linting vendor/dependency code.)

    Hope you understand πŸ™

  5. lukeedclosed6 years ago on GitHub

  6. KY
    Author

    Completely understand. πŸ™‚ I'll find another way.

    Thanks for the (very) quick and helpful response!

  7. LU

    No problem!

    You can provide custom types for `clsx` if you're unable to ignore node_modules. It's obviously not ideal, but you can copy/paste the definitions into `src/@types` or wherever and (re)declare the `clsx` module with your preferred types