-
Notifications
You must be signed in to change notification settings - Fork 12.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
189 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
tests/baselines/reference/mappedTypeOverArrayWithBareAnyRestCanBeUsedAsRestParam1.symbols
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
//// [tests/cases/compiler/mappedTypeOverArrayWithBareAnyRestCanBeUsedAsRestParam1.ts] //// | ||
|
||
=== mappedTypeOverArrayWithBareAnyRestCanBeUsedAsRestParam1.ts === | ||
// https://github.com/microsoft/TypeScript/issues/55932 | ||
|
||
type Replace<T extends [...any], A, B> = { | ||
>Replace : Symbol(Replace, Decl(mappedTypeOverArrayWithBareAnyRestCanBeUsedAsRestParam1.ts, 0, 0)) | ||
>T : Symbol(T, Decl(mappedTypeOverArrayWithBareAnyRestCanBeUsedAsRestParam1.ts, 2, 13)) | ||
>A : Symbol(A, Decl(mappedTypeOverArrayWithBareAnyRestCanBeUsedAsRestParam1.ts, 2, 32)) | ||
>B : Symbol(B, Decl(mappedTypeOverArrayWithBareAnyRestCanBeUsedAsRestParam1.ts, 2, 35)) | ||
|
||
[K in keyof T]: T[K] extends A ? B : T[K]; | ||
>K : Symbol(K, Decl(mappedTypeOverArrayWithBareAnyRestCanBeUsedAsRestParam1.ts, 3, 3)) | ||
>T : Symbol(T, Decl(mappedTypeOverArrayWithBareAnyRestCanBeUsedAsRestParam1.ts, 2, 13)) | ||
>T : Symbol(T, Decl(mappedTypeOverArrayWithBareAnyRestCanBeUsedAsRestParam1.ts, 2, 13)) | ||
>K : Symbol(K, Decl(mappedTypeOverArrayWithBareAnyRestCanBeUsedAsRestParam1.ts, 3, 3)) | ||
>A : Symbol(A, Decl(mappedTypeOverArrayWithBareAnyRestCanBeUsedAsRestParam1.ts, 2, 32)) | ||
>B : Symbol(B, Decl(mappedTypeOverArrayWithBareAnyRestCanBeUsedAsRestParam1.ts, 2, 35)) | ||
>T : Symbol(T, Decl(mappedTypeOverArrayWithBareAnyRestCanBeUsedAsRestParam1.ts, 2, 13)) | ||
>K : Symbol(K, Decl(mappedTypeOverArrayWithBareAnyRestCanBeUsedAsRestParam1.ts, 3, 3)) | ||
|
||
}; | ||
|
||
type ReplaceParams1<ARRAY extends [...any], A, B> = ( | ||
>ReplaceParams1 : Symbol(ReplaceParams1, Decl(mappedTypeOverArrayWithBareAnyRestCanBeUsedAsRestParam1.ts, 4, 2)) | ||
>ARRAY : Symbol(ARRAY, Decl(mappedTypeOverArrayWithBareAnyRestCanBeUsedAsRestParam1.ts, 6, 20)) | ||
>A : Symbol(A, Decl(mappedTypeOverArrayWithBareAnyRestCanBeUsedAsRestParam1.ts, 6, 43)) | ||
>B : Symbol(B, Decl(mappedTypeOverArrayWithBareAnyRestCanBeUsedAsRestParam1.ts, 6, 46)) | ||
|
||
...args: Replace<ARRAY, A, B> | ||
>args : Symbol(args, Decl(mappedTypeOverArrayWithBareAnyRestCanBeUsedAsRestParam1.ts, 6, 53)) | ||
>Replace : Symbol(Replace, Decl(mappedTypeOverArrayWithBareAnyRestCanBeUsedAsRestParam1.ts, 0, 0)) | ||
>ARRAY : Symbol(ARRAY, Decl(mappedTypeOverArrayWithBareAnyRestCanBeUsedAsRestParam1.ts, 6, 20)) | ||
>A : Symbol(A, Decl(mappedTypeOverArrayWithBareAnyRestCanBeUsedAsRestParam1.ts, 6, 43)) | ||
>B : Symbol(B, Decl(mappedTypeOverArrayWithBareAnyRestCanBeUsedAsRestParam1.ts, 6, 46)) | ||
|
||
) => any; | ||
|
19 changes: 19 additions & 0 deletions
19
tests/baselines/reference/mappedTypeOverArrayWithBareAnyRestCanBeUsedAsRestParam1.types
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
//// [tests/cases/compiler/mappedTypeOverArrayWithBareAnyRestCanBeUsedAsRestParam1.ts] //// | ||
|
||
=== mappedTypeOverArrayWithBareAnyRestCanBeUsedAsRestParam1.ts === | ||
// https://github.com/microsoft/TypeScript/issues/55932 | ||
|
||
type Replace<T extends [...any], A, B> = { | ||
>Replace : Replace<T, A, B> | ||
|
||
[K in keyof T]: T[K] extends A ? B : T[K]; | ||
}; | ||
|
||
type ReplaceParams1<ARRAY extends [...any], A, B> = ( | ||
>ReplaceParams1 : ReplaceParams1<ARRAY, A, B> | ||
|
||
...args: Replace<ARRAY, A, B> | ||
>args : Replace<ARRAY, A, B> | ||
|
||
) => any; | ||
|
36 changes: 36 additions & 0 deletions
36
tests/baselines/reference/mappedTypesGenericTuples2.symbols
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
//// [tests/cases/conformance/types/mapped/mappedTypesGenericTuples2.ts] //// | ||
|
||
=== mappedTypesGenericTuples2.ts === | ||
// https://github.com/microsoft/TypeScript/issues/57389 | ||
|
||
declare function getT<T>(): T; | ||
>getT : Symbol(getT, Decl(mappedTypesGenericTuples2.ts, 0, 0)) | ||
>T : Symbol(T, Decl(mappedTypesGenericTuples2.ts, 2, 22)) | ||
>T : Symbol(T, Decl(mappedTypesGenericTuples2.ts, 2, 22)) | ||
|
||
Promise.all([getT<string>(), ...getT<any>()]).then((result) => { | ||
>Promise.all([getT<string>(), ...getT<any>()]).then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) | ||
>Promise.all : Symbol(PromiseConstructor.all, Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) | ||
>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, --, --)) | ||
>all : Symbol(PromiseConstructor.all, Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) | ||
>getT : Symbol(getT, Decl(mappedTypesGenericTuples2.ts, 0, 0)) | ||
>getT : Symbol(getT, Decl(mappedTypesGenericTuples2.ts, 0, 0)) | ||
>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) | ||
>result : Symbol(result, Decl(mappedTypesGenericTuples2.ts, 4, 52)) | ||
|
||
const head = result[0]; // string | ||
>head : Symbol(head, Decl(mappedTypesGenericTuples2.ts, 5, 7)) | ||
>result : Symbol(result, Decl(mappedTypesGenericTuples2.ts, 4, 52)) | ||
>0 : Symbol(0) | ||
|
||
const tail = result.slice(1); // any[] | ||
>tail : Symbol(tail, Decl(mappedTypesGenericTuples2.ts, 6, 7)) | ||
>result.slice : Symbol(Array.slice, Decl(lib.es5.d.ts, --, --)) | ||
>result : Symbol(result, Decl(mappedTypesGenericTuples2.ts, 4, 52)) | ||
>slice : Symbol(Array.slice, Decl(lib.es5.d.ts, --, --)) | ||
|
||
tail satisfies string[]; // ok | ||
>tail : Symbol(tail, Decl(mappedTypesGenericTuples2.ts, 6, 7)) | ||
|
||
}); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
//// [tests/cases/conformance/types/mapped/mappedTypesGenericTuples2.ts] //// | ||
|
||
=== mappedTypesGenericTuples2.ts === | ||
// https://github.com/microsoft/TypeScript/issues/57389 | ||
|
||
declare function getT<T>(): T; | ||
>getT : <T>() => T | ||
|
||
Promise.all([getT<string>(), ...getT<any>()]).then((result) => { | ||
>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> | ||
>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> | ||
>Promise.all([getT<string>(), ...getT<any>()]) : Promise<[string, ...any[]]> | ||
>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]>; }>; } | ||
>Promise : PromiseConstructor | ||
>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]>; }>; } | ||
>[getT<string>(), ...getT<any>()] : [string, ...any[]] | ||
>getT<string>() : string | ||
>getT : <T>() => T | ||
>...getT<any>() : any | ||
>getT<any>() : any | ||
>getT : <T>() => T | ||
>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> | ||
>(result) => { const head = result[0]; // string const tail = result.slice(1); // any[] tail satisfies string[]; // ok} : (result: [string, ...any[]]) => void | ||
>result : [string, ...any[]] | ||
|
||
const head = result[0]; // string | ||
>head : string | ||
>result[0] : string | ||
>result : [string, ...any[]] | ||
>0 : 0 | ||
|
||
const tail = result.slice(1); // any[] | ||
>tail : any[] | ||
>result.slice(1) : any[] | ||
>result.slice : (start?: number | undefined, end?: number | undefined) => any[] | ||
>result : [string, ...any[]] | ||
>slice : (start?: number | undefined, end?: number | undefined) => any[] | ||
>1 : 1 | ||
|
||
tail satisfies string[]; // ok | ||
>tail satisfies string[] : any[] | ||
>tail : any[] | ||
|
||
}); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
tests/cases/compiler/mappedTypeOverArrayWithBareAnyRestCanBeUsedAsRestParam1.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
// @strict: true | ||
// @noEmit: true | ||
|
||
// https://github.com/microsoft/TypeScript/issues/55932 | ||
|
||
type Replace<T extends [...any], A, B> = { | ||
[K in keyof T]: T[K] extends A ? B : T[K]; | ||
}; | ||
|
||
type ReplaceParams1<ARRAY extends [...any], A, B> = ( | ||
...args: Replace<ARRAY, A, B> | ||
) => any; |
13 changes: 13 additions & 0 deletions
13
tests/cases/conformance/types/mapped/mappedTypesGenericTuples2.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// @strict: true | ||
// @lib: esnext | ||
// @noEmit: true | ||
|
||
// https://github.com/microsoft/TypeScript/issues/57389 | ||
|
||
declare function getT<T>(): T; | ||
|
||
Promise.all([getT<string>(), ...getT<any>()]).then((result) => { | ||
const head = result[0]; // string | ||
const tail = result.slice(1); // any[] | ||
tail satisfies string[]; // ok | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters