From 02510601368c302af64ba2bdf69560957e3ac2ea Mon Sep 17 00:00:00 2001 From: Ben Thompson <113354590+BenGearset@users.noreply.github.com> Date: Thu, 27 Apr 2023 13:02:03 +0100 Subject: [PATCH] (Typescript) Allow `ReadonlyArray`s as valid classNames parameters (#307) * Add `ReadonlyArray` to `Argument` * Add test * Move to seperate interface for ; interface ArgumentArray extends Array {} - type Argument = Value | Mapping | ArgumentArray; + interface ReadonlyArgumentArray extends ReadonlyArray {} + type Argument = Value | Mapping | ArgumentArray | ReadonlyArgumentArray; } interface ClassNames { diff --git a/tests/types.ts b/tests/types.ts index be8c2c0..b192580 100644 --- a/tests/types.ts +++ b/tests/types.ts @@ -20,6 +20,7 @@ classNames('bar', null, undefined, true, false, 1234); 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); // $ExpectError classNames(Symbol()); // $ExpectError