Typescript interfaces allow definition of a function-style call signature thus:
interface A {
(x: number): number;
}
This can be implemented by, e.g. a function:
const a: A = function(x: number): number {
return 1;
}
Is it possible to implement such an interface using a class?
I've attempted it like this:
class B implements A {
(x: number): number {
return 1;
}
}
But I get this error:
Class 'B' incorrectly implements interface 'A'. Type 'B' provides no match for the signature '(x: number): number'.ts(2420)
Is there any way to implement this sort of interface using a class in Typescript?