繁体   English   中英

如何向现有接口添加新属性,然后在 Typescript 中导出新接口?

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

如何创建和导出新界面 - UIInterface:(希望将 SummaryInterface 与其他一些新属性结合起来)

例子:

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

我的尝试

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

通过像这样扩展另一个接口:

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

你可以试试下面的代码:

通过扩展父 class 属性

说明:基本上,您在下面的代码中,同时具有父接口和子接口的属性。

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM