Skip to content

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

Answer

By extending the other interface like so:

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