File tree Expand file tree Collapse file tree 5 files changed +64
-193
lines changed
Expand file tree Collapse file tree 5 files changed +64
-193
lines changed Load Diff This file was deleted.
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 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+ }
Original file line number Diff line number Diff 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- }
Original file line number Diff line number Diff line change 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 ) )
You can’t perform that action at this time.
0 commit comments