diff --git a/tests/baselines/reference/mappedTypeHomomorphicTupleInstantiationNameTypeKeys.symbols b/tests/baselines/reference/mappedTypeHomomorphicTupleInstantiationNameTypeKeys.symbols new file mode 100644 index 0000000000000..a7f398bb7bb28 --- /dev/null +++ b/tests/baselines/reference/mappedTypeHomomorphicTupleInstantiationNameTypeKeys.symbols @@ -0,0 +1,36 @@ +//// [tests/cases/compiler/mappedTypeHomomorphicTupleInstantiationNameTypeKeys.ts] //// + +=== mappedTypeHomomorphicTupleInstantiationNameTypeKeys.ts === +// https://github.com/microsoft/TypeScript/pull/55774#issuecomment-1813484949 + +type Mapper = { +>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] : 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)) + diff --git a/tests/baselines/reference/mappedTypeHomomorphicTupleInstantiationNameTypeKeys.types b/tests/baselines/reference/mappedTypeHomomorphicTupleInstantiationNameTypeKeys.types new file mode 100644 index 0000000000000..314ee7c796ec8 --- /dev/null +++ b/tests/baselines/reference/mappedTypeHomomorphicTupleInstantiationNameTypeKeys.types @@ -0,0 +1,20 @@ +//// [tests/cases/compiler/mappedTypeHomomorphicTupleInstantiationNameTypeKeys.ts] //// + +=== mappedTypeHomomorphicTupleInstantiationNameTypeKeys.ts === +// https://github.com/microsoft/TypeScript/pull/55774#issuecomment-1813484949 + +type Mapper = { +>Mapper : Mapper + + [K in keyof T as K]: T[K] extends NonNullable ? 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 + diff --git a/tests/cases/compiler/mappedTypeHomomorphicTupleInstantiationNameTypeKeys.ts b/tests/cases/compiler/mappedTypeHomomorphicTupleInstantiationNameTypeKeys.ts new file mode 100644 index 0000000000000..e20c9fce401f3 --- /dev/null +++ b/tests/cases/compiler/mappedTypeHomomorphicTupleInstantiationNameTypeKeys.ts @@ -0,0 +1,13 @@ +// @strict: true +// @noEmit: true + +// https://github.com/microsoft/TypeScript/pull/55774#issuecomment-1813484949 + +type Mapper = { + [K in keyof T as K]: T[K] extends NonNullable ? T[K] : never; +}; + +type Mapped = Mapper<[1, 2]>; +type Keys = keyof Mapper<[1, 2]>; + +type SomeType = Mapped[Keys]; // ok