Ian
Ian

Reputation: 87

Proper way of Extending TypeScript interface properties

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.

Upvotes: 0

Views: 198

Answers (1)

AlexUA
AlexUA

Reputation: 747

I suppose, you can do something like this:

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

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

Upvotes: 1

Related Questions