Skip to content

Accept Iterable|ArrayLike union in Array.from, add tests#20467

Merged
DanielRosenwasser merged 1 commit into
microsoft:masterfrom
Jessidhia:array-from-union-fix
Dec 8, 2017
Merged

Accept Iterable|ArrayLike union in Array.from, add tests#20467
DanielRosenwasser merged 1 commit into
microsoft:masterfrom
Jessidhia:array-from-union-fix

Conversation

@Jessidhia
Copy link
Copy Markdown

Fixes #20432, and adds extra tests for #19682. The PR at #19693 that initially closed #19682 accidentally also fixed the incorrect inference that was making the // expect error cases not error.


const result1: A[] = Array.from(inputA);
const result2: A[] = Array.from(inputA.values());
const result3: B[] = Array.from(inputA.values()); // expect error
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would not error out if mapfn was optional instead of an extra parameter in an overload

@DanielRosenwasser DanielRosenwasser merged commit 8d209a3 into microsoft:master Dec 8, 2017
@Jessidhia Jessidhia deleted the array-from-union-fix branch December 8, 2017 02:44
@microsoft microsoft locked and limited conversation to collaborators Jun 14, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Array.from does not accept Iterable<T>|ArrayLike<T> argument Unnecessary widening of function argument's type

2 participants