diff --git a/classnames/classnames-tests.ts b/classnames/classnames-tests.ts index e296001ed8..5c99df82eb 100644 --- a/classnames/classnames-tests.ts +++ b/classnames/classnames-tests.ts @@ -17,6 +17,8 @@ classNames([{ foo: true, bar: false }, { baz: true }]); // => 'foo baz' classNames(["foo", ["bar", {baz: true}]]); // => 'foo bar baz' -// other falsy values are just ignored -// NOTE: We don't really want to allow this kind of thing with Typescript (otherwise what's the point!) -//classNames(null, false, 'bar', undefined, 0, 1, { baz: null }, ''); // => 'bar 1' \ No newline at end of file +// falsey values are just ignored +classNames(null, 'bar', undefined, 0, 1, { baz: null }, ''); // => 'bar 1' + +// Supporting booleans is tricky since we should only support passing in false, which is ignored +//classNames(false, 'bar', 0, 1, { baz: null }, ''); // => 'bar 1' diff --git a/classnames/index.d.ts b/classnames/index.d.ts index f9993f3c11..e6b645c5b0 100644 --- a/classnames/index.d.ts +++ b/classnames/index.d.ts @@ -3,7 +3,7 @@ // Definitions by: Dave Keen , Adi Dahiya , Jason Killian // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -declare type ClassValue = string | number | ClassDictionary | ClassArray; +declare type ClassValue = string | number | ClassDictionary | ClassArray | undefined | null; interface ClassDictionary { [id: string]: boolean;