Search code examples
javascriptangulartypescriptinterfaceecmascript-2016

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 }; 
}

Solution

  • By extending the other interface like so:

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