TS的联合类型,Partial和Omit

66 阅读1分钟
type Person {
  name: string,
  age: number,
  other: number
}

const xiaoming: Partial<Person> = {} //缺少name和age和other都不会报错
const shenmiren: Omit<Person, 'name' | 'age'> = {} //缺少name和age不会报错,第二个参数是排除某些