-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Open
Labels
Experimentation NeededSomeone needs to try this out to see what happensSomeone needs to try this out to see what happens
Milestone
Description
TypeScript Version: 4.2.0-dev.20201124
Search Terms:
function, type check, any
Code
const f1: () => number = () => {
if (window) {
return {} as any;
}
return "a"; // Pass
};
// Expected behavior
const f2: () => number = () => {
return "a"; // Error: Type '() => string' is not assignable to type '() => number'
};
// Expected behavior
function f3(): number {
if (window) {
return {} as any;
}
return "a"; // Error: Type 'string' is not assignable to type 'number'.
};Expected behavior:
f1 causes an error because it returns a string.
Actual behavior:
f1 does not cause an error.
Playground Link:
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
Experimentation NeededSomeone needs to try this out to see what happensSomeone needs to try this out to see what happens