I am trying to define a type structure where both a
and foo
are optional:
type Something = {
a?: {
foo?: {
bar: {
c: {
id: string,
countryCode: number,
animal: { ... }
}
}
}
}
}
Now I need to create another type called MyType
, which corresponds to the bar
object from the example above. So, MyType
will look like this:
type MyType = {
c: {
id: string,
countryCode: number,
animal: { ... }
}
}
My question is: How can I extract MyType
from type Something
?
Update: For the answer, please refer to this comment: TypeScript: Get type from a nested type