Skip to content

Commit 8816faf

Browse files
ChristianMurphysindresorhus
authored andcommitted
support test macros in typescript definitions (#975)
1 parent ea25b20 commit 8816faf

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

types/base.d.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,5 +120,13 @@ export interface ContextualCallbackTestContext extends CallbackTestContext {
120120
context: any;
121121
}
122122

123+
export interface Macro<T> {
124+
(t: T, ...args: any[]): void;
125+
title? (providedTitle: string, ...args: any[]): string;
126+
}
127+
export type Macros<T> = Macro<T> | Macro<T>[];
128+
123129
export function test(name: string, run: ContextualTest): void;
124130
export function test(run: ContextualTest): void;
131+
export function test(name: string, run: Macros<ContextualTestContext>, ...args: any[]): void;
132+
export function test(run: Macros<ContextualTestContext>, ...args: any[]): void;

types/make.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ function generatePrefixed(prefix) {
5353
const type = testType(parts);
5454
output += '\t' + writeFunction(part, 'name: string, implementation: ' + type);
5555
output += '\t' + writeFunction(part, 'implementation: ' + type);
56+
output += '\t' + writeFunction(part, 'name: string, implementation: Macros<' + type + 'Context>, ...args: any[]');
57+
output += '\t' + writeFunction(part, 'implementation: Macros<' + type + 'Context>, ...args: any[]');
5658
}
5759
}
5860

0 commit comments

Comments
 (0)