-
Notifications
You must be signed in to change notification settings - Fork 13k
Closed
Labels
Design LimitationConstraints of the existing architecture prevent this from being fixedConstraints of the existing architecture prevent this from being fixed
Milestone
Description
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.
earshinov, topce and blutorange
Metadata
Metadata
Assignees
Labels
Design LimitationConstraints of the existing architecture prevent this from being fixedConstraints of the existing architecture prevent this from being fixed