@alker0/type-filter-clsx
TypeScript icon, indicating that this package has built-in type declarations

0.0.2 • Public • Published

type-filter-clsx

This library makes clsx allow only specified class names.

Install

npm install @alker0/type-filter-clsx

Just once, run this somewhere in your typescript project.

import '@alker0/type-filtered-clsx';

Usage

import clsx, { Clsx } from 'clsx';

const cn: Clsx<'foo' | 'bar'> = clsx;
const cnQux: Clsx<'qux'> = clsx;

console.log(cn('foo')); // => foo
console.log(cn('foo', 'bar')); // => foo bar
console.log(cn('qux')); // error !
console.log(cnQux('qux')); // => qux

If you use babel-plugin-optimize-clsx, all clsx brother's names you created must be included in functionNames option.

babel.config.json or .babelrc.json:

{
  "plugins": [
    [
      "optimize-clsx",
      {
        "functionNames": ["clsx", "cn", "cnQux"]
      }
    ]
  ]
}

License

MIT

/@alker0/type-filter-clsx/

    Package Sidebar

    Install

    npm i @alker0/type-filter-clsx

    Weekly Downloads

    0

    Version

    0.0.2

    License

    MIT

    Unpacked Size

    3.17 kB

    Total Files

    4

    Last publish

    Collaborators

    • alker