Skip to content

Commit 30be726

Browse files
committed
added more record types to classNameKeyType for the sake of convinience
1 parent d35bda6 commit 30be726

File tree

10 files changed

+27
-7
lines changed

10 files changed

+27
-7
lines changed

lib/tests/gs.test.js

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/tests/gs.test.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/types/gs_classname_key.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
export declare type GsClassNameKeyType = (string | Record<string, string> | Record<string, boolean> | undefined);
1+
export declare type GsClassNameKeyType = (string | Record<string, string> | Record<string, boolean> | Record<string, undefined> | Record<string, null> | undefined);

lib/utils/get_class_name_keys.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/utils/get_class_name_keys.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "get-module-style",
3-
"version": "4.0.1",
3+
"version": "4.0.2",
44
"description": "This package helps you to work with module css and scss (sass)",
55
"main": "lib/index.js",
66
"types": "lib/index.d.ts",

src/tests/gs.test.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,14 @@ describe('gs function test', () => {
2020
const classNames = gs('text', { red: false }, { big: true });
2121
expect(classNames).toBe('text big');
2222
});
23+
24+
it('works with object like { className: undefined }', () => {
25+
const classNames = gs('text', { red: undefined }, { big: true });
26+
expect(classNames).toBe('text big');
27+
});
28+
29+
it('works with object like { className: null }', () => {
30+
const classNames = gs('text', { red: null}, { big: true });
31+
expect(classNames).toBe('text big');
32+
});
2333
});

src/types/gs_classname_key.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,7 @@ export type GsClassNameKeyType = (
22
string |
33
Record<string, string> |
44
Record<string, boolean> |
5+
Record<string, undefined> |
6+
Record<string, null> |
57
undefined
68
);

src/utils/get_class_name_keys.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export function getClassNameKeys(classNames: GsClassNameKeyType[]) {
88

99
case 'object':
1010
return Object.entries(cname)
11-
// if cnameKeyValue equals to false, it will be filtered
11+
// if cnameKeyValue equals to false | null | undefined, it will be filtered
1212
.filter(([_cnameKey, cnameKeyValue]) => cnameKeyValue)
1313

1414
// array first element destructure

0 commit comments

Comments
 (0)