TypeScript Version: 2.6.1, 2.7.0-dev.20171110
function test(a: boolean): false | Date {
if (a) {
return new Date();
}
return false;
}
async function test2() {
let b = test(true);
if (!b) {
b = new Date();
}
await Promise.all([]).then(() => {
b.getDate(); //Should compile.
})
}
Expected behavior:
Should compile
Actual behavior:
Throws with Property 'getDate' does not exist on type 'true'.
This can be reproduced with any return type and even when type inference is used.