Skip to content

Commit

Permalink
[types] use a generic
Browse files Browse the repository at this point in the history
  • Loading branch information
ljharb committed Mar 9, 2024
1 parent 3d3da0a commit a1d744d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
4 changes: 2 additions & 2 deletions index.d.ts
@@ -1,3 +1,3 @@
declare function safeArrayConcat(item: unknown | unknown[], ...items: unknown[]): unknown[];
declare function safeArrayConcat<T = unknown>(item: T | T[], ...items: (T | T[])[]): T[];

export = safeArrayConcat;
export = safeArrayConcat;
3 changes: 2 additions & 1 deletion test/index.js
Expand Up @@ -19,7 +19,8 @@ test('safe-array-concat', function (t) {
);

t.deepEqual(
safeConcat([1, 2], [3, 4], 'foo', 5, 6, [[7]]),
// eslint-disable-next-line no-extra-parens
safeConcat(/** @type {(string | number | number[])[]} */ ([1, 2]), [3, 4], 'foo', 5, 6, [[7]]),
[1, 2, 3, 4, 'foo', 5, 6, [7]],
'works with flat and nested arrays'
);
Expand Down

0 comments on commit a1d744d

Please sign in to comment.