Background
Given the following interface
interface MyInterface<I, O> {
execute: (input: I) => O
}
The TS compiler is then happy with either of the following implementations of MyInterface:
class MyClass implements MyInterface<string, number> {
execute = (input: string): number => 1;
}
Or
class MyClass implements MyInterface<string, number> {
execute(input: string): number {
return 1;
}
}
Question
Due to the way type variance is handled in TS - contra-variant function arguments, but bi-variant method arguments - is it possible to prevent (by raising a compiler error) execute being implemented as a method?