mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-11-18 20:11:14 +00:00
Merge pull request #20467 from Kovensky/array-from-union-fix
Accept Iterable|ArrayLike union in Array.from, add tests
This commit is contained in:
12 files changed
+487
-18
No files matched your search
Vendored
+2
-2
@@ -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> {
|
||||
|
||||
Reference in new issue
Block a user