mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Merge pull request #16698 from Microsoft/master-16017
[Master] Fix 16017 - ordering of promise all method
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
// @lib: dom, es7
|
||||
|
||||
interface A {
|
||||
id: string
|
||||
}
|
||||
|
||||
interface B {
|
||||
id: string
|
||||
fieldB: string
|
||||
}
|
||||
|
||||
async function countEverything(): Promise<number> {
|
||||
const providerA = async (): Promise<A[]> => { return [] }
|
||||
const providerB = async (): Promise<B[]> => { return [] }
|
||||
|
||||
const [resultA, resultB] = await Promise.all([
|
||||
providerA(),
|
||||
providerB(),
|
||||
]);
|
||||
|
||||
const dataA: A[] = resultA;
|
||||
const dataB: B[] = resultB;
|
||||
if (dataA && dataB) {
|
||||
return dataA.length + dataB.length;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user