I have the following interface in typescript
interface ConfigOptions {
autoloadCallback: (err: any) => void;
}
in my implementation I have
options = {
autoloadCallback: this.autoLoadCallBack(err)
}
public autoLoadCallBack(err: any) : void {
console.log('im a callback');
};
which throws the following error
Types of property 'autoloadCallback' are incompatible. Type 'void' is not assignable to type '((err: any) => void) | undefined'.
since autoLoadCallBack takes any type and doesn't return anything should it match the interface specification?
options.autoloadCallbackis supposed to be a function, right? But you've set it to thevoidreturn value of a function. And the error is telling you that. Why notoptions = {autoloadCallback: this.autoLoadCallback.bind(this)}or something?