I've got the following code:
class A {
constructor(public n: number) {}
defaultFn(a: number): number {
return a + 1;
}
doStuff(callback?): number {
return callback ? callback(this.n) : this.defaultFn(this.n);
}
}
How can I tell TypeScript that the optional callback
function passed to doStuff
method should have the same signature as defaultFn
method?