-
Notifications
You must be signed in to change notification settings - Fork 12.6k
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
3 changed files
with
69 additions
and
0 deletions.
There are no files selected for viewing
36 changes: 36 additions & 0 deletions
36
tests/baselines/reference/mappedTypeHomomorphicTupleInstantiationNameTypeKeys.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/compiler/mappedTypeHomomorphicTupleInstantiationNameTypeKeys.ts] //// | ||
|
||
=== mappedTypeHomomorphicTupleInstantiationNameTypeKeys.ts === | ||
// https://github.com/microsoft/TypeScript/pull/55774#issuecomment-1813484949 | ||
|
||
type Mapper<T> = { | ||
>Mapper : Symbol(Mapper, Decl(mappedTypeHomomorphicTupleInstantiationNameTypeKeys.ts, 0, 0)) | ||
>T : Symbol(T, Decl(mappedTypeHomomorphicTupleInstantiationNameTypeKeys.ts, 2, 12)) | ||
|
||
[K in keyof T as K]: T[K] extends NonNullable<T[K]> ? T[K] : never; | ||
>K : Symbol(K, Decl(mappedTypeHomomorphicTupleInstantiationNameTypeKeys.ts, 3, 3)) | ||
>T : Symbol(T, Decl(mappedTypeHomomorphicTupleInstantiationNameTypeKeys.ts, 2, 12)) | ||
>K : Symbol(K, Decl(mappedTypeHomomorphicTupleInstantiationNameTypeKeys.ts, 3, 3)) | ||
>T : Symbol(T, Decl(mappedTypeHomomorphicTupleInstantiationNameTypeKeys.ts, 2, 12)) | ||
>K : Symbol(K, Decl(mappedTypeHomomorphicTupleInstantiationNameTypeKeys.ts, 3, 3)) | ||
>NonNullable : Symbol(NonNullable, Decl(lib.es5.d.ts, --, --)) | ||
>T : Symbol(T, Decl(mappedTypeHomomorphicTupleInstantiationNameTypeKeys.ts, 2, 12)) | ||
>K : Symbol(K, Decl(mappedTypeHomomorphicTupleInstantiationNameTypeKeys.ts, 3, 3)) | ||
>T : Symbol(T, Decl(mappedTypeHomomorphicTupleInstantiationNameTypeKeys.ts, 2, 12)) | ||
>K : Symbol(K, Decl(mappedTypeHomomorphicTupleInstantiationNameTypeKeys.ts, 3, 3)) | ||
|
||
}; | ||
|
||
type Mapped = Mapper<[1, 2]>; | ||
>Mapped : Symbol(Mapped, Decl(mappedTypeHomomorphicTupleInstantiationNameTypeKeys.ts, 4, 2)) | ||
>Mapper : Symbol(Mapper, Decl(mappedTypeHomomorphicTupleInstantiationNameTypeKeys.ts, 0, 0)) | ||
|
||
type Keys = keyof Mapper<[1, 2]>; | ||
>Keys : Symbol(Keys, Decl(mappedTypeHomomorphicTupleInstantiationNameTypeKeys.ts, 6, 29)) | ||
>Mapper : Symbol(Mapper, Decl(mappedTypeHomomorphicTupleInstantiationNameTypeKeys.ts, 0, 0)) | ||
|
||
type SomeType = Mapped[Keys]; // ok | ||
>SomeType : Symbol(SomeType, Decl(mappedTypeHomomorphicTupleInstantiationNameTypeKeys.ts, 7, 33)) | ||
>Mapped : Symbol(Mapped, Decl(mappedTypeHomomorphicTupleInstantiationNameTypeKeys.ts, 4, 2)) | ||
>Keys : Symbol(Keys, Decl(mappedTypeHomomorphicTupleInstantiationNameTypeKeys.ts, 6, 29)) | ||
|
20 changes: 20 additions & 0 deletions
20
tests/baselines/reference/mappedTypeHomomorphicTupleInstantiationNameTypeKeys.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,20 @@ | ||
//// [tests/cases/compiler/mappedTypeHomomorphicTupleInstantiationNameTypeKeys.ts] //// | ||
|
||
=== mappedTypeHomomorphicTupleInstantiationNameTypeKeys.ts === | ||
// https://github.com/microsoft/TypeScript/pull/55774#issuecomment-1813484949 | ||
|
||
type Mapper<T> = { | ||
>Mapper : Mapper<T> | ||
|
||
[K in keyof T as K]: T[K] extends NonNullable<T[K]> ? T[K] : never; | ||
}; | ||
|
||
type Mapped = Mapper<[1, 2]>; | ||
>Mapped : Mapper<[1, 2]> | ||
|
||
type Keys = keyof Mapper<[1, 2]>; | ||
>Keys : "0" | "1" | ||
|
||
type SomeType = Mapped[Keys]; // ok | ||
>SomeType : 2 | 1 | ||
|
13 changes: 13 additions & 0 deletions
13
tests/cases/compiler/mappedTypeHomomorphicTupleInstantiationNameTypeKeys.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 | ||
// @noEmit: true | ||
|
||
// https://github.com/microsoft/TypeScript/pull/55774#issuecomment-1813484949 | ||
|
||
type Mapper<T> = { | ||
[K in keyof T as K]: T[K] extends NonNullable<T[K]> ? T[K] : never; | ||
}; | ||
|
||
type Mapped = Mapper<[1, 2]>; | ||
type Keys = keyof Mapper<[1, 2]>; | ||
|
||
type SomeType = Mapped[Keys]; // ok |