What is the difference between these two interface declarations :
interface A {
foo: (x: number) => number;
}
const a: A = {
foo: (x: number) => (x + 1);
}
interface B {
foo(x: number): number;
}
const b: B = {
foo(x: number) {
return x + 1;
}
}
My guess is that foo
in A
is declared as an arrow function while foo
in B
is Function
object (with its own this
etc.), but I'm not sure. I couldn't find any info on this online, even after searching through the TypeScript doc. By the way, if you find anything online about this, I would be interested in knowing how did you find it (what did you type on Google to get your answer :p )