I'm moving from js to typescript and i have some challenges.
I need to convert a constructor function to the equivalent of typescript.
The function in js is like so:
export default function(address) {
var self = this ;
self.address = address;
self.init = function(){
//some code
}
self.onClick = function() {
// some code
}
}
I tried to convert it but it complains in this
keyword. (missing anotation)
const Address: (address: string) => void = function (address: string) {
this.address = address;
}
Address.prototype.init = function() {
// some code here
}
export default Address
and I'm planning to call it inside react component, from another file, like so:
new (Address as any)(
address_here));
I'm having the issue with the this
so I haven't checked if the prototype function works too.