Skip to content
Advertisement

how do i add new property to existing interface and then export the new interface in Typescript?

How do I create and export a new interface – UIInterface: (would like to combine SummaryInterface with few other new properties)

Example:

import { SummaryInterface } from 'x-api'; // summaryInterface has 20+ properties defined and is auto-generated from script

My attempt

export interface UIInterface {
    SummaryInterface &
     { displayStatus: string;
       flag: boolean }; 
}

Advertisement

Answer

By extending the other interface like so:

export interface UIInterface extends SummaryInterface {
  displayStatus: string;
  flag: boolean;
}
User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement