element-plus/packages/utils/types.ts
JeremyWuuuuu a7a8f29a19 refactor(popper): use-popper-hook for popper
- Add new use popper hook into the codebase for replacing the current `use-popper`
2021-07-13 17:49:00 +08:00

25 lines
837 B
TypeScript

import type { App } from 'vue'
type OptionalKeys<T extends Record<string, unknown>> = {
[K in keyof T]: T extends Record<K, T[K]>
? never
: K
}[keyof T]
type RequiredKeys<T extends Record<string, unknown>> = Exclude<keyof T, OptionalKeys<T>>
type MonoArgEmitter<T, Keys extends keyof T> = <K extends Keys>(evt: K, arg?: T[K]) => void
type BiArgEmitter<T, Keys extends keyof T> = <K extends Keys>(evt: K, arg: T[K]) => void
export type EventEmitter<T extends Record<string, unknown>> =
MonoArgEmitter<T, OptionalKeys<T>> & BiArgEmitter<T, RequiredKeys<T>>
export type AnyFunction<T> = (...args: any[]) => T
export type PartialReturnType<T extends (...args: unknown[]) => unknown> = Partial<ReturnType<T>>
export type SFCWithInstall<T> = T & { install(app: App): void; }
export type RefElement = Nullable<HTMLElement>