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
| interface PersonType { age: number; address: string; }
interface UserType<T> { unit: string; profile: T; }
const user: UserType<PersonType> = { unit: '北极研究所', profile: { age: 23, address: '北极' } }
type UserType1 = Pick<UserType<PersonType>, 'unit'>
type UserType2 = Partial<UserType<PersonType>>
type UserType3 = Omit<UserType2, 'unit' | 'married'>
type UserType4 = Exclude<'unit' | 'married' | 'hasChild' | 'profile', 'unit' | 'married'>
type UserType5 = Extract<'unit' | 'married' | 'hasChild' | 'profile', 'unit' | 'married'>
|