Skip to content

Commit 3168f9b

Browse files
hongaarMoLow
andauthored
fix: make TestFn generic
Apply suggestions from code review by @MoLow Co-authored-by: Moshe Atlow <[email protected]>
1 parent 77308d5 commit 3168f9b

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

lib/test.d.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ interface TestOptions {
3535
signal?: AbortSignal;
3636
}
3737

38-
type TestFn = (t: TestContext, done: (result?: any) => void) => any;
38+
type TestFn = <T>(t: TestContext, done: (result?: T) => void) => any | <T>(t: TestContext) => Promise<T>;
3939

4040
export default test;
4141

@@ -47,13 +47,13 @@ export default test;
4747
* Default: A no-op function.
4848
* @returns A {@link Promise} resolved with `undefined` once the test completes.
4949
*/
50-
export function test(
50+
export function test<T>(
5151
name: string,
5252
options: TestOptions,
53-
fn: TestFn
53+
fn: TestFn<T>
5454
): Promise<void>;
55-
export function test(name: string, fn: TestFn): Promise<void>;
56-
export function test(options: TestOptions, fn: TestFn): Promise<void>;
55+
export function test<T>(name: string, fn: TestFn<T>): Promise<void>;
56+
export function test<T>(options: TestOptions, fn: TestFn<T>): Promise<void>;
5757
export function test(fn: TestFn): Promise<void>;
5858

5959
type SuiteFn = (t: SuiteContext) => void;

0 commit comments

Comments
 (0)