【发布时间】:2015-06-27 21:20:19
【问题描述】:
我有如下界面:
interface IUpdateBusinessAddressRequest extends IReturn<IBusinessAddressResponse>
{
BusinessId?: number;
AddressId?: number;
AddressLine1?: string;
AddressLine2?: string;
AddressLine3?: string;
TownCity?: string;
County?: string;
Postcode?: string;
Country?: string;
IsPrimary?: boolean;
}
还有这个类:
export class UpdateBusinessAddressRequest implements IUpdateBusinessAddressRequest {
}
我没有在类中实现接口,但我的 Typescript 仍然可以编译。
我在另一个类中有这个方法:
test(request: IDeleteBusinessRequest) {
//stuff
}
IDeleteBusinessRequest 是另一个接口。我可以这样称呼它而没有编译错误:
this.test(new UpdateBusinessAddressRequest());
UpdateBusinessAddressRequest 没有实现 IDeleteBusinessRequest,但我没有收到任何编译错误。
例如,在 C# 中,这不会编译。我只是对打字稿期望过高,还是我做错了什么?
我正在使用带有最新 Typescript 编译器的 Visual Studio 2015 RC。
谢谢
【问题讨论】:
-
类编译成javascript函数,所以你可以调用它。对我来说看起来很正常。
标签: typescript