Skip to content

Commit 245e6f9

Browse files
committed
refactor: improve type specificity and ensure consistency between ndarray types
--- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed ---
1 parent b582752 commit 245e6f9

File tree

1 file changed

+29
-53
lines changed

1 file changed

+29
-53
lines changed

lib/node_modules/@stdlib/types/index.d.ts

Lines changed: 29 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1892,10 +1892,10 @@ declare module '@stdlib/types/ndarray' {
18921892
}
18931893

18941894
/**
1895-
* Interface describing an ndarray having a generic data type.
1895+
* Interface describing an ndarray having a homogeneous data type.
18961896
*
18971897
* @example
1898-
* const arr: genericndarray<any> = {
1898+
* const arr: typedndarray<number> = {
18991899
* 'byteLength': null,
19001900
* 'BYTES_PER_ELEMENT': null,
19011901
* 'data': [ 1, 2, 3 ],
@@ -1919,22 +1919,7 @@ declare module '@stdlib/types/ndarray' {
19191919
* }
19201920
* };
19211921
*/
1922-
interface genericndarray<T> extends ndarray {
1923-
/**
1924-
* Size (in bytes) of the array.
1925-
*/
1926-
byteLength: null;
1927-
1928-
/**
1929-
* Size (in bytes) of each array element.
1930-
*/
1931-
BYTES_PER_ELEMENT: null;
1932-
1933-
/**
1934-
* Underlying data type.
1935-
*/
1936-
dtype: 'generic';
1937-
1922+
interface typedndarray<T> extends ndarray {
19381923
/**
19391924
* A reference to the underlying data buffer.
19401925
*/
@@ -1962,14 +1947,14 @@ declare module '@stdlib/types/ndarray' {
19621947
* @param args - subscripts and value to set
19631948
* @returns ndarray instance
19641949
*/
1965-
set( ...args: Array<number|T> ): genericndarray<T>;
1950+
set( ...args: Array<number | T> ): typedndarray<T>;
19661951
}
19671952

19681953
/**
1969-
* Interface describing an ndarray having a homogeneous data type.
1954+
* Interface describing an ndarray having a generic data type.
19701955
*
19711956
* @example
1972-
* const arr: typedndarray<number> = {
1957+
* const arr: genericndarray<any> = {
19731958
* 'byteLength': null,
19741959
* 'BYTES_PER_ELEMENT': null,
19751960
* 'data': [ 1, 2, 3 ],
@@ -1993,7 +1978,22 @@ declare module '@stdlib/types/ndarray' {
19931978
* }
19941979
* };
19951980
*/
1996-
interface typedndarray<T> extends ndarray {
1981+
interface genericndarray<T> extends typedndarray<T> {
1982+
/**
1983+
* Size (in bytes) of the array.
1984+
*/
1985+
byteLength: null;
1986+
1987+
/**
1988+
* Size (in bytes) of each array element.
1989+
*/
1990+
BYTES_PER_ELEMENT: null;
1991+
1992+
/**
1993+
* Underlying data type.
1994+
*/
1995+
dtype: 'generic';
1996+
19971997
/**
19981998
* A reference to the underlying data buffer.
19991999
*/
@@ -2021,7 +2021,7 @@ declare module '@stdlib/types/ndarray' {
20212021
* @param args - subscripts and value to set
20222022
* @returns ndarray instance
20232023
*/
2024-
set( ...args: Array<number | T> ): typedndarray<T>;
2024+
set( ...args: Array<number|T> ): genericndarray<T>;
20252025
}
20262026

20272027
/**
@@ -2989,7 +2989,7 @@ declare module '@stdlib/types/ndarray' {
29892989
* }
29902990
* };
29912991
*/
2992-
interface realcomplexndarray extends ndarray {
2992+
interface realcomplexndarray extends typedndarray<number | ComplexLike> {
29932993
/**
29942994
* Size (in bytes) of the array.
29952995
*/
@@ -3010,18 +3010,6 @@ declare module '@stdlib/types/ndarray' {
30103010
*/
30113011
dtype: NumericDataType;
30123012

3013-
/**
3014-
* Returns an array element specified according to provided subscripts.
3015-
*
3016-
* ## Notes
3017-
*
3018-
* - The number of provided subscripts should equal the number of dimensions.
3019-
*
3020-
* @param args - subscripts
3021-
* @returns array element
3022-
*/
3023-
get( ...args: Array<number> ): number | ComplexLike | void;
3024-
30253013
/**
30263014
* Sets an array element specified according to provided subscripts.
30273015
*
@@ -3063,7 +3051,7 @@ declare module '@stdlib/types/ndarray' {
30633051
* }
30643052
* };
30653053
*/
3066-
interface floatcomplexndarray extends ndarray {
3054+
interface floatcomplexndarray extends typedndarray<number | ComplexLike> {
30673055
/**
30683056
* Size (in bytes) of the array.
30693057
*/
@@ -3084,18 +3072,6 @@ declare module '@stdlib/types/ndarray' {
30843072
*/
30853073
dtype: FloatingPointDataType;
30863074

3087-
/**
3088-
* Returns an array element specified according to provided subscripts.
3089-
*
3090-
* ## Notes
3091-
*
3092-
* - The number of provided subscripts should equal the number of dimensions.
3093-
*
3094-
* @param args - subscripts
3095-
* @returns array element
3096-
*/
3097-
get( ...args: Array<number> ): number | ComplexLike | void;
3098-
30993075
/**
31003076
* Sets an array element specified according to provided subscripts.
31013077
*
@@ -3137,7 +3113,7 @@ declare module '@stdlib/types/ndarray' {
31373113
* }
31383114
* };
31393115
*/
3140-
interface complexndarray extends ndarray {
3116+
interface complexndarray extends typedndarray<ComplexLike> {
31413117
/**
31423118
* Size (in bytes) of the array.
31433119
*/
@@ -3168,7 +3144,7 @@ declare module '@stdlib/types/ndarray' {
31683144
* @param args - subscripts
31693145
* @returns array element
31703146
*/
3171-
get( ...args: Array<number> ): ComplexLike | void;
3147+
get( ...args: Array<number> ): ComplexLike;
31723148

31733149
/**
31743150
* Sets an array element specified according to provided subscripts.
@@ -3237,7 +3213,7 @@ declare module '@stdlib/types/ndarray' {
32373213
* @param args - subscripts
32383214
* @returns array element
32393215
*/
3240-
get( ...args: Array<number> ): Complex128 | void;
3216+
get( ...args: Array<number> ): Complex128;
32413217

32423218
/**
32433219
* Sets an array element specified according to provided subscripts.
@@ -3306,7 +3282,7 @@ declare module '@stdlib/types/ndarray' {
33063282
* @param args - subscripts
33073283
* @returns array element
33083284
*/
3309-
get( ...args: Array<number> ): Complex64 | void;
3285+
get( ...args: Array<number> ): Complex64;
33103286

33113287
/**
33123288
* Sets an array element specified according to provided subscripts.

0 commit comments

Comments
 (0)