In the four functions below, the first two correctly return a number and the TypeScript compiler compiles them.
The third correctly causes a TypeScript compilation error but the fourth does not even though I expected it would?
// OK
let addNumbers: (a: number, b: number, c: number) => number = function (a, b, c) {
return a + b + c;
};
// OK
let addNumbersTwo = function (a: number, b: number, c: number): number {
return a + b + c;
};
// Correct compilation error
let addNumbersThree = function (a: number, b: number, c: number): void {
return a + b + c;
};
// Should not compile? Should give same error as addNumbersThree above
let addNumbersFour: (a: number, b: number, c: number) => void = function (a, b, c) {
return a + b + c;
};