Skip to content

Commit 2a9f02d

Browse files
committed
fix: change test case
1 parent b73e24d commit 2a9f02d

File tree

5 files changed

+64
-193
lines changed

5 files changed

+64
-193
lines changed

samples/common/complex-1.ts

Lines changed: 0 additions & 43 deletions
This file was deleted.

samples/common/complex-2.ts

Lines changed: 0 additions & 117 deletions
This file was deleted.

samples/common/complex.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
type Complex_Base = {
2+
id: number
3+
name: string
4+
age: number
5+
role: 'admin' | 'user' | 'guest'
6+
}
7+
8+
type Complex_Extended = Complex_Base & {
9+
email: string
10+
active: boolean
11+
}
12+
13+
type Complex_UserType =
14+
| (Complex_Base & { role: 'admin'; permissions: string[] })
15+
| (Complex_Base & { role: 'user'; group: string })
16+
| (Complex_Base & { role: 'guest'; restrictions: string[] })
17+
18+
type Complex_WithoutAgeAndEmail = Omit<Complex_Extended, 'age' | 'email'>
19+
20+
type Complex_ExtractAdminAndUser = Extract<Complex_UserType, { role: 'admin' | 'user' }>
21+
22+
type Complex_ExcludeGuest = Exclude<Complex_UserType, { role: 'guest' }>
23+
24+
export type Complex_Model = Complex_WithoutAgeAndEmail & {
25+
extraInfo: Complex_ExtractAdminAndUser
26+
filteredRoles: Complex_ExcludeGuest
27+
}

samples/common/extend.ts

Lines changed: 1 addition & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -4,39 +4,7 @@ type Extend_BaseSubModel = {
44
updatedAt: string
55
}
66

7-
type Extend_SubModel1 = Extend_BaseSubModel & {
8-
type: 'submodel1'
7+
export type Extend_Model = Extend_BaseSubModel & {
98
id: string
109
items: string[]
1110
}
12-
13-
type Extend_SubModel2 = Extend_BaseSubModel & {
14-
type: 'submodel2'
15-
id: number
16-
items: number[]
17-
}
18-
19-
type Extend_SubModel3 = Extend_BaseSubModel & {
20-
type: 'submodel3'
21-
a: boolean
22-
items: boolean[]
23-
}
24-
25-
type Extend_SubModel4<T> = Extend_BaseSubModel & {
26-
type: 'submodel4'
27-
id: T
28-
items: T[]
29-
}
30-
31-
type Extend_SubModel =
32-
| Extend_SubModel1
33-
| Extend_SubModel2
34-
| Extend_SubModel3
35-
| Extend_SubModel4<any>
36-
37-
export type Extend_Model = {
38-
a: number
39-
b: string
40-
c: boolean
41-
d: Extend_SubModel[]
42-
}

samples/common/union.ts

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
type Animal = {
2+
type: 'animal'
3+
name: string
4+
}
5+
6+
type Mammal = Animal & {
7+
type: 'mammal'
8+
hasFur: boolean
9+
}
10+
11+
type Bird = Animal & {
12+
type: 'bird'
13+
canFly: boolean
14+
}
15+
16+
type Dog = Mammal & {
17+
breed: 'dog'
18+
barkingLevel: 'low' | 'medium' | 'high'
19+
}
20+
21+
type Cat = Mammal & {
22+
breed: 'cat'
23+
clawSharpness: 'dull' | 'sharp'
24+
}
25+
26+
type Eagle = Bird & {
27+
species: 'eagle'
28+
wingSpan: number
29+
}
30+
31+
type Penguin = Bird & {
32+
species: 'penguin'
33+
swimmingSpeed: number
34+
}
35+
36+
export type Union_Model = (Mammal & (Dog | Cat)) | (Bird & (Eagle | Penguin))

0 commit comments

Comments
 (0)