mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-04-23 21:00:01 +08:00
classnames: Fix error for falsy values with bind
This commit is contained in:
6
types/classnames/bind.d.ts
vendored
6
types/classnames/bind.d.ts
vendored
@@ -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;
|
||||
|
||||
@@ -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'
|
||||
|
||||
Reference in New Issue
Block a user