Typescript数组接受错误的类型

Gui*_* CR 1 arrays typescript

我希望以下代码无法转换,因为B不应该是array.push的有效类型.我错过了什么?

class A {};
class B {};
const arr: A[] = [];
arr.push(new B());
Run Code Online (Sandbox Code Playgroud)

Exp*_*lls 6

TypeScript使用结构兼容性来确定类型兼容性.这些类在结构上是兼容的,因为它们具有相同的属性(空对象).

请参阅:https://www.typescriptlang.org/docs/handbook/type-compatibility.html