我希望Class B像Class C一样不能通过编译,
Class C 编译会报错如下:
Type '{ name: string; some: string; }' is not assignable to type 'Info'.
Object literal may only specify known properties, and 'some' does not exist in type 'Info'.
interface Info {
name: string;
}
interface Person {
info(): Info;
}
class B implements Person {
info() {
return {
name: "li",
some: "1",
};
}
}
class C {
info():Info {
return {
name: "li",
some: "1",
};
}
}