# typescript

  1. Exclude<T, U>,T有,U没有
type ResT = Exclude<"a"|"b"|"c", "c"|"d">
// ResT = "a"|"b"
1
2
  1. Extract<T, U>,T、U交集
type ResT = Extract<"a"|"b"|"c", "c"|"d">
// ResT = "c"
1
2
  1. Pick<T, K>,从T中取出K
ExampleTyle = {
  lable: string
  id: string
}
const ResT = Pick<ExampleTyle, 'lable'>
// ResT = {label: string}
1
2
3
4
5
6
  1. Omit<T, K>,从T中去除K
ExampleTyle = {
  id: string
  lable: string
  name: string
}
const ResT = Omit<ExampleTyle, 'lable'>
// ResT = {
//   id: string
//   name: string
// }
1
2
3
4
5
6
7
8
9
10
最后更新时间: 8/12/2021, 4:22:34 PM