Skip to content

Commit 7738d26

Browse files
committed
feat(string): getClassNames对象类型参数不再限制值的类型
1 parent 32639b1 commit 7738d26

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/string.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -497,6 +497,8 @@ export function hideString(
497497
*
498498
* // object
499499
* getClassNames({ a: true, b: false, c: true }); // 'a c'
500+
* getClassNames({ a: true, b: ' ', c: '' }); // 'a b'
501+
* getClassNames({ a: true, b: 1, c: 0 }); // 'a b'
500502
*
501503
* // string & object
502504
* getClassNames('a', 'b', { a: true, b: false, c: true }); // 'a b c'
@@ -507,12 +509,10 @@ export function hideString(
507509
*
508510
* @param classes 支持字符串和对象类型
509511
*/
510-
export function getClassNames(
511-
...classes: Array<string | Record<string, boolean | null | undefined | number>>
512-
): string {
512+
export function getClassNames(...classes: Array<string | Record<string, unknown>>): string {
513513
const classNames: Record<string, boolean> = {};
514514

515-
const handleObjClasses = (obj: Record<string, boolean | null | undefined | number>): void => {
515+
const handleObjClasses = (obj: Record<string, unknown>): void => {
516516
forEachObj(obj, (v, k): void => {
517517
if (v) classNames[k] = true;
518518
});

0 commit comments

Comments
 (0)