| Total Complexity | 2 |
| Complexity/F | 1 |
| Lines of Code | 41 |
| Function Count | 2 |
| Duplicated Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | import React from "react" |
||
| 2 | import classNamesCheck from "./check" |
||
| 3 | import type { ClassNames, ClassNamesMap } from "./defs" |
||
| 4 | |||
| 5 | function Root(_: ClassNames<"fc1"|"fc2">) { |
||
| 6 | return null |
||
| 7 | } |
||
| 8 | |||
| 9 | it("dummy", () => { |
||
| 10 | <Root classNames={classNamesCheck()}/>; |
||
| 11 | |||
| 12 | //@ts-expect-error Property 'fc2' is missing |
||
| 13 | <Root classNames={classNamesCheck<"fc1">()}/>; |
||
| 14 | <Root classNames={classNamesCheck<"fc1"|"fc2"|"etc">()}/>; |
||
| 15 | |||
| 16 | expect(true).toBe(true) |
||
| 17 | }) |
||
| 18 | |||
| 19 | it("check that all are used", () => { |
||
| 20 | const classNames = {} as ClassNamesMap<"fc1"|"fc2"|"fc3">; |
||
| 21 | //@ts-expect-error is missing the following properties |
||
| 22 | <Root classNames={ |
||
| 23 | classNamesCheck<"">(classNames) |
||
| 24 | } />; |
||
| 25 | |||
| 26 | // TypeScript doesn't check redundant props |
||
| 27 | <Root classNames={{} as ClassNamesMap<"fc1"|"fc2">} />; |
||
| 28 | <Root classNames={classNames} />; |
||
| 29 | <Root classNames={classNames as ClassNames<typeof Root>["classNames"]} />; |
||
| 30 | |||
| 31 | //@ts-expect-error //TODO TBD redundant props |
||
| 32 | <Root classNames={classNamesCheck<typeof Root>(classNames)} />; |
||
| 33 | //@ts-expect-error //TODO TBD not error |
||
| 34 | <Root3 classNames={classNamesCheck<typeof Root3>(classNames)} />; |
||
| 35 | |||
| 36 | function Root3(_: ClassNames<"fc1"|"fc2"|"fc3">) { |
||
| 37 | return null |
||
| 38 | } |
||
| 39 | |||
| 40 | expect(true).toBe(true) |
||
| 41 | }) |
||
| 42 |