Merge pull request #20467 from Kovensky/array-from-union-fix

Accept Iterable|ArrayLike union in Array.from, add tests
This commit is contained in:
Daniel Rosenwasser
2017-12-07 17:22:05 -08:00
committed by GitHub
12 changed files with 487 additions and 18 deletions

View File

@@ -52,7 +52,7 @@ interface ArrayConstructor {
* Creates an array from an iterable object.
* @param iterable An iterable object to convert to an array.
*/
from<T>(iterable: Iterable<T>): T[];
from<T>(iterable: Iterable<T> | ArrayLike<T>): T[];
/**
* Creates an array from an iterable object.
@@ -60,7 +60,7 @@ interface ArrayConstructor {
* @param mapfn A mapping function to call on every element of the array.
* @param thisArg Value of 'this' used to invoke the mapfn.
*/
from<T, U>(iterable: Iterable<T>, mapfn: (v: T, k: number) => U, thisArg?: any): U[];
from<T, U>(iterable: Iterable<T> | ArrayLike<T>, mapfn: (v: T, k: number) => U, thisArg?: any): U[];
}
interface ReadonlyArray<T> {