Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
"node": ">=4"
},
"scripts": {
"test": "xo && flow check test/flow-types && nyc tap --no-cov --timeout=150 --jobs=4 test/*.js test/reporters/*.js",
"test": "xo && flow check test/flow-types && tsc -p test/ts-types && nyc tap --no-cov --timeout=150 --jobs=4 test/*.js test/reporters/*.js",
"test-win": "tap --no-cov --reporter=classic --timeout=150 --jobs=4 test/*.js test/reporters/*.js",
"visual": "node test/visual/run-visual-tests.js",
"prepublish": "npm run make-ts",
Expand Down Expand Up @@ -188,6 +188,7 @@
"tap": "^10.0.0",
"temp-write": "^3.1.0",
"touch": "^1.0.0",
"typescript": "^2.2.2",
"xo": "^0.18.0",
"zen-observable": "^0.5.1"
},
Expand Down
1 change: 1 addition & 0 deletions test/ts-types/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.js
5 changes: 5 additions & 0 deletions test/ts-types/regression-1347.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import test from '../..'

test.cb(t => {
t.end()
})
8 changes: 8 additions & 0 deletions test/ts-types/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"compilerOptions": {
"module": "commonjs",
"target": "es6",
"noImplicitAny": false,
"sourceMap": false
}
}
7 changes: 7 additions & 0 deletions types/base.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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>> {
Expand Down
6 changes: 5 additions & 1 deletion types/make.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down