classnames: Fix error for falsy values with bind

This commit is contained in:
Marvin Hagemeister
2017-08-16 09:23:11 +02:00
parent 193d9dc3bf
commit 23b64b5990
2 changed files with 5 additions and 4 deletions

View File

@@ -1,5 +1,3 @@
export type ClassNamesFn = (
...args: Array<string | string[] | Record<string, boolean | undefined | null>>
) => string;
import * as cn from "./index";
export function bind(styles: Record<string, string>): ClassNamesFn;
export function bind(styles: Record<string, string>): typeof cn;

View File

@@ -35,3 +35,6 @@ const styles = {
const cx = cn.bind(styles);
const className = cx('foo', ['bar'], { baz: true }); // => "abc def xyz"
// falsey values are just ignored
cx(null, 'bar', undefined, 0, 1, { baz: null }, ''); // => 'bar 1'