我的界面目前看起来像这样。是否有可能重构它,以便在两者中不再重复属性。
export interface Navigation {
name: string;
roles: Array<number>;
sublinks: NavigationItem[];
}
export interface NavigationItem {
name: string;
roles: Array<number>;
url: string;
}
答案 0 :(得分:2)
export interface NavigationBase {
name: string;
roles: number[];
}
export interface Navigation extends NavigationBase {
sublinks: NavigationItem[];
}
export interface NavigationItem extends NavigationBase {
url: string;
}