2021-03-09 21:24:22 +08:00
|
|
|
import type { App } from 'vue'
|
2020-12-23 14:07:15 +08:00
|
|
|
|
2020-08-04 10:49:49 +08:00
|
|
|
type OptionalKeys<T extends Record<string, unknown>> = {
|
2020-08-02 18:27:46 +08:00
|
|
|
[K in keyof T]: T extends Record<K, T[K]>
|
|
|
|
? never
|
|
|
|
: K
|
|
|
|
}[keyof T]
|
|
|
|
|
2020-08-04 10:49:49 +08:00
|
|
|
type RequiredKeys<T extends Record<string, unknown>> = Exclude<keyof T, OptionalKeys<T>>
|
2020-08-02 18:27:46 +08:00
|
|
|
|
|
|
|
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
|
|
|
|
|
2020-08-04 10:49:49 +08:00
|
|
|
export type EventEmitter<T extends Record<string, unknown>> =
|
2020-08-02 18:27:46 +08:00
|
|
|
MonoArgEmitter<T, OptionalKeys<T>> & BiArgEmitter<T, RequiredKeys<T>>
|
2020-08-24 15:38:30 +08:00
|
|
|
|
|
|
|
export type AnyFunction<T> = (...args: any[]) => T
|
2020-09-03 21:19:12 +08:00
|
|
|
|
2021-06-25 16:25:54 +08:00
|
|
|
export type PartialReturnType<T extends (...args: unknown[]) => unknown> = Partial<ReturnType<T>>
|
2020-12-23 14:07:15 +08:00
|
|
|
|
|
|
|
export type SFCWithInstall<T> = T & { install(app: App): void; }
|
2021-07-13 17:30:41 +08:00
|
|
|
|
|
|
|
export type RefElement = Nullable<HTMLElement>
|