mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-04 23:07:06 +00:00
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:
@@ -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'
|
||||
|
||||
Vendored
+1
-1
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user