What is a good approach to giving this a type annotation in a constructor?
function Client(options: ClientOptions) {
const defaultOptions = {
host: 'ws://127.0.0.1',
port: 8080,
logger: function() {
const prefix = "LOG:";
console.log.call(null, prefix, ...Array.from(arguments))
},
maxTime: 30000,
startFromTransactionId: 1
};
Object.assign(this, { ...defaultOptions, ...options });
this.transactionsCounter = 0;
this.requestCallbacks {};
this.socket = null;
}
[ts] 'this' implicitly has type 'any' because it does not have a type annotation.
Elaboration
My editor shows me red squiggly lines beneath each use of the this keyword in this constructor. I get a [ts] warning that this does not have any type annotation.
How should I go about adding type annotation to this?