-
Notifications
You must be signed in to change notification settings - Fork 0
/
interfaceAndType.ts
71 lines (55 loc) · 1.1 KB
/
interfaceAndType.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
type TPerson = {
name: string,
age: number,
}
interface Person extends TPerson {
age: number,
}
interface Person2 {
age: number,
}
interface IPerson extends Person2 {
name: string,
age: number,
}
const me: Person = {
name: "밸리",
age: 22
}
interface IData {
age: number,
}
type TData = IData & {
name: string,
}
const data: TData = {
name: "밸리",
age: 22,
}
type TData1 = {
food: string
}
type TData2 = TData1 & {
name: string,
age: number,
}
type TURL = string;
interface UserProfile {
name: string;
image: TURL,
}
const obj: UserProfile = {
name: '',
image: '',
}
type NumberToStringConverter = {
convert: (value: number) => string;
}
type BidirectionalStringNumberConverter = NumberToStringConverter & {
convert: (value: string) => number;
}
type type2 = { a: 1 } & { b: 2 } // 잘 머지됨
type type3 = { a: 1; b: 2 } & { b: 3 } // resolved to `never`
const t2: type2 = { a: 1, b: 2 } // good
const t3: type3 = { a: 1, b: 3 } // Type 'number' is not assignable to type 'never'.(2322)
const t3: type3 = { a: 1, b: 2 } // Type 'number' is not assignable to type 'never'.(2322)