Skip to content

Commit 3b02ff0

Browse files
committed
Add collection type
1 parent a603fb0 commit 3b02ff0

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,8 @@ declare module '@stdlib/types/iter' {
187187
* };
188188
*/
189189
declare module '@stdlib/types/object' {
190+
import { ArrayLike, TypedArray } from '@stdlib/types/array';
191+
190192
/**
191193
* Interface describing a data property descriptor object.
192194
*
@@ -284,6 +286,14 @@ declare module '@stdlib/types/object' {
284286
* const prop: PropertyName = 'foo';
285287
*/
286288
type PropertyName = string | symbol;
289+
290+
/**
291+
* A collection, which is defined as either an array, typed array, or an array-like object (excluding strings and functions).
292+
*
293+
* @example
294+
* const arr: Collection = [ 1, 2, 3 ];
295+
*/
296+
type Collection = Array<any> | TypedArray | ArrayLike<any>;
287297
}
288298

289299
/**

lib/node_modules/@stdlib/types/test.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,11 @@ function createIterableIterator(): iter.IterableIterator {
282282
if ( prop !== 'foo' ) {
283283
throw new Error( 'something went wrong' );
284284
}
285+
286+
const arr: obj.Collection = [ 1, 2, 3 ];
287+
if ( arr.length !== 3 ) {
288+
throw new Error( 'something went wrong' );
289+
}
285290
}
286291

287292
// The compiler should not throw an error when using PRNG types...

0 commit comments

Comments
 (0)