Skip to content

Commit bd81ef4

Browse files
committed
Fix TypeScript definition for callback tests
Fixes #1347
1 parent 6224f31 commit bd81ef4

File tree

3 files changed

+17
-1
lines changed

3 files changed

+17
-1
lines changed

test/ts-types/regression-1347.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import test from '../..'
2+
3+
test.cb(t => {
4+
t.end()
5+
})

types/base.d.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,13 @@ interface RegisterBase<T> {
119119
(run: Macros<GenericTestContext<T>>, ...args: any[]): void;
120120
}
121121

122+
interface CallbackRegisterBase<T> {
123+
(name: string, run: GenericCallbackTest<T>): void;
124+
(run: GenericCallbackTest<T>): void;
125+
(name: string, run: Macros<GenericCallbackTestContext<T>>, ...args: any[]): void;
126+
(run: Macros<GenericCallbackTestContext<T>>, ...args: any[]): void;
127+
}
128+
122129
export default test;
123130
export const test: RegisterContextual<any>;
124131
export interface RegisterContextual<T> extends Register<Context<T>> {

types/make.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,11 @@ function generatePrefixed(prefix) {
7474
// 'todo' functions don't have a function argument, just a string
7575
output += `\t${part}: (name: string) => void;\n`;
7676
} else {
77-
output += `\t${part}: RegisterBase<T>`;
77+
if (arrayHas(parts)('cb')) {
78+
output += `\t${part}: CallbackRegisterBase<T>`;
79+
} else {
80+
output += `\t${part}: RegisterBase<T>`;
81+
}
7882

7983
if (hasChildren(parts)) {
8084
// This chain can be continued, make the property an intersection type with the chain continuation

0 commit comments

Comments
 (0)