Skip to content

Commit 9819b6b

Browse files
committed
Allow non-number array for source of TypedArray.from
1 parent e471856 commit 9819b6b

File tree

1 file changed

+64
-10
lines changed

1 file changed

+64
-10
lines changed

src/lib/es5.d.ts

Lines changed: 64 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -517,7 +517,7 @@ interface TemplateStringsArray extends ReadonlyArray<string> {
517517

518518
/**
519519
* The type of `import.meta`.
520-
*
520+
*
521521
* If you need to declare that a given property exists on `import.meta`,
522522
* this type may be augmented via interface merging.
523523
*/
@@ -1843,13 +1843,19 @@ interface Int8ArrayConstructor {
18431843
*/
18441844
of(...items: number[]): Int8Array;
18451845

1846+
/**
1847+
* Creates an array from an array-like or iterable object.
1848+
* @param arrayLike An array-like or iterable object to convert to an array.
1849+
*/
1850+
from(arrayLike: ArrayLike<number>): Int8Array;
1851+
18461852
/**
18471853
* Creates an array from an array-like or iterable object.
18481854
* @param arrayLike An array-like or iterable object to convert to an array.
18491855
* @param mapfn A mapping function to call on every element of the array.
18501856
* @param thisArg Value of 'this' used to invoke the mapfn.
18511857
*/
1852-
from(arrayLike: ArrayLike<number>, mapfn?: (v: number, k: number) => number, thisArg?: any): Int8Array;
1858+
from<T>(arrayLike: ArrayLike<T>, mapfn: (v: T, k: number) => number, thisArg?: any): Int8Array;
18531859

18541860

18551861
}
@@ -2113,13 +2119,19 @@ interface Uint8ArrayConstructor {
21132119
*/
21142120
of(...items: number[]): Uint8Array;
21152121

2122+
/**
2123+
* Creates an array from an array-like or iterable object.
2124+
* @param arrayLike An array-like or iterable object to convert to an array.
2125+
*/
2126+
from(arrayLike: ArrayLike<number>): Uint8Array;
2127+
21162128
/**
21172129
* Creates an array from an array-like or iterable object.
21182130
* @param arrayLike An array-like or iterable object to convert to an array.
21192131
* @param mapfn A mapping function to call on every element of the array.
21202132
* @param thisArg Value of 'this' used to invoke the mapfn.
21212133
*/
2122-
from(arrayLike: ArrayLike<number>, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8Array;
2134+
from<T>(arrayLike: ArrayLike<T>, mapfn: (v: T, k: number) => number, thisArg?: any): Uint8Array;
21232135

21242136
}
21252137
declare const Uint8Array: Uint8ArrayConstructor;
@@ -2382,13 +2394,19 @@ interface Uint8ClampedArrayConstructor {
23822394
*/
23832395
of(...items: number[]): Uint8ClampedArray;
23842396

2397+
/**
2398+
* Creates an array from an array-like or iterable object.
2399+
* @param arrayLike An array-like or iterable object to convert to an array.
2400+
*/
2401+
from(arrayLike: ArrayLike<number>): Uint8ClampedArray;
2402+
23852403
/**
23862404
* Creates an array from an array-like or iterable object.
23872405
* @param arrayLike An array-like or iterable object to convert to an array.
23882406
* @param mapfn A mapping function to call on every element of the array.
23892407
* @param thisArg Value of 'this' used to invoke the mapfn.
23902408
*/
2391-
from(arrayLike: ArrayLike<number>, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8ClampedArray;
2409+
from<T>(arrayLike: ArrayLike<T>, mapfn: (v: T, k: number) => number, thisArg?: any): Uint8ClampedArray;
23922410
}
23932411
declare const Uint8ClampedArray: Uint8ClampedArrayConstructor;
23942412

@@ -2649,13 +2667,19 @@ interface Int16ArrayConstructor {
26492667
*/
26502668
of(...items: number[]): Int16Array;
26512669

2670+
/**
2671+
* Creates an array from an array-like or iterable object.
2672+
* @param arrayLike An array-like or iterable object to convert to an array.
2673+
*/
2674+
from(arrayLike: ArrayLike<number>): Int16Array;
2675+
26522676
/**
26532677
* Creates an array from an array-like or iterable object.
26542678
* @param arrayLike An array-like or iterable object to convert to an array.
26552679
* @param mapfn A mapping function to call on every element of the array.
26562680
* @param thisArg Value of 'this' used to invoke the mapfn.
26572681
*/
2658-
from(arrayLike: ArrayLike<number>, mapfn?: (v: number, k: number) => number, thisArg?: any): Int16Array;
2682+
from<T>(arrayLike: ArrayLike<T>, mapfn: (v: T, k: number) => number, thisArg?: any): Int16Array;
26592683

26602684

26612685
}
@@ -2919,13 +2943,19 @@ interface Uint16ArrayConstructor {
29192943
*/
29202944
of(...items: number[]): Uint16Array;
29212945

2946+
/**
2947+
* Creates an array from an array-like or iterable object.
2948+
* @param arrayLike An array-like or iterable object to convert to an array.
2949+
*/
2950+
from(arrayLike: ArrayLike<number>): Uint16Array;
2951+
29222952
/**
29232953
* Creates an array from an array-like or iterable object.
29242954
* @param arrayLike An array-like or iterable object to convert to an array.
29252955
* @param mapfn A mapping function to call on every element of the array.
29262956
* @param thisArg Value of 'this' used to invoke the mapfn.
29272957
*/
2928-
from(arrayLike: ArrayLike<number>, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint16Array;
2958+
from<T>(arrayLike: ArrayLike<T>, mapfn: (v: T, k: number) => number, thisArg?: any): Uint16Array;
29292959

29302960

29312961
}
@@ -3188,13 +3218,19 @@ interface Int32ArrayConstructor {
31883218
*/
31893219
of(...items: number[]): Int32Array;
31903220

3221+
/**
3222+
* Creates an array from an array-like or iterable object.
3223+
* @param arrayLike An array-like or iterable object to convert to an array.
3224+
*/
3225+
from(arrayLike: ArrayLike<number>): Int32Array;
3226+
31913227
/**
31923228
* Creates an array from an array-like or iterable object.
31933229
* @param arrayLike An array-like or iterable object to convert to an array.
31943230
* @param mapfn A mapping function to call on every element of the array.
31953231
* @param thisArg Value of 'this' used to invoke the mapfn.
31963232
*/
3197-
from(arrayLike: ArrayLike<number>, mapfn?: (v: number, k: number) => number, thisArg?: any): Int32Array;
3233+
from<T>(arrayLike: ArrayLike<T>, mapfn: (v: T, k: number) => number, thisArg?: any): Int32Array;
31983234

31993235
}
32003236
declare const Int32Array: Int32ArrayConstructor;
@@ -3456,13 +3492,19 @@ interface Uint32ArrayConstructor {
34563492
*/
34573493
of(...items: number[]): Uint32Array;
34583494

3495+
/**
3496+
* Creates an array from an array-like or iterable object.
3497+
* @param arrayLike An array-like or iterable object to convert to an array.
3498+
*/
3499+
from(arrayLike: ArrayLike<number>): Uint32Array;
3500+
34593501
/**
34603502
* Creates an array from an array-like or iterable object.
34613503
* @param arrayLike An array-like or iterable object to convert to an array.
34623504
* @param mapfn A mapping function to call on every element of the array.
34633505
* @param thisArg Value of 'this' used to invoke the mapfn.
34643506
*/
3465-
from(arrayLike: ArrayLike<number>, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint32Array;
3507+
from<T>(arrayLike: ArrayLike<T>, mapfn: (v: T, k: number) => number, thisArg?: any): Uint32Array;
34663508

34673509
}
34683510
declare const Uint32Array: Uint32ArrayConstructor;
@@ -3725,13 +3767,19 @@ interface Float32ArrayConstructor {
37253767
*/
37263768
of(...items: number[]): Float32Array;
37273769

3770+
/**
3771+
* Creates an array from an array-like or iterable object.
3772+
* @param arrayLike An array-like or iterable object to convert to an array.
3773+
*/
3774+
from(arrayLike: ArrayLike<number>): Float32Array;
3775+
37283776
/**
37293777
* Creates an array from an array-like or iterable object.
37303778
* @param arrayLike An array-like or iterable object to convert to an array.
37313779
* @param mapfn A mapping function to call on every element of the array.
37323780
* @param thisArg Value of 'this' used to invoke the mapfn.
37333781
*/
3734-
from(arrayLike: ArrayLike<number>, mapfn?: (v: number, k: number) => number, thisArg?: any): Float32Array;
3782+
from<T>(arrayLike: ArrayLike<T>, mapfn: (v: T, k: number) => number, thisArg?: any): Float32Array;
37353783

37363784

37373785
}
@@ -3995,13 +4043,19 @@ interface Float64ArrayConstructor {
39954043
*/
39964044
of(...items: number[]): Float64Array;
39974045

4046+
/**
4047+
* Creates an array from an array-like or iterable object.
4048+
* @param arrayLike An array-like or iterable object to convert to an array.
4049+
*/
4050+
from(arrayLike: ArrayLike<number>): Float64Array;
4051+
39984052
/**
39994053
* Creates an array from an array-like or iterable object.
40004054
* @param arrayLike An array-like or iterable object to convert to an array.
40014055
* @param mapfn A mapping function to call on every element of the array.
40024056
* @param thisArg Value of 'this' used to invoke the mapfn.
40034057
*/
4004-
from(arrayLike: ArrayLike<number>, mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array;
4058+
from<T>(arrayLike: ArrayLike<T>, mapfn: (v: T, k: number) => number, thisArg?: any): Float64Array;
40054059

40064060
}
40074061
declare const Float64Array: Float64ArrayConstructor;

0 commit comments

Comments
 (0)