-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Mapped types on tuples and arrays not working recursively #29442
Copy link
Copy link
Closed
Labels
BugA bug in TypeScriptA bug in TypeScriptFixedA PR has been merged for this issueA PR has been merged for this issue
Milestone
Description
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[];Related Issues:
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
BugA bug in TypeScriptA bug in TypeScriptFixedA PR has been merged for this issueA PR has been merged for this issue