-
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.
🤖 Pick PR #58098 (Fix constraints of nested homomorph...) into releas…
…e-5.4 (#58118) Co-authored-by: Anders Hejlsberg <[email protected]>
- Loading branch information
1 parent
71b2f84
commit 9f33bf1
Showing
4 changed files
with
103 additions
and
7 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
51 changes: 51 additions & 0 deletions
51
tests/baselines/reference/homomorphicMappedTypeNesting.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,51 @@ | ||
//// [tests/cases/compiler/homomorphicMappedTypeNesting.ts] //// | ||
|
||
=== homomorphicMappedTypeNesting.ts === | ||
// Repro from #58060 | ||
|
||
type Box<T extends string> = { v: T }; | ||
>Box : Symbol(Box, Decl(homomorphicMappedTypeNesting.ts, 0, 0)) | ||
>T : Symbol(T, Decl(homomorphicMappedTypeNesting.ts, 2, 9)) | ||
>v : Symbol(v, Decl(homomorphicMappedTypeNesting.ts, 2, 30)) | ||
>T : Symbol(T, Decl(homomorphicMappedTypeNesting.ts, 2, 9)) | ||
|
||
type Test<T extends string[]> = T | ||
>Test : Symbol(Test, Decl(homomorphicMappedTypeNesting.ts, 2, 38)) | ||
>T : Symbol(T, Decl(homomorphicMappedTypeNesting.ts, 4, 10)) | ||
>T : Symbol(T, Decl(homomorphicMappedTypeNesting.ts, 4, 10)) | ||
|
||
type UnboxArray<T> = { | ||
>UnboxArray : Symbol(UnboxArray, Decl(homomorphicMappedTypeNesting.ts, 4, 33)) | ||
>T : Symbol(T, Decl(homomorphicMappedTypeNesting.ts, 6, 16)) | ||
|
||
[K in keyof T]: T[K] extends Box<infer R> ? R : never; | ||
>K : Symbol(K, Decl(homomorphicMappedTypeNesting.ts, 7, 5)) | ||
>T : Symbol(T, Decl(homomorphicMappedTypeNesting.ts, 6, 16)) | ||
>T : Symbol(T, Decl(homomorphicMappedTypeNesting.ts, 6, 16)) | ||
>K : Symbol(K, Decl(homomorphicMappedTypeNesting.ts, 7, 5)) | ||
>Box : Symbol(Box, Decl(homomorphicMappedTypeNesting.ts, 0, 0)) | ||
>R : Symbol(R, Decl(homomorphicMappedTypeNesting.ts, 7, 42)) | ||
>R : Symbol(R, Decl(homomorphicMappedTypeNesting.ts, 7, 42)) | ||
|
||
}; | ||
|
||
type Identity<T> = { [K in keyof T]: T[K] }; | ||
>Identity : Symbol(Identity, Decl(homomorphicMappedTypeNesting.ts, 8, 2)) | ||
>T : Symbol(T, Decl(homomorphicMappedTypeNesting.ts, 10, 14)) | ||
>K : Symbol(K, Decl(homomorphicMappedTypeNesting.ts, 10, 22)) | ||
>T : Symbol(T, Decl(homomorphicMappedTypeNesting.ts, 10, 14)) | ||
>T : Symbol(T, Decl(homomorphicMappedTypeNesting.ts, 10, 14)) | ||
>K : Symbol(K, Decl(homomorphicMappedTypeNesting.ts, 10, 22)) | ||
|
||
declare function fnBad<T extends Array<Box<string>>>(...args: T): Test<Identity<UnboxArray<T>>>; | ||
>fnBad : Symbol(fnBad, Decl(homomorphicMappedTypeNesting.ts, 10, 44)) | ||
>T : Symbol(T, Decl(homomorphicMappedTypeNesting.ts, 12, 23)) | ||
>Array : Symbol(Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) | ||
>Box : Symbol(Box, Decl(homomorphicMappedTypeNesting.ts, 0, 0)) | ||
>args : Symbol(args, Decl(homomorphicMappedTypeNesting.ts, 12, 53)) | ||
>T : Symbol(T, Decl(homomorphicMappedTypeNesting.ts, 12, 23)) | ||
>Test : Symbol(Test, Decl(homomorphicMappedTypeNesting.ts, 2, 38)) | ||
>Identity : Symbol(Identity, Decl(homomorphicMappedTypeNesting.ts, 8, 2)) | ||
>UnboxArray : Symbol(UnboxArray, Decl(homomorphicMappedTypeNesting.ts, 4, 33)) | ||
>T : Symbol(T, Decl(homomorphicMappedTypeNesting.ts, 12, 23)) | ||
|
25 changes: 25 additions & 0 deletions
25
tests/baselines/reference/homomorphicMappedTypeNesting.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,25 @@ | ||
//// [tests/cases/compiler/homomorphicMappedTypeNesting.ts] //// | ||
|
||
=== homomorphicMappedTypeNesting.ts === | ||
// Repro from #58060 | ||
|
||
type Box<T extends string> = { v: T }; | ||
>Box : Box<T> | ||
>v : T | ||
|
||
type Test<T extends string[]> = T | ||
>Test : T | ||
|
||
type UnboxArray<T> = { | ||
>UnboxArray : UnboxArray<T> | ||
|
||
[K in keyof T]: T[K] extends Box<infer R> ? R : never; | ||
}; | ||
|
||
type Identity<T> = { [K in keyof T]: T[K] }; | ||
>Identity : Identity<T> | ||
|
||
declare function fnBad<T extends Array<Box<string>>>(...args: T): Test<Identity<UnboxArray<T>>>; | ||
>fnBad : <T extends Box<string>[]>(...args: T) => Test<Identity<UnboxArray<T>>> | ||
>args : T | ||
|
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,16 @@ | ||
// @strict: true | ||
// @noEmit: true | ||
|
||
// Repro from #58060 | ||
|
||
type Box<T extends string> = { v: T }; | ||
|
||
type Test<T extends string[]> = T | ||
|
||
type UnboxArray<T> = { | ||
[K in keyof T]: T[K] extends Box<infer R> ? R : never; | ||
}; | ||
|
||
type Identity<T> = { [K in keyof T]: T[K] }; | ||
|
||
declare function fnBad<T extends Array<Box<string>>>(...args: T): Test<Identity<UnboxArray<T>>>; |