Total Complexity | 4 |
Complexity/F | 1 |
Lines of Code | 69 |
Function Count | 4 |
Duplicated Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | import { |
||
2 | Component |
||
3 | } from "react" |
||
4 | import type { |
||
5 | ClassNamed, |
||
6 | ClassHash, |
||
7 | ReactRelated, |
||
8 | } from "./defs" |
||
9 | import { |
||
10 | GetProps |
||
11 | } from "./react-swiss" |
||
12 | |||
13 | |||
14 | describe("ReactRelated", () => { |
||
15 | type Getter<T extends ReactRelated> = GetProps<T> |
||
16 | |||
17 | type Without = ClassNamed |
||
18 | type Wrong = ClassNamed & {classnames: string} |
||
19 | type Some = ClassNamed & {classnames: Record<string, ClassHash>} |
||
20 | type Props = ClassNamed & {classnames: {class1: ClassHash; class2: ClassHash;}} |
||
21 | |||
22 | it("Component", () => { |
||
23 | class RWithout extends Component<Without> {}; |
||
24 | class RWrong extends Component<Wrong> {}; |
||
25 | class RSome extends Component<Some> {}; |
||
26 | class RProps extends Component<Props> {}; |
||
27 | |||
28 | //@ts-expect-error |
||
29 | type x = |
||
30 | | Getter<typeof RProps> |
||
31 | //@ts-expect-error |
||
32 | type Res = |
||
33 | //@ts-expect-error |
||
34 | | Getter<typeof RWithout> |
||
35 | //@ts-expect-error |
||
36 | | Getter<typeof RWrong> |
||
37 | //Consider @ts-expect-error |
||
38 | | Getter<typeof RSome> |
||
39 | | Getter<typeof RProps> |
||
40 | |||
41 | expect(true).toBe(true) |
||
42 | }) |
||
43 | |||
44 | it("Function", () => { |
||
45 | function RWithout(_: Without) {return null}; |
||
46 | function RWrong(_: Wrong) {return null}; |
||
47 | function RSome(_: Some) {return null}; |
||
48 | function RProps(_: Props) {return null}; |
||
49 | |||
50 | // type RF = (props: {classnames: any}) => ReactElement<any, any> | null |
||
51 | |||
52 | // const ch1: Props extends {classnames: any} ? true : false = true |
||
53 | // const ch2: Parameters<typeof RProps>[0] extends {classnames: any} ? true : false = true |
||
54 | // const ch3: Parameters<typeof RProps>[0] extends Parameters<RF>[0] ? true : false = true |
||
55 | |||
56 | //@ts-expect-error |
||
57 | type Res = |
||
58 | //TODO @ts-expect-error |
||
59 | | Getter<typeof RWithout> |
||
60 | //TODO @ts-expect-error |
||
61 | | Getter<typeof RWrong> |
||
62 | //Consider @ts-expect-error |
||
63 | | Getter<typeof RSome> |
||
64 | | Getter<typeof RProps> |
||
65 | |||
66 | expect(true).toBe(true) |
||
67 | }) |
||
68 | }) |
||
69 |