TypeScript Version: Whatever runs https://www.typescriptlang.org/play/
Code
const x = (a: number = 1): number => a;
const y: () => number = x;
// TypeScript error: "Supplied parameters do not match signature of call target."
// OK
y('x').toFixed();
const z: (a: string) => number = y;
// No TypeScript error
// Runtime error: Uncaught TypeError: z(...).toFixed is not a function
z('x').toFixed();
Expected behavior:
TypeScript error that either (a?: number) => number is incompatible with () => number, or that () => number is incompatible with (a: string) => number. I'm not sure which one is most correct, but permitting both of these things in combination is definitely unsound.
Actual behavior:
No TypeScript error on the const z: (a: string) => number = y; line nor the z('x').toFixed(); line., but an error when the code runs.
TypeScript Version: Whatever runs https://www.typescriptlang.org/play/
Code
Expected behavior:
TypeScript error that either
(a?: number) => numberis incompatible with() => number, or that() => numberis incompatible with(a: string) => number. I'm not sure which one is most correct, but permitting both of these things in combination is definitely unsound.Actual behavior:
No TypeScript error on the
const z: (a: string) => number = y;line nor thez('x').toFixed();line., but an error when the code runs.