Skip to content

Commit

Permalink
add an extra test case
Browse files Browse the repository at this point in the history
  • Loading branch information
Andarist committed Dec 28, 2023
1 parent b55610e commit 0318886
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 0 deletions.
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))

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

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

0 comments on commit 0318886

Please sign in to comment.