Skip to content

Commit 8e939f4

Browse files
committed
Merge pull request DefinitelyTyped#4750 from ccapndave/classname
classnames: initial commit
2 parents 1e0ba03 + cd3b9a6 commit 8e939f4

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

classnames/classnames-tests.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
///<reference path='classnames.d.ts' />
2+
3+
import classNames = require('classnames')
4+
5+
classNames('foo', 'bar'); // => 'foo bar'
6+
7+
classNames('foo', 'bar'); // => 'foo bar'
8+
classNames('foo', { bar: true }); // => 'foo bar'
9+
classNames({ foo: true }, { bar: true }); // => 'foo bar'
10+
classNames({ foo: true, bar: true }); // => 'foo bar'
11+
12+
// lots of arguments of various types
13+
classNames('foo', { bar: true, duck: false }, 'baz', { quux: true }) // => 'foo bar baz quux'
14+
15+
// other falsy values are just ignored
16+
// NOTE: We don't really want to allow this kind of thing with Typescript (otherwise what's the point!)
17+
//classNames(null, false, 'bar', undefined, 0, 1, { baz: null }, ''); // => 'bar 1'

classnames/classnames.d.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// Type definitions for classnames
2+
// Project: https://github.com/JedWatson/classnames
3+
// Definitions by: Dave Keen <http://www.keendevelopment.ch>
4+
// Definitions: https://github.com/borisyankov/DefinitelyTyped
5+
6+
interface ClassDictionary {
7+
[id: string]: boolean;
8+
}
9+
10+
declare module "classnames" {
11+
function classNames(...classes: (string|ClassDictionary)[]): string;
12+
export = classNames
13+
}

0 commit comments

Comments
 (0)