Passed
Push — main ( 158772...7691a1 )
by Andrii
01:50
created

src/check.ts   A

Complexity

Total Complexity 5
Complexity/F 1

Size

Lines of Code 46
Function Count 5

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 20
dl 0
loc 46
rs 10
c 0
b 0
f 0
wmc 5
mnd 0
bc 0
fnc 5
bpm 0
cpm 1
noi 0

1 Function

Rating   Name   Duplication   Size   Complexity  
A check.ts ➔ classNamesCheck 0 10 1
1
import { EMPTY_OBJECT } from "./consts"
2
import type { ReactRelated, ClassNamesFrom, CssModule, ClassHash } from "./defs"
3
4
export {
5
  classNamesCheck
6
}
7
8
//TODO On assignment
9
/** Checks equality
10
 * @example classNamesCheck<typeof App, typeof require("./module.css")>(module?) // Will return notation as array of not used classes
11
 * @todo On parameter:
12
 * @example classNamesCheck<typeof App>(require("./module.css"))
13
*/
14
15
/** Identical function */
16
function classNamesCheck<T extends CssModule>(classnames: T): T
17
18
/** Declares class keys
19
 * @example
20
 * classNamesCheck() // Anything
21
 * classNamesCheck<typeof Component>()
22
 */
23
function classNamesCheck(): never
24
25
/**
26
 * Overrides argument's shape.
27
 * For checking equality add `typeof css_module` as second generic parameter
28
*/
29
function classNamesCheck<K extends ReactRelated>(classnames: {[k: string]: ClassHash}): ClassNamesFrom<K>
30
31
/**
32
 * Check redundant keys
33
 */
34
function classNamesCheck<
35
  K extends ReactRelated,
36
  T extends ClassNamesFrom<K> = ClassNamesFrom<K> 
37
>(classnames?: T): string extends keyof T ? ClassNamesFrom<K>
38
: keyof T extends keyof ClassNamesFrom<K> ? T
39
// For Verbosing redundant keys
40
: Exclude<keyof T, keyof ClassNamesFrom<K>>[]
41
42
43
function classNamesCheck(classnames = EMPTY_OBJECT) {
44
  return classnames
45
}
46