1616* limitations under the License.
1717*/
1818
19+ /* eslint-disable @typescript-eslint/unified-signatures */
20+
1921// TypeScript Version: 4.1
2022
2123/// <reference types="@stdlib/types"/>
2224
23- import { RealOrComplexTypedArray , DataType , Collection } from '@stdlib/types/array' ;
25+ import { Collection , DataTypeMap } from '@stdlib/types/array' ;
2426import { IterableIterator } from '@stdlib/types/iter' ;
2527
26- /**
27- * Array or typed array.
28- */
29- type ArrayOrTypedArray = Array < any > | RealOrComplexTypedArray ;
30-
3128/**
3229* Creates a filled array.
3330*
@@ -57,7 +54,7 @@ type ArrayOrTypedArray = Array<any> | RealOrComplexTypedArray;
5754* var arr = filledarray( 'float32' );
5855* // returns <Float32Array>
5956*/
60- declare function filledarray ( dtype ?: DataType ) : ArrayOrTypedArray ;
57+ declare function filledarray < T = any , U extends keyof DataTypeMap < T > = 'float64' > ( dtype ?: U ) : DataTypeMap < any > [ U ] ;
6158
6259/**
6360* Creates a filled array having a specified `length`.
@@ -75,7 +72,7 @@ declare function filledarray( dtype?: DataType ): ArrayOrTypedArray;
7572* var arr = filledarray( 1.0, 5, 'float32' );
7673* // returns <Float32Array>[ 1.0, 1.0, 1.0, 1.0, 1.0 ]
7774*/
78- declare function filledarray ( value : any , length : number , dtype ?: DataType ) : ArrayOrTypedArray ;
75+ declare function filledarray < T , U extends keyof DataTypeMap < T > = 'float64' > ( value : T , length : number , dtype ?: U ) : DataTypeMap < T > [ U ] ;
7976
8077/**
8178* Creates a filled array from another `array`.
@@ -93,7 +90,7 @@ declare function filledarray( value: any, length: number, dtype?: DataType ): Ar
9390* var arr = filledarray( 1.0, [ 5.0, -3.0, 2.0 ], 'float32' );
9491* // returns <Float32Array>[ 1.0, 1.0, 1.0 ]
9592*/
96- declare function filledarray ( value : any , array : Collection , dtype ?: DataType ) : ArrayOrTypedArray ;
93+ declare function filledarray < T , U extends keyof DataTypeMap < T > = 'float64' > ( value : T , array : Collection , dtype ?: U ) : DataTypeMap < T > [ U ] ;
9794
9895/**
9996* Creates a filled array from an iterable.
@@ -121,7 +118,7 @@ declare function filledarray( value: any, array: Collection, dtype?: DataType ):
121118* var arr = filledarray( 1.0, it, 'float32' );
122119* // returns <Float32Array>[ 1.0, 1.0, 1.0 ]
123120*/
124- declare function filledarray ( value : any , iterable : IterableIterator , dtype ?: DataType ) : ArrayOrTypedArray ;
121+ declare function filledarray < T , U extends keyof DataTypeMap < T > = 'float64' > ( value : T , iterable : IterableIterator , dtype ?: U ) : DataTypeMap < T > [ U ] ;
125122
126123/**
127124* Returns a filled typed array view of an `ArrayBuffer`.
@@ -151,7 +148,7 @@ declare function filledarray( value: any, iterable: IterableIterator, dtype?: Da
151148* var arr = filledarray( 1.0, buf, 8, 2, 'float32' );
152149* // returns <Float32Array>[ 1.0, 1.0 ]
153150*/
154- declare function filledarray ( value : any , buffer : ArrayBuffer , byteOffset : number , length : number , dtype ?: DataType ) : RealOrComplexTypedArray ;
151+ declare function filledarray < T , U extends keyof DataTypeMap < T > = 'float64' > ( value : T , buffer : ArrayBuffer , byteOffset : number , length : number , dtype ?: U ) : DataTypeMap < T > [ U ] ;
155152
156153/**
157154* Returns a filled typed array view of an `ArrayBuffer`.
@@ -180,7 +177,7 @@ declare function filledarray( value: any, buffer: ArrayBuffer, byteOffset: numbe
180177* var arr = filledarray( 1.0, buf, 8, 'float32' );
181178* // returns <Float32Array>[ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ]
182179*/
183- declare function filledarray ( value : any , buffer : ArrayBuffer , byteOffset : number , dtype ?: DataType ) : RealOrComplexTypedArray ;
180+ declare function filledarray < T , U extends keyof DataTypeMap < T > = 'float64' > ( value : T , buffer : ArrayBuffer , byteOffset : number , dtype ?: U ) : DataTypeMap < T > [ U ] ;
184181
185182/**
186183* Returns a filled typed array view of an `ArrayBuffer`.
@@ -208,7 +205,7 @@ declare function filledarray( value: any, buffer: ArrayBuffer, byteOffset: numbe
208205* var arr = filledarray( 1.0, buf, 'float32' );
209206* // returns <Float32Array>[ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ]
210207*/
211- declare function filledarray ( value : any , buffer : ArrayBuffer , dtype ?: DataType ) : RealOrComplexTypedArray ;
208+ declare function filledarray < T , U extends keyof DataTypeMap < T > = 'float64' > ( value : T , buffer : ArrayBuffer , dtype ?: U ) : DataTypeMap < T > [ U ] ;
212209
213210
214211// EXPORTS //
0 commit comments