How do i extract the type of key3 in MyInterface2 for use in key3Value similar to key2Value?
interface MyInterface {
key1: {
key2: string
}
}
const key2Value: MyInterface['key1']['key2'] = 'Hi' //Works fine
interface MyInterface2 {
key1: {
key2: Array<{ key3: string }>
}
}
const key3Value: MyInterface2['key1']['key2']['key3'] = 'Hi' //Property 'key3' does not exist on type '{ key3: string; }[]'.(2339)
Link to typescript playground.