Upon examining the following typescript code, my expectation was that it would lead to a compile error. The reason being, the property in the derived class shares the same name as the property in the base class but with a different type. Surprisingly, this code compiles without any issues and results in Derived.property overshadowing Base.property, ultimately causing hidden bugs. Is there a way to prevent such occurrences through either the compiler or a linter?
class Base {
protected property: {};
constructor(property: {}) {
this.property = property;
}
}
class Derived extends Base {
property = 1;
}