Home > OS >  Proper way of Extending TypeScript interface properties
Proper way of Extending TypeScript interface properties

Time:05-05

export interface IDDMenuItem {
  [key: string]: object extends { disabled:boolean,label:string, type:string}
}

This way not seems to be legit -

Getting these errors:

Return type of index signature from exported interface has or is using private name ''.
Return type of index signature from exported interface has or is using private name ''.
'?' expected.

Looking for the proper way of extending properties.

CodePudding user response:

I suppose, you can do something like this:

export interface IItem {
  disabled: boolean;
  label: string;
  type: string;
}

export interface IDDMenu {
  [key: string]: IItem;
}
  • Related