Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mapped types on tuples and arrays not working recursively #29442

Closed
Voronar opened this issue Jan 16, 2019 · 0 comments · Fixed by #29740
Closed

Mapped types on tuples and arrays not working recursively #29442

Voronar opened this issue Jan 16, 2019 · 0 comments · Fixed by #29740
Assignees
Labels
Bug A bug in TypeScript Fixed A PR has been merged for this issue

Comments

@Voronar
Copy link

Voronar commented Jan 16, 2019

TypeScript Version: 3.2.2 (ts playground)

Search Terms: recursive, mapped types, tuple, array

Code

type DeepMap<T extends unknown[], R> = {
  [K in keyof T]: T[K] extends unknown[] ? DeepMap<T[K], R> : R;
};

type tup = [string, [string, [string]]];
type arr = string[][];

type t1 = DeepMap<tup, number>;
type t2 = DeepMap<arr, number>;

Expected behavior:

type t1 = [number, [number, [number]]];
type t2 = number[][];

Actual behavior:

type t1 = [number, any];
type t2 = any[];

Playground Link:

Related Issues:

@RyanCavanaugh RyanCavanaugh added the Bug A bug in TypeScript label Jan 16, 2019
@RyanCavanaugh RyanCavanaugh added this to the TypeScript 3.4.0 milestone Jan 16, 2019
@ahejlsberg ahejlsberg assigned ahejlsberg and unassigned sandersn Feb 5, 2019
@ahejlsberg ahejlsberg added the Fixed A PR has been merged for this issue label Feb 6, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in TypeScript Fixed A PR has been merged for this issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants