Search code examples
typescriptgraphqlcode-generation

Typescript extend "a type nested in a type"


I am have the following type:

type IQueryResolvers<ContextType = any, ParentType extends {} = {}> = {
me?: ...
profile?: ... 
}

the problem is, I have one controller function for each key of type IQueryResolvers, for example:

const meController = () => {};

I would like access the type like this:

const meController: IQueryResolvers.me = () => {};

Does anyone has the solution for that?


Solution

  • the solution is:

    const meController: IQueryResolvers['me'] = () => {};