Skip to content

Commit ab5117a

Browse files
committed
Add tests
1 parent 4544384 commit ab5117a

8 files changed

+83
-8
lines changed

Diff for: tests/baselines/reference/correctOrderOfPromiseMethod.js

+7-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ async function countEverything(): Promise<number> {
1515
const [resultA, resultB] = await Promise.all([
1616
providerA(),
1717
providerB(),
18-
] as const);
18+
]);
1919

2020
const dataA: A[] = resultA;
2121
const dataB: B[] = resultB;
@@ -24,6 +24,10 @@ async function countEverything(): Promise<number> {
2424
}
2525
return 0;
2626
}
27+
28+
// #31179
29+
30+
const expected: Promise<["a", "b", "c"]> = Promise.all(undefined as readonly ["a", "b", "c"]);
2731

2832

2933
//// [correctOrderOfPromiseMethod.js]
@@ -92,3 +96,5 @@ function countEverything() {
9296
});
9397
});
9498
}
99+
// #31179
100+
var expected = Promise.all(undefined);

Diff for: tests/baselines/reference/correctOrderOfPromiseMethod.symbols

+11-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ async function countEverything(): Promise<number> {
4343
providerB(),
4444
>providerB : Symbol(providerB, Decl(correctOrderOfPromiseMethod.ts, 11, 9))
4545

46-
] as const);
46+
]);
4747

4848
const dataA: A[] = resultA;
4949
>dataA : Symbol(dataA, Decl(correctOrderOfPromiseMethod.ts, 18, 9))
@@ -70,3 +70,13 @@ async function countEverything(): Promise<number> {
7070
return 0;
7171
}
7272

73+
// #31179
74+
75+
const expected: Promise<["a", "b", "c"]> = Promise.all(undefined as readonly ["a", "b", "c"]);
76+
>expected : Symbol(expected, Decl(correctOrderOfPromiseMethod.ts, 28, 5))
77+
>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --))
78+
>Promise.all : Symbol(PromiseConstructor.all, Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --))
79+
>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --))
80+
>all : Symbol(PromiseConstructor.all, Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --))
81+
>undefined : Symbol(undefined)
82+

Diff for: tests/baselines/reference/correctOrderOfPromiseMethod.types

+15-5
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,12 @@ async function countEverything(): Promise<number> {
2828
const [resultA, resultB] = await Promise.all([
2929
>resultA : A[]
3030
>resultB : B[]
31-
>await Promise.all([ providerA(), providerB(), ] as const) : [A[], B[]]
32-
>Promise.all([ providerA(), providerB(), ] as const) : Promise<[A[], B[]]>
31+
>await Promise.all([ providerA(), providerB(), ]) : [A[], B[]]
32+
>Promise.all([ providerA(), providerB(), ]) : Promise<[A[], B[]]>
3333
>Promise.all : { <TAll>(values: Iterable<TAll>): Promise<(TAll extends undefined ? TAll : TAll extends PromiseLike<infer UAll> ? UAll : TAll)[]>; <T extends readonly any[]>(values: T): Promise<{ -readonly [P in keyof T]: Awaited<T[P]>; }>; }
3434
>Promise : PromiseConstructor
3535
>all : { <TAll>(values: Iterable<TAll>): Promise<(TAll extends undefined ? TAll : TAll extends PromiseLike<infer UAll> ? UAll : TAll)[]>; <T extends readonly any[]>(values: T): Promise<{ -readonly [P in keyof T]: Awaited<T[P]>; }>; }
36-
>[ providerA(), providerB(), ] as const : readonly [Promise<A[]>, Promise<B[]>]
37-
>[ providerA(), providerB(), ] : readonly [Promise<A[]>, Promise<B[]>]
36+
>[ providerA(), providerB(), ] : [Promise<A[]>, Promise<B[]>]
3837

3938
providerA(),
4039
>providerA() : Promise<A[]>
@@ -44,7 +43,7 @@ async function countEverything(): Promise<number> {
4443
>providerB() : Promise<B[]>
4544
>providerB : () => Promise<B[]>
4645

47-
] as const);
46+
]);
4847

4948
const dataA: A[] = resultA;
5049
>dataA : A[]
@@ -72,3 +71,14 @@ async function countEverything(): Promise<number> {
7271
>0 : 0
7372
}
7473

74+
// #31179
75+
76+
const expected: Promise<["a", "b", "c"]> = Promise.all(undefined as readonly ["a", "b", "c"]);
77+
>expected : Promise<["a", "b", "c"]>
78+
>Promise.all(undefined as readonly ["a", "b", "c"]) : Promise<["a", "b", "c"]>
79+
>Promise.all : { <TAll>(values: Iterable<TAll>): Promise<(TAll extends undefined ? TAll : TAll extends PromiseLike<infer UAll> ? UAll : TAll)[]>; <T extends readonly any[]>(values: T): Promise<{ -readonly [P in keyof T]: Awaited<T[P]>; }>; }
80+
>Promise : PromiseConstructor
81+
>all : { <TAll>(values: Iterable<TAll>): Promise<(TAll extends undefined ? TAll : TAll extends PromiseLike<infer UAll> ? UAll : TAll)[]>; <T extends readonly any[]>(values: T): Promise<{ -readonly [P in keyof T]: Awaited<T[P]>; }>; }
82+
>undefined as readonly ["a", "b", "c"] : readonly ["a", "b", "c"]
83+
>undefined : undefined
84+

