-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcomplex.ts
More file actions
27 lines (21 loc) · 762 Bytes
/
complex.ts
File metadata and controls
27 lines (21 loc) · 762 Bytes
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
type Complex_Base = {
id: number
name: string
age: number
role: 'admin' | 'user' | 'guest'
}
type Complex_Extended = Complex_Base & {
email: string
active: boolean
}
type Complex_UserType =
| (Complex_Base & { role: 'admin'; permissions: string[] })
| (Complex_Base & { role: 'user'; group: string })
| (Complex_Base & { role: 'guest'; restrictions: string[] })
type Complex_WithoutAgeAndEmail = Omit<Complex_Extended, 'age' | 'email'>
type Complex_ExtractAdminAndUser = Extract<Complex_UserType, { role: 'admin' | 'user' }>
type Complex_ExcludeGuest = Exclude<Complex_UserType, { role: 'guest' }>
export type Complex_Model = Complex_WithoutAgeAndEmail & {
extraInfo: Complex_ExtractAdminAndUser
filteredRoles: Complex_ExcludeGuest
}