I expected the following typescript code might cause a compile error, as the property in the derived class has the same name as the property in the base class, but with a different type. However, this code compiles without issues and Derived.property shadows Base.property, causing subtle bugs. Is it possible to prevent this kind of code, either through the compiler or a linter?
class Base {
protected property: {};
constructor(property: {}) {
this.property = property;
}
}
class Derived extends Base {
property = 1;
}