嗨角社区,
是否可以包含嵌套在另一个中的三个接口,我认为我的代码将解释它比我的句子更多: 我正在尝试实现接口IProject1& IProject2& IProject3将成为IAdmin2接口的一部分:
提前致谢
import {IBusiness} from "./business";
import {ITechnology} from "./technology";
export interface IAdmin2 {
id: number;
business_id: number;
technology_ids: number[];
trigram: string;
position: string;
years_experience: number;
notification: boolean;
availability: any;
form_admin2_file: File;
business: IBusiness;
technologies: ITechnology[];
admin2Translations: any;
translations: any;
delete: any;
data: any;
** Include interface Iproject1**
** Include interface Iproject2**
** Include interface Iproject3**
}
import {ITechnology} from "./technology";
import {IProjectFile} from "./project-file";
export interface IProject1 {
id: number;
name: string;
start_date: any;
technologies: ITechnology[];
description: string;
sector_id: number;
end_date: any;
team_size: number;
}
import {ITechnology} from "./technology";
import {IProjectFile} from "./project-file";
export interface IProject2 {
id: number;
name: string;
start_date: any;
technologies: ITechnology[];
description: string;
sector_id: number;
end_date: any;
team_size: number;
}
import {ITechnology} from "./technology";
import {IProjectFile} from "./project-file";
export interface IProject3 {
id: number;
name: string;
start_date: any;
technologies: ITechnology[];
description: string;
sector_id: number;
end_date: any;
team_size: number;
}
答案 0 :(得分:2)
在TypeScript中,您可以从一个或多个基接口继承接口:
interface IProject1 {
}
interface IProject2 {
}
interface IProject3 {
}
interface IAdmin2 extends IProject1, IProject2, IProject3 {
}
因此,IAdmin2
的实施也必须实施IProject1
,IProject2
和IProject3
。您还可以查看the official documentation of interfaces。