-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Conditional types break mapped types on arrays and tuples #29702
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
cc @sandersn
TypeScript Version: 3.4.0-dev.20190131
Search Terms:
Code
type Remap1<T> = { [P in keyof T]: Remap1<T[P]>; };
type Remap2<T> = T extends object ? { [P in keyof T]: Remap2<T[P]>; } : T;
type a = Remap1<string[]>;
type b = Remap2<string[]>;Expected behavior:
a type and b type are:
any[]
But this is also wrong. Must be string[].
Actual behavior:
b type is:
{
[x: number]: string;
length: number;
toString: {};
toLocaleString: {};
pop: {};
push: {};
concat: {};
join: {};
reverse: {};
shift: {};
slice: {};
sort: {};
splice: {};
unshift: {};
indexOf: {};
lastIndexOf: {};
every: {};
... 13 more ...;
includes: {};
}
Related Issues:
#29442
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