TypeScript icon indicating copy to clipboard operation
TypeScript copied to clipboard

Multi await support

Open smcreator opened this issue 10 years ago • 1 comments

Dear, TypeScript team,

Could it be more efficient and convenient way to use multi await support. I wrote an example below:

 let sums = await Promise.all(result.map(item=> this.get<number>(`/api/values/${item}`)));

may it be better to use more smart syntax here:

 let sums = await result.map(item=> this.get<number>(`/api/values/${item}`));

so compiler here should use overloaded version of await: first with one promise parameter, and second with array of promises. So this is just my offer for simplify this. Thank you in advance!

Expected behavior: let sums = await result.map(item=> this.get(/api/values/${item}));

Actual behavior: let sums = await result.map(item=> this.get(/api/values/${item}));

Regards, Serik

smcreator avatar Feb 26 '16 07:02 smcreator

Changing the emit of await based on the type of its awaited expression goes against certain principles of our language - mainly that we avoid type-informed emit.

DanielRosenwasser avatar Feb 26 '16 08:02 DanielRosenwasser