I hope that Class B cannot be compiled like Class C.
Class C compiles an error as follows:
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",
};
}
}