If I want to define a property in interface Two and have it be the same as a property in interface One. I can do it with this:
interface One {
parent?: {
child?: boolean;
};
}
interface Two {
parent?: One['parent']
}
But how can I copy a nested property? I would expect this to work:
interface Two {
parent?: One['parent']['child']
}
but it errors:
Property 'child' does not exist on type '{ child?: boolean | undefined; } | undefined'.
One['parent']is optional, so its type is{child?: boolean | undefined}| undefined.