Skip to content

Commit 4b9e1dc

Browse files
committed
Add experimental make() and fork() types
1 parent 11e7829 commit 4b9e1dc

File tree

2 files changed

+30
-1
lines changed

2 files changed

+30
-1
lines changed

experimental.d.ts

+17-1
Original file line numberDiff line numberDiff line change
@@ -307,8 +307,24 @@ export interface TodoDeclaration {
307307
(title: string): void;
308308
}
309309

310+
export interface ForkableSerialInterface<Context = unknown> extends SerialInterface<Context> {
311+
/** Create a new serial() function with its own hooks. */
312+
fork(): ForkableSerialInterface<Context>;
313+
}
314+
315+
export interface ForkableTestInterface<Context = unknown> extends TestInterface<Context> {
316+
/** Create a new test() function with its own hooks. */
317+
fork(): ForkableTestInterface<Context>;
318+
319+
/** Declare tests and hooks that are run serially. */
320+
serial: ForkableSerialInterface<Context>;
321+
}
322+
310323
/** Call to declare a test, or chain to declare hooks or test modifiers */
311-
declare const test: TestInterface;
324+
declare const test: TestInterface & {
325+
/** Create a new test() function with its own hooks. */
326+
make(): ForkableTestInterface;
327+
};
312328

313329
/** Call to declare a test, or chain to declare hooks or test modifiers */
314330
export default test;

test-d/experimental-forkable.ts

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import {expectType} from 'tsd';
2+
import test, {ForkableTestInterface, ForkableSerialInterface} from '../experimental';
3+
4+
const foo = test.make();
5+
expectType<ForkableTestInterface>(foo);
6+
7+
const bar = foo.fork();
8+
expectType<ForkableTestInterface>(bar);
9+
10+
const baz = foo.serial.fork();
11+
expectType<ForkableSerialInterface>(baz);
12+
const thud = baz.fork();
13+
expectType<ForkableSerialInterface>(thud);

0 commit comments

Comments
 (0)