diff --git a/package.json b/package.json index 3b771f2ea..6cd97b092 100644 --- a/package.json +++ b/package.json @@ -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", @@ -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" }, diff --git a/test/ts-types/.gitignore b/test/ts-types/.gitignore new file mode 100644 index 000000000..a6c7c2852 --- /dev/null +++ b/test/ts-types/.gitignore @@ -0,0 +1 @@ +*.js diff --git a/test/ts-types/regression-1347.ts b/test/ts-types/regression-1347.ts new file mode 100644 index 000000000..4a864bbe6 --- /dev/null +++ b/test/ts-types/regression-1347.ts @@ -0,0 +1,5 @@ +import test from '../..' + +test.cb(t => { + t.end() +}) diff --git a/test/ts-types/tsconfig.json b/test/ts-types/tsconfig.json new file mode 100644 index 000000000..600a425b7 --- /dev/null +++ b/test/ts-types/tsconfig.json @@ -0,0 +1,8 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es6", + "noImplicitAny": false, + "sourceMap": false + } +} diff --git a/types/base.d.ts b/types/base.d.ts index c4faed073..b23afa0af 100644 --- a/types/base.d.ts +++ b/types/base.d.ts @@ -119,6 +119,13 @@ interface RegisterBase { (run: Macros>, ...args: any[]): void; } +interface CallbackRegisterBase { + (name: string, run: GenericCallbackTest): void; + (run: GenericCallbackTest): void; + (name: string, run: Macros>, ...args: any[]): void; + (run: Macros>, ...args: any[]): void; +} + export default test; export const test: RegisterContextual; export interface RegisterContextual extends Register> { diff --git a/types/make.js b/types/make.js index 46990fa88..9516fbb61 100644 --- a/types/make.js +++ b/types/make.js @@ -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`; + if (arrayHas(parts)('cb')) { + output += `\t${part}: CallbackRegisterBase`; + } else { + output += `\t${part}: RegisterBase`; + } if (hasChildren(parts)) { // This chain can be continued, make the property an intersection type with the chain continuation