ts中(Exclude,Extract,Omit,Pick)
interface UserInfo { username: string password: string gender: number } type People = Pick<UserInfo, 'username'> type Tome = Omit<UserInfo, 'gender'> const tom: Tome = { username: 'tom', password: '33', } type Animal = { name: string count: number } type Other = { position: string name: string count: number } type Cat = Exclude<Other, Animal> type MM = Extract<Other, Animal> // unknown let a: string = '99' let b: number = a as unknown as number // 类型断言 function func(): Promise<string> { return Promise.resolve(33 + '') } function request(): Promise<number> { return Promise.resolve(33) } let c: number let d: ReadonlyArray<number> interface userA { username: string password: string [name: string]: any }
时间如白驹过隙,忽然而已,且行且珍惜......