Skip to content

Commit a08d7d7

Browse files
committed
add an extra test case
1 parent 67e1810 commit a08d7d7

File tree

3 files changed

+94
-0
lines changed

3 files changed

+94
-0
lines changed
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
//// [tests/cases/conformance/types/mapped/mappedTypesGenericTuples2.ts] ////
2+
3+
=== mappedTypesGenericTuples2.ts ===
4+
// https://github.com/microsoft/TypeScript/issues/57389
5+
6+
declare function getT<T>(): T;
7+
>getT : Symbol(getT, Decl(mappedTypesGenericTuples2.ts, 0, 0))
8+
>T : Symbol(T, Decl(mappedTypesGenericTuples2.ts, 2, 22))
9+
>T : Symbol(T, Decl(mappedTypesGenericTuples2.ts, 2, 22))
10+
11+
Promise.all([getT<string>(), ...getT<any>()]).then((result) => {
12+
>Promise.all([getT<string>(), ...getT<any>()]).then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --))
13+
>Promise.all : Symbol(PromiseConstructor.all, Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --))
14+
>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, --, --), Decl(lib.es2018.promise.d.ts, --, --))
15+
>all : Symbol(PromiseConstructor.all, Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --))
16+
>getT : Symbol(getT, Decl(mappedTypesGenericTuples2.ts, 0, 0))
17+
>getT : Symbol(getT, Decl(mappedTypesGenericTuples2.ts, 0, 0))
18+
>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --))
19+
>result : Symbol(result, Decl(mappedTypesGenericTuples2.ts, 4, 52))
20+
21+
const head = result[0]; // string
22+
>head : Symbol(head, Decl(mappedTypesGenericTuples2.ts, 5, 7))
23+
>result : Symbol(result, Decl(mappedTypesGenericTuples2.ts, 4, 52))
24+
>0 : Symbol(0)
25+
26+
const tail = result.slice(1); // any[]
27+
>tail : Symbol(tail, Decl(mappedTypesGenericTuples2.ts, 6, 7))
28+
>result.slice : Symbol(Array.slice, Decl(lib.es5.d.ts, --, --))
29+
>result : Symbol(result, Decl(mappedTypesGenericTuples2.ts, 4, 52))
30+
>slice : Symbol(Array.slice, Decl(lib.es5.d.ts, --, --))
31+
32+
tail satisfies string[]; // ok
33+
>tail : Symbol(tail, Decl(mappedTypesGenericTuples2.ts, 6, 7))
34+
35+
});
36+
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
//// [tests/cases/conformance/types/mapped/mappedTypesGenericTuples2.ts] ////
2+
3+
=== mappedTypesGenericTuples2.ts ===
4+
// https://github.com/microsoft/TypeScript/issues/57389
5+
6+
declare function getT<T>(): T;
7+
>getT : <T>() => T
8+
9+
Promise.all([getT<string>(), ...getT<any>()]).then((result) => {
10+
>Promise.all([getT<string>(), ...getT<any>()]).then((result) => { const head = result[0]; // string const tail = result.slice(1); // any[] tail satisfies string[]; // ok}) : Promise<void>
11+
>Promise.all([getT<string>(), ...getT<any>()]).then : <TResult1 = [string, ...any[]], TResult2 = never>(onfulfilled?: ((value: [string, ...any[]]) => TResult1 | PromiseLike<TResult1>) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | null | undefined) => Promise<TResult1 | TResult2>
12+
>Promise.all([getT<string>(), ...getT<any>()]) : Promise<[string, ...any[]]>
13+
>Promise.all : { <T>(values: Iterable<T | PromiseLike<T>>): Promise<Awaited<T>[]>; <T_1 extends readonly unknown[] | []>(values: T_1): Promise<{ -readonly [P in keyof T_1]: Awaited<T_1[P]>; }>; }
14+
>Promise : PromiseConstructor
15+
>all : { <T>(values: Iterable<T | PromiseLike<T>>): Promise<Awaited<T>[]>; <T_1 extends readonly unknown[] | []>(values: T_1): Promise<{ -readonly [P in keyof T_1]: Awaited<T_1[P]>; }>; }
16+
>[getT<string>(), ...getT<any>()] : [string, ...any[]]
17+
>getT<string>() : string
18+
>getT : <T>() => T
19+
>...getT<any>() : any
20+
>getT<any>() : any
21+
>getT : <T>() => T
22+
>then : <TResult1 = [string, ...any[]], TResult2 = never>(onfulfilled?: ((value: [string, ...any[]]) => TResult1 | PromiseLike<TResult1>) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | null | undefined) => Promise<TResult1 | TResult2>
23+
>(result) => { const head = result[0]; // string const tail = result.slice(1); // any[] tail satisfies string[]; // ok} : (result: [string, ...any[]]) => void
24+
>result : [string, ...any[]]
25+
26+
const head = result[0]; // string
27+
>head : string
28+
>result[0] : string
29+
>result : [string, ...any[]]
30+
>0 : 0
31+
32+
const tail = result.slice(1); // any[]
33+
>tail : any[]
34+
>result.slice(1) : any[]
35+
>result.slice : (start?: number | undefined, end?: number | undefined) => any[]
36+
>result : [string, ...any[]]
37+
>slice : (start?: number | undefined, end?: number | undefined) => any[]
38+
>1 : 1
39+
40+
tail satisfies string[]; // ok
41+
>tail satisfies string[] : any[]
42+
>tail : any[]
43+
44+
});
45+
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// @strict: true
2+
// @lib: esnext
3+
// @noEmit: true
4+
5+
// https://github.com/microsoft/TypeScript/issues/57389
6+
7+
declare function getT<T>(): T;
8+
9+
Promise.all([getT<string>(), ...getT<any>()]).then((result) => {
10+
const head = result[0]; // string
11+
const tail = result.slice(1); // any[]
12+
tail satisfies string[]; // ok
13+
});

0 commit comments

Comments
 (0)