Issue
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)
Solution
type Query = { a: { b?: { c: string } } };
type foo = NonNullable<Query['a']['b']>['c'];
Answered By - Matthieu Riegler
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.