123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- /**
- * 全局类型定义
- */
- /** 接口返回值 */
- declare interface apiResDataType {
- code: number | "ERR_CANCELED"
- data: any
- message: string
- }
- /*
- store
- */
- /** 菜单 */
- declare interface menuType {
- path: string
- title: string
- icon: string
- component: string
- children: menuType[]
- meta: {
- routeType: "layout" | "singlepage" //菜单或者单页 模式
- }
- }
- /** 角色类型 */
- declare type rolesType = "GYM" | "GYT" | "KLX"
- /**
- *type tool
- */
- /**
- * 提取obj中的某个属性的值类型
- *
- *例: type a={b:{c:1}}
- *
- * type c=ExtractVByK<a,"b"> /{c:number}
- */
- declare type ExtractVByK<T extends Record<string, any>, P extends keyof T> = T[P]
- /**
- * 获取 数组的类型
- *
- * 例: type a=string[]
- *
- * type b=ArrElement< a > //string 另外: type b=a[number] 可以获取数组的类型,同时也能获取元祖的类型
- */
- declare type ArrElement<ArrType extends any[]> = ArrType extends (infer ElementType)[] ? ElementType : never
- /**
- * 将obj的某些类型变为可选
- *
- * 例: type a={a:string,b:string,c:string}
- *
- * type b=ObjPartial< a , 'a'|'b' > //{a?:string,b?:string,c:string}
- */
- declare type ObjPartial<T extends Record<string, any>, P extends keyof T> = Partial<Pick<T, P>> & Omit<T, P>
|