Total Complexity | 1 |
Complexity/F | 1 |
Lines of Code | 37 |
Function Count | 1 |
Duplicated Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | import { EMPTY_OBJECT } from "./consts.json" |
||
2 | import type { CssModule, ClassHash } from "./types" |
||
3 | |||
4 | export { |
||
5 | classNamesCheck |
||
6 | } |
||
7 | |||
8 | /** |
||
9 | * Identical function or returning constant `EMPTY_OBJECT` for keys check of not required classes |
||
10 | * @example |
||
11 | * ```tsx |
||
12 | * // Dummies shape |
||
13 | * <Component classnames={classNamesCheck()} />; |
||
14 | * |
||
15 | * import css_module from "./some.css" // With redundant `.never-used {...}` |
||
16 | * // TS-check via arguments |
||
17 | * <Component classnames={classNamesCheck( |
||
18 | * css_module, |
||
19 | * //@ts-expect-error Property 'never-used' is missing |
||
20 | * {} as ComponentClassNames |
||
21 | * )} />; |
||
22 | * |
||
23 | * // TS-check via generics |
||
24 | * <Component classnames={classNamesCheck< |
||
25 | * //@ts-expect-error Type 'ComponentClassNames' does not satisfy the constraint |
||
26 | * ComponentClassNames, |
||
27 | * typeof css_module // has redundant `.never-used {...}` |
||
28 | * >(css_module)} />; |
||
29 | * ``` |
||
30 | */ |
||
31 | function classNamesCheck<C extends {[K in keyof T]: ClassHash}, T extends CssModule = CssModule>( |
||
32 | source = EMPTY_OBJECT as T, |
||
33 | _ = EMPTY_OBJECT as C |
||
34 | ) { |
||
35 | return source |
||
36 | } |
||
37 |