import modules from '../modules' // 获取单个mutations的类型 type GetMutation = Module extends { mutations: infer V } ? V : unknown // 获取全部的mutations类型 type GetMutations = { [K in keyof Modules]: GetMutation } // 源数组 type TotalMutations = GetMutations //模块名+方法名 type CombineModuleAndMethod = `${M & string}/${N & string}` // key是模块名 value是模块名/方法名 type CombineModuleAndMethods = { [K in keyof Modules]: CombineModuleAndMethod }[keyof Modules] type GetFunc = T[A & keyof T][B & keyof T[A & keyof T]] type MutationsObj = { [K in CombineModuleAndMethods]: K extends `${infer A}/${infer B}` ? GetFunc : unknown } type MutationsMap = MutationsObj type Mutations = { [K in keyof MutationsMap]: MutationsMap[K] } export { Mutations }