Diff for: tests/baselines/reference/promiseType.js

+9
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,12 @@ const pc6 = p.then(() => Promise.reject("1"), () => {});
217217
const pc7 = p.then(() => Promise.reject("1"), () => {throw 1});
218218
const pc8 = p.then(() => Promise.reject("1"), () => Promise.resolve(1));
219219
const pc9 = p.then(() => Promise.reject("1"), () => Promise.reject(1));
220+
221+
const expected: undefined = undefined as Awaited<undefined>;
222+
223+
// #28427
224+
225+
Promise.all([undefined as Promise<string> | number]);
220226

221227

222228
//// [promiseType.js]
@@ -440,3 +446,6 @@ const pc6 = p.then(() => Promise.reject("1"), () => { });
440446
const pc7 = p.then(() => Promise.reject("1"), () => { throw 1; });
441447
const pc8 = p.then(() => Promise.reject("1"), () => Promise.resolve(1));
442448
const pc9 = p.then(() => Promise.reject("1"), () => Promise.reject(1));
449+
const expected = undefined;
450+
// #28427
451+
Promise.all([undefined]);

Diff for: tests/baselines/reference/promiseType.symbols

+14
Original file line numberDiff line numberDiff line change
@@ -1089,3 +1089,17 @@ const pc9 = p.then(() => Promise.reject("1"), () => Promise.reject(1));
10891089
>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --))
10901090
>reject : Symbol(PromiseConstructor.reject, Decl(lib.es2015.promise.d.ts, --, --))
10911091

1092+
const expected: undefined = undefined as Awaited<undefined>;
1093+
>expected : Symbol(expected, Decl(promiseType.ts, 219, 5))
1094+
>undefined : Symbol(undefined)
1095+
>Awaited : Symbol(Awaited, Decl(lib.es2015.promise.d.ts, --, --))
1096+
1097+
// #28427
1098+
1099+
Promise.all([undefined as Promise<string> | number]);
1100+
>Promise.all : Symbol(PromiseConstructor.all, Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --))
1101+
>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --))
1102+
>all : Symbol(PromiseConstructor.all, Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --))
1103+
>undefined : Symbol(undefined)
1104+
>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --))
1105+

Diff for: tests/baselines/reference/promiseType.types

+16
Original file line numberDiff line numberDiff line change
@@ -1583,3 +1583,19 @@ const pc9 = p.then(() => Promise.reject("1"), () => Promise.reject(1));
15831583
>reject : <T = never>(reason?: any) => Promise<T>
15841584
>1 : 1
15851585

1586+
const expected: undefined = undefined as Awaited<undefined>;
1587+
>expected : undefined
1588+
>undefined as Awaited<undefined> : undefined
1589+
>undefined : undefined
1590+
1591+
// #28427
1592+
1593+
Promise.all([undefined as Promise<string> | number]);
1594+
>Promise.all([undefined as Promise<string> | number]) : Promise<(string | number)[]>
1595+
>Promise.all : { <TAll>(values: Iterable<TAll>): Promise<(TAll extends undefined ? TAll : TAll extends PromiseLike<infer UAll> ? UAll : TAll)[]>; <T extends readonly any[]>(values: T): Promise<{ -readonly [P in keyof T]: Awaited<T[P]>; }>; }
1596+
>Promise : PromiseConstructor
1597+
>all : { <TAll>(values: Iterable<TAll>): Promise<(TAll extends undefined ? TAll : TAll extends PromiseLike<infer UAll> ? UAll : TAll)[]>; <T extends readonly any[]>(values: T): Promise<{ -readonly [P in keyof T]: Awaited<T[P]>; }>; }
1598+
>[undefined as Promise<string> | number] : (number | Promise<string>)[]
1599+
>undefined as Promise<string> | number : number | Promise<string>
1600+
>undefined : undefined
1601+

Diff for: tests/cases/compiler/correctOrderOfPromiseMethod.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ async function countEverything(): Promise<number> {
1717
const [resultA, resultB] = await Promise.all([
1818
providerA(),
1919
providerB(),
20-
] as const);
20+
]);
2121

2222
const dataA: A[] = resultA;
2323
const dataB: B[] = resultB;
@@ -26,3 +26,7 @@ async function countEverything(): Promise<number> {
2626
}
2727
return 0;
2828
}
29+
30+
// #31179
31+
32+
const expected: Promise<["a", "b", "c"]> = Promise.all(undefined as readonly ["a", "b", "c"]);

Diff for: tests/cases/compiler/promiseType.ts

+6
Original file line numberDiff line numberDiff line change
@@ -217,3 +217,9 @@ const pc6 = p.then(() => Promise.reject("1"), () => {});
217217
const pc7 = p.then(() => Promise.reject("1"), () => {throw 1});
218218
const pc8 = p.then(() => Promise.reject("1"), () => Promise.resolve(1));
219219
const pc9 = p.then(() => Promise.reject("1"), () => Promise.reject(1));
220+
221+
const expected: undefined = undefined as Awaited<undefined>;
222+
223+
// #28427
224+
225+
Promise.all([undefined as Promise<string> | number]);

0 commit comments

Comments
 (0)