aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--packages/bun-types/bun-test.d.ts27
-rw-r--r--packages/bun-types/tests/test.test-d.ts17
2 files changed, 38 insertions, 6 deletions
diff --git a/packages/bun-types/bun-test.d.ts b/packages/bun-types/bun-test.d.ts
index 6c22ad62f..a78c74b85 100644
--- a/packages/bun-types/bun-test.d.ts
+++ b/packages/bun-types/bun-test.d.ts
@@ -174,11 +174,12 @@ declare module "bun:test" {
*
* @param table Array of Arrays with the arguments that are passed into the test fn for each row.
*/
- each<T extends Readonly<Readonly<[any, ...any[]]>[]>>(
- table: T,
+
+ each<T extends Readonly<[any, ...any[]]>>(
+ table: ReadonlyArray<T>,
): (
label: string,
- fn: (...args: Readonly<T>[number]) => void | Promise<unknown>,
+ fn: (...args: [...T]) => void | Promise<unknown>,
options?: number | TestOptions,
) => void;
each<T extends Array<any>>(
@@ -188,6 +189,13 @@ declare module "bun:test" {
fn: (...args: Readonly<T>) => void | Promise<unknown>,
options?: number | TestOptions,
) => void;
+ each<T>(
+ table: Array<T>,
+ ): (
+ label: string,
+ fn: (...args: T[]) => void | Promise<unknown>,
+ options?: number | TestOptions,
+ ) => void;
};
/**
* Describes a group of related tests.
@@ -419,11 +427,11 @@ declare module "bun:test" {
*
* @param table Array of Arrays with the arguments that are passed into the test fn for each row.
*/
- each<T extends Readonly<Readonly<[any, ...any[]]>[]>>(
- table: T,
+ each<T extends Readonly<[any, ...any[]]>>(
+ table: ReadonlyArray<T>,
): (
label: string,
- fn: (...args: Readonly<T>[number]) => void | Promise<unknown>,
+ fn: (...args: [...T]) => void | Promise<unknown>,
options?: number | TestOptions,
) => void;
each<T extends Array<any>>(
@@ -433,6 +441,13 @@ declare module "bun:test" {
fn: (...args: Readonly<T>) => void | Promise<unknown>,
options?: number | TestOptions,
) => void;
+ each<T>(
+ table: Array<T>,
+ ): (
+ label: string,
+ fn: (...args: T[]) => void | Promise<unknown>,
+ options?: number | TestOptions,
+ ) => void;
};
/**
* Runs a test.
diff --git a/packages/bun-types/tests/test.test-d.ts b/packages/bun-types/tests/test.test-d.ts
index 1e67590b2..4aed19fb0 100644
--- a/packages/bun-types/tests/test.test-d.ts
+++ b/packages/bun-types/tests/test.test-d.ts
@@ -75,12 +75,24 @@ test.each([
});
describe.each([
["a", true, 5],
+ ["b", false, 5],
+])("test.each", (a, b, c) => {
+ expectType<string>(a);
+ expectType<boolean>(b);
+ expectType<number | string>(c);
+});
+describe.each([
+ ["a", true, 5],
["b", false, "asdf"],
])("test.each", (a, b, c) => {
expectType<string>(a);
expectType<boolean>(b);
expectType<number | string>(c);
});
+describe.each([{ asdf: "asdf" }, { asdf: "asdf" }])("test.each", (a, b, c) => {
+ expectType<{ asdf: string }>(a);
+ expectType<{ asdf: string }>(c);
+});
// no inference on data
const data = [
@@ -112,3 +124,8 @@ describe.each(dataAsConst)("test.each", (...args) => {
expectType<boolean>(args[1]);
expectType<string | number>(args[2]);
});
+describe.each(dataAsConst)("test.each", (a, b, c) => {
+ expectType<"a" | "b">(a);
+ expectType<boolean>(b);
+ expectType<5 | "asdf">(c);
+});