You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
55 lines
1.0 KiB
TypeScript
55 lines
1.0 KiB
TypeScript
/**
|
|
* 字符串类型对象
|
|
*/
|
|
declare type Recordable<T = any> = Record<string, T>;
|
|
|
|
/**
|
|
* 字符串类型对象(只读)
|
|
*/
|
|
declare type ReadonlyRecordable<T = any> = {
|
|
readonly [key: string]: T;
|
|
};
|
|
|
|
/**
|
|
* T | null 包装
|
|
*/
|
|
declare type Nullable<T> = T | null;
|
|
|
|
/**
|
|
* T | Not null 包装
|
|
*/
|
|
declare type NonNullable<T> = T extends null | undefined ? never : T;
|
|
|
|
declare type Indexable<T = any> = {
|
|
[key: string]: T;
|
|
};
|
|
|
|
declare type DeepPartial<T> = {
|
|
[P in keyof T]?: DeepPartial<T[P]>;
|
|
};
|
|
/**
|
|
* 任意类型的异步函数
|
|
*/
|
|
declare type AnyPromiseFunction = (...arg: any[]) => PromiseLike<any>;
|
|
|
|
/**
|
|
* 任意类型的普通函数
|
|
*/
|
|
declare type AnyNormalFunction = (...arg: any[]) => any;
|
|
|
|
/**
|
|
* 任意类型的函数
|
|
*/
|
|
declare type AnyFunction = AnyNormalFunction | AnyPromiseFunction;
|
|
|
|
/**
|
|
* setTimeout 返回值类型
|
|
*/
|
|
type TimeoutHandle = ReturnType<typeof setTimeout>;
|
|
|
|
/**
|
|
* setInterval 返回值类型
|
|
*/
|
|
type IntervalHandle = ReturnType<typeof setInterval>;
|
|
|
|
declare type FormType = 'create' | 'update' |