Is it possible to declare a "member variable" as an "extension object" rather than a static type (without relying on an interface)?
Imagine something like this pseudocode:
class Foo {
bar -> extends Rectangle;
constructor(barInstance:IRectangle){
this.bar = barInstance;
this.bar.getArea(); //<-- code completion works because of interface IRectangle
// no type error
this.bar.someCustomFunction = function() {
}
}
}
as opposed to
class Foo {
bar: IRectangle;
//or
bar:Rectangle;
}
This approach allows for adding properties that are not defined in the base class or interface without triggering type errors, while still benefiting from code completion provided by the base class. A bit of a cheeky take on strict typing, right? Lazy but effective.