What's the difference between declaring functions using the fat arrow and non-fat arrow syntax in interfaces and types in TypeScript?
For example:
build(paramOne: string): string;
Compared to:
build: (paramOne: string) => string;
At first, I thought it would restrict the way I implement the functions but it doesn't seem like the case. So, I don't think it has to do with the this
like in ES6. But I do notice that the one declared in fat arrow syntax has issues when I attempt to overload.
For example, this would not be acceptable:
build: (paramOne: string) => void
build: (paramOne: number, paramTwo: string) => void
This would give an error:
Subsequent property declarations must have the same type. Property 'build' must be of type '{ (paramOne: string): string; (paramOne: number, paramTwo: string): number; }', but here has type '(params: unknown) => void
But this is OK:
build(paramOne: string): string;
build(paramOne: number, paramTwo: string): number;
So, are the 2 syntaxes the same? Are there any differences or scenarios I should use one over another?