import type { ComputedRef, Ref, VNode, VNodeChild } from 'vue'; /** * 任意类型的异步函数 */ type AnyPromiseFunction = (...arg: T) => Promise; /** * 任意类型的普通函数 */ type AnyNormalFunction = (...arg: T) => R; /** * 任意类型的函数 */ type AnyFunction = | AnyNormalFunction | AnyPromiseFunction; /** * T | null 包装 */ type Nullable = T | null; /** * T | Not null 包装 */ type NonNullable = T extends null | undefined ? never : T; /** * 字符串类型对象 */ type Recordable = Record; /** * 字符串类型对象(只读) */ interface ReadonlyRecordable { readonly [key: string]: T; } /** * setTimeout 返回值类型 */ type TimeoutHandle = ReturnType; /** * setInterval 返回值类型 */ type IntervalHandle = ReturnType; /** * 也许它是一个Ref,或者一个普通的值 * */ type MaybeRef = T | Ref; /** * 也许它是一个 ref,或者一个普通值,或者一个 getter 函数 * */ type MaybeComputedRef = MaybeReadonlyRef | MaybeRef; /** * 也许它是一个计算的 ref,或者一个 getter 函数 * */ type MaybeReadonlyRef = (() => T) | ComputedRef; /** * 包含label和value属性的下拉框 * */ type LabelValueOptions = { label: string; value: any; [key: string]: string | number | boolean; }[]; /** * 目标源打开方式 * */ type TargetContext = '_self' | '_blank'; /** * 组件元素的类型 */ interface ComponentElRef { $el: T; } /** * 组件的类型 */ type ComponentRef = ComponentElRef | null; /** * HTML元素的类型 */ type ElRef = Nullable; /** * 数组类型 */ type Arrayable = T[]; /** * 将类型转换为深可选 */ type DeepPartial = { [P in keyof T]?: DeepPartial; }; /** * 动态props */ type DynamicProps = { [P in keyof T]: Ref | T[P] | ComputedRef; }; /** * 可变的 */ type Mutable = { -readonly [P in keyof T]: T[P] }; /** * 返回类型改为可选 */ type PartialReturnType unknown> = Partial>; type EmitType = (event: string, ...args: any[]) => void; type VueNode = VNodeChild | JSX.Element; namespace JSX { // tslint:disable no-empty-interface export type Element = VNode; export interface ElementAttributesProperty { $props: any; } export interface IntrinsicElements { [elem: string]: any; } export interface IntrinsicAttributes { [elem: string]: any; } } export { type AnyFunction, type AnyNormalFunction, type AnyPromiseFunction, type Arrayable, type ComponentElRef, type ComponentRef, type DeepPartial, type DynamicProps, type ElRef, type EmitType, type IntervalHandle, type LabelValueOptions, type MaybeComputedRef, type MaybeReadonlyRef, type MaybeRef, type Mutable, type NonNullable, type Nullable, type PartialReturnType, type ReadonlyRecordable, type Recordable, type TargetContext, type TimeoutHandle, type VueNode, };