Merge pull request #10802 from vsaarinen/support-undefined-null-classnames

[Types 2.0] Add support for passing in undefined or null in classNames
This commit is contained in:
Andy
2016-09-20 11:20:01 -07:00
committed by GitHub
2 changed files with 6 additions and 4 deletions
+5 -3
View File
@@ -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'
// 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'
+1 -1
View File
@@ -3,7 +3,7 @@
// Definitions by: Dave Keen <http://www.keendevelopment.ch>, Adi Dahiya <https://github.com/adidahiya>, Jason Killian <https://github.com/JKillian>
// 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;