In typescript, if I have a class like this
<code>class A {
private a:string;
constructor(a:string) {
this.a = a;
}
GetA() {
return this.a;
}
}
</code>
<code>class A {
private a:string;
constructor(a:string) {
this.a = a;
}
GetA() {
return this.a;
}
}
</code>
class A {
private a:string;
constructor(a:string) {
this.a = a;
}
GetA() {
return this.a;
}
}
Is there a way I can dynamically convert this to a type like this:
<code>interface A {
a:string;
}
</code>
<code>interface A {
a:string;
}
</code>
interface A {
a:string;
}
I ask because, if I have a class instance and I pass it to a web worker, it seems to auto change the data type into a regular object with those properties, but no methods. So I would like to define a type to it, but I can’t really use the class instance type, I would need a interface type to make it accurate.
Does anyone know how to do this?
Thanks