-
Notifications
You must be signed in to change notification settings - Fork 0
/
internal-type.ts
52 lines (39 loc) · 1.01 KB
/
internal-type.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
{
//type Extract<T, U> = T extends U ? never : T
let foo: Extract<'a' | 'b' | 'c', 'b'> = 'b'
let foo2: Exclude<'a' | 'b' | 'c', 'b'> = 'a'
foo2 = 'c'
const foo3: Record<string, boolean> = {
a: true
};
const foo4: Record<'x' | 'y', number> = {
x: 1,
y: 2
};
interface Foo {
a: string;
b: number;
}
const foo5: Partial<Foo> = {
b: 2
}
const foo6: Required<Foo> = {
a: 'a',
b: 2
}
const foo7: Readonly<Foo> = {
a: 'a',
b: 2
}
const foo8: Pick<Foo, 'b'> = {
b: 1
};
//type Parameters<T extends (...args: any) => any> =
//T extends (...args: infer P) => any ? P : never
type Foo2 = (a: string, b: number) => void
const a: Parameters<Foo2> = ['a', 1] // [string, number]
//type ReturnType<T extends (...args: any) => any> =
//T extends (...args:any) => infer R ? R : any
type Foo3 = () => boolean
const a1: ReturnType<Foo3> = true
}