-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Async function not type checking correctly #15830
New issue
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
Comments
Hi, As your inner function does not specify the type the type is recognized automatically form inside of the function - I just checked: with async its
without async its
Isn't this correct behavior? |
Hi @fis-cz. The inner type is inferred to have that return type, however the outer |
when I do
it works correctly. Is there a reason why not to explicitly define return type of the innerFn? (ofc, it should be working correctly in both cases) |
I don't always add type annotations for my function returns. I don't want it to silently fail when relying on inference. |
Addressed by #15104 |
Automatically closing this issue for housekeeping purposes. The issue labels indicate that it is unactionable at the moment or has already been addressed. |
TypeScript Version: 2.3.2
Code
Expected behavior:
return innerFn()
should error withType 'string' is not assignable to type 'number'.
Actual behavior:
return innerFn()
does not error.If you remove the
async
keyword from the async function, the program type checks as expected:The text was updated successfully, but these errors were encountered: