Permalink
Browse files

Fix TypeScript definition for callback tests

Fixes #1347
  • Loading branch information...
novemberborn committed Apr 6, 2017
1 parent 6224f31 commit bd81ef4a995edcf37f8f2199ac8b83c1463e3a4a
Showing with 17 additions and 1 deletion.
  1. +5 −0 test/ts-types/regression-1347.ts
  2. +7 −0 types/base.d.ts
  3. +5 −1 types/make.js
@@ -0,0 +1,5 @@
+import test from '../..'
+
+test.cb(t => {
+ t.end()
+})
View
@@ -119,6 +119,13 @@ interface RegisterBase<T> {
(run: Macros<GenericTestContext<T>>, ...args: any[]): void;
}
+interface CallbackRegisterBase<T> {
+ (name: string, run: GenericCallbackTest<T>): void;
+ (run: GenericCallbackTest<T>): void;
+ (name: string, run: Macros<GenericCallbackTestContext<T>>, ...args: any[]): void;
+ (run: Macros<GenericCallbackTestContext<T>>, ...args: any[]): void;
+}
+
export default test;
export const test: RegisterContextual<any>;
export interface RegisterContextual<T> extends Register<Context<T>> {
View
@@ -74,7 +74,11 @@ function generatePrefixed(prefix) {
// 'todo' functions don't have a function argument, just a string
output += `\t${part}: (name: string) => void;\n`;
} else {
- output += `\t${part}: RegisterBase<T>`;
+ if (arrayHas(parts)('cb')) {
+ output += `\t${part}: CallbackRegisterBase<T>`;
+ } else {
+ output += `\t${part}: RegisterBase<T>`;
+ }
if (hasChildren(parts)) {
// This chain can be continued, make the property an intersection type with the chain continuation

0 comments on commit bd81ef4

Please sign in to comment.