Is there a way to extract the type of key3 in MyInterface2 and use it in key3Value, similar to key2Value?
interface MyInterface {
key1: {
key2: string
}
}
const key2Value: MyInterface['key1']['key2'] = 'Hi' //Operates correctly
interface MyInterface2 {
key1: {
key2: Array<{ key3: string }>
}
}
const key3Value: MyInterface2['key1']['key2']['key3'] = 'Hi' //Error: Property 'key3' does not exist on type '{ key3: string; }[]'.(2339)
Link to typescript playground.