You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
(6,16): error TS1057: An async function or method must have a valid awaitable return type.
(7,10): error TS1059: Return expression in async function does not have a valid callable 'then' member.
Again, if I remove the async keyword, this example compiles successfully.
Use Case D: Succeeds with string lookup type
The issue seems only to occur if the resolved lookup type is of type any.
This is due to the fact that an IndexedType in our type system that points to any does not itself have the TypeFlags.Any flag, so it fails one of the conditions for checking for a "thenable" type. However, when we compare the type to Thenable, our type checking logic treats TObj['anyProp'] as any, which is why it is failing.
Uh oh!
There was an error while loading. Please reload this page.
TypeScript Version: 2.2.0-dev.20161221
Code
Use Case A: Fails with
async
keyword, andany
lookup typeExpected behavior:
Code should compile successfully
Actual behavior:
Code does not compile. Emits an error:
Where
(6,16)
is the location ofgetAnyProp
Use case B: Succeeds without
async
keywordNote that the code will compile if you remove the
async
keyword:Use case C: Fails with
async
keyword, and generic passed toPromise.resolve
I also get a strange error if I pass a generic to
Promise.resolve
:Results in:
Again, if I remove the
async
keyword, this example compiles successfully.Use Case D: Succeeds with
string
lookup typeThe issue seems only to occur if the resolved lookup type is of type
any
.This code, for example, compile successfully.
It will also compile successfully with
number
,boolean
,void
, or{}
.Use Case E: Succeeds without generic
If I do not use generics, the code compiles successfully.
For example:
Thank you for your help! I'm really loving the new lookup types.
The text was updated successfully, but these errors were encountered: