Skip to content

Mapped types on tuples and arrays not working recursively #29442

Description

TypeScript Version: 3.2.2 (ts playground)

Search Terms: recursive, mapped types, tuple, array

Code

typeDeepMap<Textendsunknown[],R>={[KinkeyofT]: T[K]extendsunknown[] ? DeepMap<T[K],R> : R;};typetup=[string,[string,[string]]];typearr=string[][];typet1=DeepMap<tup,number>;typet2=DeepMap<arr,number>;

Expected behavior:

typet1=[number,[number,[number]]];typet2=number[][];

Actual behavior:

typet1=[number,any];typet2=any[];

Playground Link:

Related Issues:

Metadata

Metadata

Labels

BugA bug in TypeScriptFixedA PR has been merged for this issue

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions