Closed
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'.