版博士V2.0程序
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

пре 1 година
12345678910111213
  1. type RecordToUnion<T extends Record<string, any>> = T[keyof T]
  2. type UnionToIntersection<U> = (
  3. U extends unknown ? (arg: U) => 0 : never
  4. ) extends (arg: infer I) => 0
  5. ? I
  6. : never
  7. export type ShortEmits<T extends Record<string, any>> = UnionToIntersection<
  8. RecordToUnion<{
  9. [K in keyof T]: T[K] extends (...args: any[]) => any
  10. ? (evt: K, ...args: Parameters<T[K]>) => void
  11. : (evt: K, ...args: T[K]) => void
  12. }>
  13. >