From ea8e8398a680acb0ab740d5d062794c71b43ea96 Mon Sep 17 00:00:00 2001 From: Jon Koops Date: Wed, 27 Dec 2023 17:53:58 +0100 Subject: [PATCH] Restore ability to pass TypeScript `interface` (#341) --- index.d.ts | 2 +- tests/bind.test-d.ts | 16 ++++++++++++++-- tests/dedupe.test-d.ts | 16 ++++++++++++++-- tests/index.test-d.ts | 18 ++++++++++++++---- 4 files changed, 43 insertions(+), 9 deletions(-) diff --git a/index.d.ts b/index.d.ts index ac80e5c..65efa7d 100644 --- a/index.d.ts +++ b/index.d.ts @@ -10,7 +10,7 @@ declare namespace classNames { type Value = string | number | boolean | undefined | null; - type Mapping = Record; + type Mapping = Record; interface ArgumentArray extends Array {} interface ReadonlyArgumentArray extends ReadonlyArray {} type Argument = Value | Mapping | ArgumentArray | ReadonlyArgumentArray; diff --git a/tests/bind.test-d.ts b/tests/bind.test-d.ts index a04c9d8..7c0b07a 100644 --- a/tests/bind.test-d.ts +++ b/tests/bind.test-d.ts @@ -1,6 +1,18 @@ import {expectError} from 'tsd'; import bind from '../bind'; +type Foo = { + bar: boolean; +}; + +const foo: Foo = { bar: true }; + +interface IFoo { + bar: boolean; +} + +const ifoo: IFoo = { bar: true }; + // bind bind.default.bind({foo: 'bar'}); const bound = bind.bind({foo: 'bar'}); @@ -22,6 +34,6 @@ bound('bar', null, undefined, true, false, 1234); bound('bar', ['abc', { foo: true }]); bound('bar', ['abc', { foo: true }], { def: false, ijk: 1234 }); bound('abc', 1234, true, false, undefined, null, { foo: true }, ['abc', 1234, true, false, undefined, null, { foo: true }]); +bound(foo); +bound(ifoo); expectError(bound(Symbol())); -expectError(bound([Symbol()])); -expectError(bound([[Symbol()]])); diff --git a/tests/dedupe.test-d.ts b/tests/dedupe.test-d.ts index 7f4c643..c2ef547 100644 --- a/tests/dedupe.test-d.ts +++ b/tests/dedupe.test-d.ts @@ -1,6 +1,18 @@ import {expectError} from 'tsd'; import dedupe from '../dedupe'; +type Foo = { + bar: boolean; +}; + +const foo: Foo = { bar: true }; + +interface IFoo { + bar: boolean; +} + +const ifoo: IFoo = { bar: true }; + // dedupe dedupe.default('foo'); dedupe('foo'); @@ -19,6 +31,6 @@ dedupe('bar', null, undefined, true, false, 1234); dedupe('bar', ['abc', { foo: true }]); dedupe('bar', ['abc', { foo: true }], { def: false, ijk: 1234 }); dedupe('abc', 1234, true, false, undefined, null, { foo: true }, ['abc', 1234, true, false, undefined, null, { foo: true }]); +dedupe(foo); +dedupe(ifoo); expectError(dedupe(Symbol())); -expectError(dedupe([Symbol()])); -expectError(dedupe([[Symbol()]])); diff --git a/tests/index.test-d.ts b/tests/index.test-d.ts index a7d628a..c7d3138 100644 --- a/tests/index.test-d.ts +++ b/tests/index.test-d.ts @@ -1,6 +1,18 @@ import {expectError} from 'tsd'; import classNames from '..'; +type Foo = { + bar: boolean; +}; + +const foo: Foo = { bar: true }; + +interface IFoo { + bar: boolean; +} + +const ifoo: IFoo = { bar: true }; + // default classNames.default('foo'); classNames('foo'); @@ -20,11 +32,9 @@ classNames('bar', ['abc', { foo: true }]); classNames('bar', ['abc', { foo: true }], { def: false, ijk: 1234 }); classNames('abc', 1234, true, false, undefined, null, { foo: true }, ['abc', 1234, true, false, undefined, null, { foo: true }]); classNames('abc', 1234, true, false, undefined, null, { foo: true }, ['abc', 1234, true, false, undefined, null, { foo: true }], ['abc', 1234, true, false, undefined, null, { foo: true }] as const); - +classNames(foo); +classNames(ifoo); expectError(classNames(Symbol())); -expectError(classNames([Symbol()])); -expectError(classNames([[Symbol()]])); - // should match tests/index.js classNames('c', ['a', 'b']); classNames('', 'b', {}, '');