Skip to content

Commit a90f1be

Browse files
committed
refactor(toCollection): remove explicit generics type
Fix PR review
1 parent 158ef52 commit a90f1be

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

packages/falso/src/lib/collection.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,10 @@ import { FakeOptions, fake } from './core/core';
1818
* }, { length: 10 }) // default is no length.
1919
*
2020
*/
21-
export function toCollection<Collection, Options extends FakeOptions = never>(
21+
export function toCollection<
22+
Collection = never,
23+
Options extends FakeOptions = never
24+
>(
2225
generateCollection: (options?: Options) => Collection,
2326
options?: Options
2427
): Collection | Collection[] {

packages/falso/src/tests/collection.spec.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ describe('randCollection', () => {
2121
const expectedData: fakeData = { data: 1 };
2222
expect(toCollection<fakeData>(() => expectedData)).toEqual(expectedData);
2323
expect(
24-
toCollection<fakeData, { length: number }>(() => expectedData, {
24+
toCollection(() => expectedData, {
2525
length: 1,
2626
})
2727
).toEqual([expectedData]);
@@ -30,7 +30,7 @@ describe('randCollection', () => {
3030
it('should return a collection of 2 elements if length=2 specified', () => {
3131
const expectedData: fakeData = { data: 1 };
3232
expect(
33-
toCollection<fakeData, { length: number }>(() => expectedData, {
33+
toCollection(() => expectedData, {
3434
length: 2,
3535
})
3636
).toEqual([expectedData, expectedData]);
@@ -51,7 +51,7 @@ describe('randCollection', () => {
5151
it('should return a collection of 2 elements that call another function', () => {
5252
const expectedData: fakeData = { data: 1 };
5353
expect(
54-
toCollection<fakeData, { length: number }>(generatorFunction, {
54+
toCollection(generatorFunction, {
5555
length: 2,
5656
})
5757
).toEqual([{ data: 1 }, { data: 1 }]);
@@ -74,7 +74,7 @@ describe('randCollection', () => {
7474
const expectedData: fakeData = { data: 1 };
7575
randNumberSpy.mockReturnValueOnce(1).mockReturnValueOnce(2);
7676
expect(
77-
toCollection<fakeData, { length: number }>(
77+
toCollection(
7878
() => {
7979
return { data: randNumber() };
8080
},

0 commit comments

Comments
 (0)