/** * 空对象 * * 类似 * { * "xxx": string, * } */ type NestedObjectWithToString = { [key: string]: any | NestedObjectWithToString; toString(): any; }; /** * Promise的兼容类型 * * 它是返回提供的类型或Promise包裹的类型 */ declare type IPromise = T | Promise; declare type IFunction = T | ((...args: any[]) => T); declare type IArray = T | T[]; /** * 提取数组中的元素类型 */ declare type ArrayElementType = T extends Array ? U : never; /** * 让对象的某个属性必选 */ declare type RequiredProperty = Omit & Required>; /** * 让对象的某个属性非空 */ declare type NonNullableProperty = Omit & { [P in K]-?: NonNullable; }; declare type DeepRequired = T extends any[] ? T : // eslint-disable-next-line @typescript-eslint/no-unsafe-function-type T extends Function ? T : T extends object ? T extends Node ? T : { [K in keyof T]-?: DeepRequired; } : T; /** * 修复无法识别.vue文件的问题 */ declare module "*.vue" { import { defineComponent } from "vue"; const Component: ReturnType; export default Component; }