打字稿扩展 "a type nested in a type"
Typescript extend "a type nested in a type"
我属于以下类型:
type IQueryResolvers<ContextType = any, ParentType extends {} = {}> = {
me?: ...
profile?: ...
}
问题是,对于 IQueryResolvers 类型的每个键,我都有一个控制器函数,例如:
const meController = () => {};
我想访问这样的类型:
const meController: IQueryResolvers.me = () => {};
有人对此有解决方案吗?
解决方法是:
const meController: IQueryResolvers['me'] = () => {};
我属于以下类型:
type IQueryResolvers<ContextType = any, ParentType extends {} = {}> = {
me?: ...
profile?: ...
}
问题是,对于 IQueryResolvers 类型的每个键,我都有一个控制器函数,例如:
const meController = () => {};
我想访问这样的类型:
const meController: IQueryResolvers.me = () => {};
有人对此有解决方案吗?
解决方法是:
const meController: IQueryResolvers['me'] = () => {};