We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
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'.
Property 'getDate' does not exist on type 'true'.
This can be reproduced with any return type and even when type inference is used.
The text was updated successfully, but these errors were encountered:
Likely duplicate of #13180. Also, see #9998 for detailed commentary and discussion.
Note: this is not related to promises.
Simple fix:
async function test2() { const b = test(true) || new Date(); await Promise.all([]).then(() => { b.getDate(); // compiles. }); }
Sorry, something went wrong.
Thanks @aluanhaddad. The simple fix works and looks like #9998 should cover this. Closing this ticket.
Successfully merging a pull request may close this issue.
TypeScript Version: 2.6.1, 2.7.0-dev.20171110
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.
The text was updated successfully, but these errors were encountered: