У меня есть следующие определения интерфейса.
interface IComponents {
root: IComponent,
[key: string]: IComponent,
}
interface IComponent {
type: string,
children?: Array<keyof IComponents>;
}
Я хочу, чтобы свойства "children" принимали только ключи определенных компонентов.в случае свойства "root.children" он должен принимать только root, button1 и button2:
const list: IComponents = {
root: {
type: 'panel',
children: ['button1', 'button2', 'button3']
},
button1: {
type: 'button'
},
button2: {
type: 'button'
},
}
Но он также принимает произвольные строки, как в примере " button3 ».