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