I have an interface like
interface I {
a : string;
b : number;
c : string;
}
And now I'm declaring a class which will have public members a, b, c as per the interface I.
So I declare
class C implements I {
public a : string;
public b : number;
public c : string;
// and then constructor, other fields, other methods
}
Is there a way for me to avoid duplication in declaring fields? I.e. I want to have those fields without actually declaring them, by the virtue of extending the interface. So all I'll be left to write something like :
class C implements I {
// perhaps a magic statement that asserts that C should inherit all members from I
// and then constructor, other fields, other methods
}
To add insult to injury, there's even more duplication in the constructor because I cannot just initialize the fields from an object literal satisfying interface I in a one liner
constructor(data : I) {
this.a = data.a;
this.b = data.b;
this.c = data.c;
}
I do not have control over definition of the interface, I only have control over definition of the class (this means I cannot for instance turn interface into an abstract class...)