Closed
Description
TypeScript Version: 2.4.0
Code
declare function test(num: string): void;
let withString: number | string;
// Error: `Type 'number' is not assignable to type 'string'.`, as expected. withString might be a number, which does not have the necessary properties to act as a string.
test(withString);
let withAny: number | any;
// No error
test(withAny);
Expected behavior:
I expected the second case to give an error. withAny
might only have the properties of a number.
Actual behavior:
withAny reduces to the type any, and so does not give an error.