From cd3b9a69dcda6a2035bb149d57be2229d3f4faa2 Mon Sep 17 00:00:00 2001 From: Dave Keen Date: Fri, 19 Jun 2015 12:19:22 +0200 Subject: [PATCH] classnames: initial commit --- classnames/classnames-tests.ts | 17 +++++++++++++++++ classnames/classnames.d.ts | 13 +++++++++++++ 2 files changed, 30 insertions(+) create mode 100644 classnames/classnames-tests.ts create mode 100644 classnames/classnames.d.ts diff --git a/classnames/classnames-tests.ts b/classnames/classnames-tests.ts new file mode 100644 index 0000000000..7b085c4fb3 --- /dev/null +++ b/classnames/classnames-tests.ts @@ -0,0 +1,17 @@ +/// + +import classNames = require('classnames') + +classNames('foo', 'bar'); // => 'foo bar' + +classNames('foo', 'bar'); // => 'foo bar' +classNames('foo', { bar: true }); // => 'foo bar' +classNames({ foo: true }, { bar: true }); // => 'foo bar' +classNames({ foo: true, bar: true }); // => 'foo bar' + +// lots of arguments of various types +classNames('foo', { bar: true, duck: false }, 'baz', { quux: true }) // => 'foo bar baz quux' + +// 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 diff --git a/classnames/classnames.d.ts b/classnames/classnames.d.ts new file mode 100644 index 0000000000..8200436860 --- /dev/null +++ b/classnames/classnames.d.ts @@ -0,0 +1,13 @@ +// Type definitions for classnames +// Project: https://github.com/JedWatson/classnames +// Definitions by: Dave Keen +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +interface ClassDictionary { + [id: string]: boolean; +} + +declare module "classnames" { + function classNames(...classes: (string|ClassDictionary)[]): string; + export = classNames +} \ No newline at end of file