-
Notifications
You must be signed in to change notification settings - Fork 12.6k
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
Wrong return type inference in a generic function using Promise.all #37664
Comments
If it can help i have this example Here the thing that break type inferring is the fact that one of the promises has unknown type even if its return value is not used |
**I am sorry @adrienboulle I am not sure what I should be looking for in your example you mention I think the line 13 where At this moment I am still using |
ok (OOPS!) I forgot to install the yes I have « 🍒» inside of my error messages LoL 😹 |
haha i can't blame you tu add some joy on your code! |
I'm not really sure what's going on here; we need a concise problem description to work from |
This comment has been minimized.
This comment has been minimized.
The TypeScript playground site was not working correctly for me when I have first opened this issue it is now working ... With: 3.9.0-dev.20200324 the following code But with: 3.9.0-dev.20200420 the following code |
I am using |
I got this error message and don't know what I should do ...
TypeScript code: // ... [more code]
export async function thenified<T>(
promise: Promise<T>,
funct: <R>(t: T) => R,
): Promise<any> {
return promise.then(
t => funct(t)
);
} Output: % ❯ tsc # 3.9.0-dev.20200324
lib/functional/promise-or-not.ts:10:16 - error TS2345: Argument of type 'awaited T' is not assignable to parameter of type 'T'.
'T' could be instantiated with an arbitrary type which could be unrelated to 'awaited T'.
10 t => funct(t)
~
Found 1 error.
|
Due to different other problems in my code when using other TS version I am stuck using In regard to the problem described above in my previous comment I could, meanwhile, do:
or do:
I am not sure the difference between using This is when using |
After 4.5, I don't think that this is a problem anymore thanks to the |
It's not a problem anymore indeed !!! thanks to the TS Team to have made it possible... and sorry for the long delay but at least it is now resolved for me !!! |
Can I resolve this problem below without the
awaited
keyword? how can I infer return type without having to useas unknown as R[]
and providing a hardcoded type each time?TypeScript Version: 3.9.0-dev.20200326
Search Terms:
Promise.all
promise.all generic
generic awaited
awaied
Code
Now that #37610 has reverted the
awaited
type I don't know what to do I have provided an example above but my real-life situation is as follow :Actual behavior:
Promise<MyMaybeList<Promise<number>>>
(as in 3.9.0-dev.20200326)Expected behavior:
Promise<MyMaybeList<number>>
(as in 3.9.0-dev.20200324)Related Issues:
#37610, #37526, #33055, #30551, #35998, #37534, #37115, #34925
maybe also:
#9998, #33707, #36232, #35136, #33562, #34883, #31394
as discussed in TypeScript 3.9 Iteration Plan #37198
The text was updated successfully, but these errors were encountered: