Skip to content

Conversation

@graphemecluster
Copy link
Contributor

@graphemecluster graphemecluster commented Jul 25, 2022

This is my attempt to fix #29841.

The checker now checks if a mapped type is an interface that extends an array or tuple, and if it is, only the elements of it are mapped and other non-array-prototype properties are discarded, behaving like the ES map method.

It also fixes Mapper<[number, ...string[], number]> being incorrectly mapped to [Mapper<number>, ...Mapper<string | number>[], Mapper<string | number>] instead of [Mapper<number>, ...Mapper<string>[], Mapper<number>], and [0, ...1[], 2] instead of [0, ...number[], number] when type Mapper<T> = { [P in keyof T]: P }.

I am new to the checker and the src code in general, so please, guide and correct me for anything weird.

@typescript-bot typescript-bot added the For Milestone Bug PRs that fix a bug with a specific milestone label Jul 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

For Milestone Bug PRs that fix a bug with a specific milestone

Projects

Status: Waiting on reviewers

Development

Successfully merging this pull request may close these issues.

Improve typings of Array.map when called on tuples

3 participants