I want to extract a nested type like in the code below. Is there a way to do that for a nullable field?
type Query = { a: { b?: { c: string } };
type c = Query['a']['b']['c'];
Property 'c' does not exist on type '{ c: string; } | undefined'.ts(2339)
CodePudding user response:
type Query = { a: { b?: { c: string } } };
type foo = NonNullable<Query['a']['b']>['c'];