-
Notifications
You must be signed in to change notification settings - Fork 13.1k
Closed
Labels
DuplicateAn existing issue was already createdAn existing issue was already created
Description
TypeScript Version: 2.0.3
Code
function fn(str: string): void;
function fn(num: number): void;
function fn(arg) {
// do something with arg
}
function test(arg: string | number) {
fn(arg); // from whatever source I get a (string | number)
}Expected behavior: This code looks logically valid.
Actual behavior: It results in a compile error: error TS2345: Argument of type 'string | number' is not assignable to parameter of type 'number'. Type 'string' is not assignable to type 'number'.
Metadata
Metadata
Assignees
Labels
DuplicateAn existing issue was already createdAn existing issue was already created