From a03557364c15e02a52bfdfc186826bb49837a2b4 Mon Sep 17 00:00:00 2001 From: Andrew Bradley Date: Fri, 17 Jan 2020 00:19:53 -0500 Subject: [PATCH] more --- globals.d.ts | 11 ++ index.d.ts | 3 +- lib/runnable.js | 7 +- lib/utils.js | 5 +- package-lock.json | 301 +------------------------------------- package.json | 2 +- test/types/mocha-tests.ts | 2 + test/types/tsconfig.json | 6 +- tsconfig.json | 7 +- 9 files changed, 37 insertions(+), 307 deletions(-) create mode 100644 globals.d.ts diff --git a/globals.d.ts b/globals.d.ts new file mode 100644 index 0000000000..18d747f9b5 --- /dev/null +++ b/globals.d.ts @@ -0,0 +1,11 @@ +import * as Mocha from './'; + +declare global { + const after: typeof Mocha.after; + const afterEach: typeof Mocha.afterEach; + const before: typeof Mocha.after; + const beforeEach: typeof Mocha.beforeEach; + const describe: typeof Mocha.describe; + const it: typeof Mocha.after; + const xit: typeof Mocha.xit; +} diff --git a/index.d.ts b/index.d.ts index 556377e4f3..527a101fcf 100644 --- a/index.d.ts +++ b/index.d.ts @@ -1 +1,2 @@ -export = import('./types/mocha'); +import * as Mocha from './types/mocha'; +export = Mocha; diff --git a/lib/runnable.js b/lib/runnable.js index 2d0c428d46..0ffee5f95f 100644 --- a/lib/runnable.js +++ b/lib/runnable.js @@ -64,7 +64,7 @@ utils.inherits(Runnable, EventEmitter); * * @private * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/setTimeout#Maximum_delay_value} - * @param {number|string} ms - Timeout threshold value. + * @param {number|string} [ms] - Timeout threshold value. * @returns {Runnable} this * @chainable */ @@ -260,13 +260,14 @@ Runnable.prototype.resetTimeout = function() { return; } this.clearTimeout(); - this.timer = setTimeout(function() { + /** @type {number} */ + this.timer = /** @type {any} */ (setTimeout(function() { if (!self._enableTimeouts) { return; } self.callback(self._timeoutError(ms)); self.timedOut = true; - }, ms); + }, ms)); }; /** diff --git a/lib/utils.js b/lib/utils.js index 91856463b9..c93e3584b1 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -29,7 +29,10 @@ var assign = (exports.assign = require('object.assign').getPolyfill()); * @throws {TypeError} if either constructor is null, or if super constructor * lacks a prototype. */ -exports.inherits = util.inherits; +exports.inherits = function(ctor, superCtor) { + // Wrapper prevents type declarations from referring to @types/node + return util.inherits.call(this, ctor, superCtor); +}; /** * Escape special characters in the given string of html. diff --git a/package-lock.json b/package-lock.json index f276bc18bf..641f9a17a5 100644 --- a/package-lock.json +++ b/package-lock.json @@ -416,9 +416,9 @@ } }, "@types/node": { - "version": "13.1.7", - "resolved": "https://registry.npmjs.org/@types/node/-/node-13.1.7.tgz", - "integrity": "sha512-HU0q9GXazqiKwviVxg9SI/+t/nAsGkvLDkIdxz+ObejG2nX6Si00TeLqHMoS+a/1tjH7a8YpKVQwtgHuMQsldg==", + "version": "13.1.8", + "resolved": "https://registry.npmjs.org/@types/node/-/node-13.1.8.tgz", + "integrity": "sha512-6XzyyNM9EKQW4HKuzbo/CkOIjn/evtCmsU+MUM1xDfJ+3/rNjBttM1NgN7AOQvN6tP1Sl1D1PIKMreTArnxM9A==", "dev": true }, "@types/normalize-package-data": { @@ -705,12 +705,6 @@ "integrity": "sha512-/FQM1EDkTsf63Ub2C6O7GuYFDsSXUwsaZDurV0np41ocwq0jthUAYCmhBX9f+KwlaCgIuWyr/4WlUQUBfKfZog==", "dev": true }, - "any-shell-escape": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/any-shell-escape/-/any-shell-escape-0.1.1.tgz", - "integrity": "sha1-1Vq5ciRMcaml4asIefML8RCAaVk=", - "dev": true - }, "anymatch": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-2.0.0.tgz", @@ -3414,106 +3408,6 @@ } } }, - "concurrently": { - "version": "3.6.1", - "resolved": "https://registry.npmjs.org/concurrently/-/concurrently-3.6.1.tgz", - "integrity": "sha512-/+ugz+gwFSEfTGUxn0KHkY+19XPRTXR8+7oUK/HxgiN1n7FjeJmkrbSiXAJfyQ0zORgJYPaenmymwon51YXH9Q==", - "dev": true, - "requires": { - "chalk": "^2.4.1", - "commander": "2.6.0", - "date-fns": "^1.23.0", - "lodash": "^4.5.1", - "read-pkg": "^3.0.0", - "rx": "2.3.24", - "spawn-command": "^0.0.2-1", - "supports-color": "^3.2.3", - "tree-kill": "^1.1.0" - }, - "dependencies": { - "commander": { - "version": "2.6.0", - "resolved": "https://registry.npmjs.org/commander/-/commander-2.6.0.tgz", - "integrity": "sha1-nfflL7Kgyw+4kFjugMMQQiXzfh0=", - "dev": true - }, - "has-flag": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-1.0.0.tgz", - "integrity": "sha1-nZ55MWXOAXoA8AQYxD+UKnsdEfo=", - "dev": true - }, - "load-json-file": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/load-json-file/-/load-json-file-4.0.0.tgz", - "integrity": "sha1-L19Fq5HjMhYjT9U62rZo607AmTs=", - "dev": true, - "requires": { - "graceful-fs": "^4.1.2", - "parse-json": "^4.0.0", - "pify": "^3.0.0", - "strip-bom": "^3.0.0" - } - }, - "parse-json": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/parse-json/-/parse-json-4.0.0.tgz", - "integrity": "sha1-vjX1Qlvh9/bHRxhPmKeIy5lHfuA=", - "dev": true, - "requires": { - "error-ex": "^1.3.1", - "json-parse-better-errors": "^1.0.1" - } - }, - "path-type": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/path-type/-/path-type-3.0.0.tgz", - "integrity": "sha512-T2ZUsdZFHgA3u4e5PfPbjd7HDDpxPnQb5jN0SrDsjNSuVXHJqtwTnWqG0B1jZrgmJ/7lj1EmVIByWt1gxGkWvg==", - "dev": true, - "requires": { - "pify": "^3.0.0" - } - }, - "pify": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/pify/-/pify-3.0.0.tgz", - "integrity": "sha1-5aSs0sEB/fPZpNB/DbxNtJ3SgXY=", - "dev": true - }, - "read-pkg": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/read-pkg/-/read-pkg-3.0.0.tgz", - "integrity": "sha1-nLxoaXj+5l0WwA4rGcI3/Pbjg4k=", - "dev": true, - "requires": { - "load-json-file": "^4.0.0", - "normalize-package-data": "^2.3.2", - "path-type": "^3.0.0" - } - }, - "rx": { - "version": "2.3.24", - "resolved": "https://registry.npmjs.org/rx/-/rx-2.3.24.tgz", - "integrity": "sha1-FPlQpCF9fjXapxu8vljv9o6ksrc=", - "dev": true - }, - "strip-bom": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-3.0.0.tgz", - "integrity": "sha1-IzTBjpx1n3vdVv3vfprj1YjmjtM=", - "dev": true - }, - "supports-color": { - "version": "3.2.3", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-3.2.3.tgz", - "integrity": "sha1-ZawFBLOVQXHYpklGsq48u4pfVPY=", - "dev": true, - "requires": { - "has-flag": "^1.0.0" - } - } - } - }, "condense-newlines": { "version": "0.2.1", "resolved": "https://registry.npmjs.org/condense-newlines/-/condense-newlines-0.2.1.tgz", @@ -3775,83 +3669,6 @@ } } }, - "cpy": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/cpy/-/cpy-4.0.1.tgz", - "integrity": "sha1-tnJn66LzlgugalphrJQDNCKDNCQ=", - "dev": true, - "requires": { - "cp-file": "^3.1.0", - "globby": "^4.0.0", - "meow": "^3.6.0", - "nested-error-stacks": "^1.0.0", - "object-assign": "^4.0.1", - "pinkie-promise": "^2.0.0" - }, - "dependencies": { - "cp-file": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/cp-file/-/cp-file-3.2.0.tgz", - "integrity": "sha1-b4NhYlRiTwrViqSqjQdvAmvn4Yg=", - "dev": true, - "requires": { - "graceful-fs": "^4.1.2", - "mkdirp": "^0.5.0", - "nested-error-stacks": "^1.0.1", - "object-assign": "^4.0.1", - "pify": "^2.3.0", - "pinkie-promise": "^2.0.0", - "readable-stream": "^2.1.4" - } - }, - "glob": { - "version": "6.0.4", - "resolved": "https://registry.npmjs.org/glob/-/glob-6.0.4.tgz", - "integrity": "sha1-DwiGD2oVUSey+t1PnOJLGqtuTSI=", - "dev": true, - "requires": { - "inflight": "^1.0.4", - "inherits": "2", - "minimatch": "2 || 3", - "once": "^1.3.0", - "path-is-absolute": "^1.0.0" - } - }, - "globby": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/globby/-/globby-4.1.0.tgz", - "integrity": "sha1-CA9UVJ7BuCpsYOYx/ILhIR2+lfg=", - "dev": true, - "requires": { - "array-union": "^1.0.1", - "arrify": "^1.0.0", - "glob": "^6.0.1", - "object-assign": "^4.0.1", - "pify": "^2.0.0", - "pinkie-promise": "^2.0.0" - } - }, - "nested-error-stacks": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/nested-error-stacks/-/nested-error-stacks-1.0.2.tgz", - "integrity": "sha1-GfYZWRUZ8JZ2mlupqG5u7sgjw88=", - "dev": true, - "requires": { - "inherits": "~2.0.1" - } - } - } - }, - "cpy-cli": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/cpy-cli/-/cpy-cli-1.0.1.tgz", - "integrity": "sha1-Z/taSi3sKMqKv/N13kuecfanVhw=", - "dev": true, - "requires": { - "cpy": "^4.0.0", - "meow": "^3.6.0" - } - }, "create-ecdh": { "version": "4.0.3", "resolved": "https://registry.npmjs.org/create-ecdh/-/create-ecdh-4.0.3.tgz", @@ -11505,12 +11322,6 @@ "integrity": "sha1-Sr6/7tdUHywnrPspvbvRXI1bpPc=", "dev": true }, - "ncp": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/ncp/-/ncp-2.0.0.tgz", - "integrity": "sha1-GVoh1sRuNh0vsSgbo4uR6d9727M=", - "dev": true - }, "needle": { "version": "2.4.0", "resolved": "https://registry.npmjs.org/needle/-/needle-2.4.0.tgz", @@ -12120,47 +11931,6 @@ } } }, - "nps-utils": { - "version": "1.7.0", - "resolved": "https://registry.npmjs.org/nps-utils/-/nps-utils-1.7.0.tgz", - "integrity": "sha512-wq/gUxTR3sgLYTLHlUKwMG2paUV3QdfwMj5aifWpQ60Vv9RQzA6pXDkwrAlMA8SNqoz8FwaGPc1X/7I+qjuYwg==", - "dev": true, - "requires": { - "any-shell-escape": "^0.1.1", - "common-tags": "^1.4.0", - "concurrently": "^3.4.0", - "cpy-cli": "^1.0.1", - "cross-env": "^3.1.4", - "is-windows": "^1.0.0", - "mkdirp": "^0.5.1", - "ncp": "2.0.0", - "opn-cli": "^3.1.0", - "rimraf": "^2.6.1" - }, - "dependencies": { - "cross-env": { - "version": "3.2.4", - "resolved": "https://registry.npmjs.org/cross-env/-/cross-env-3.2.4.tgz", - "integrity": "sha1-ngWF8neGTtQhznVvgamA/w1piro=", - "dev": true, - "requires": { - "cross-spawn": "^5.1.0", - "is-windows": "^1.0.0" - } - }, - "cross-spawn": { - "version": "5.1.0", - "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-5.1.0.tgz", - "integrity": "sha1-6L0O/uWPz/b4+UUQoKVUu/ojVEk=", - "dev": true, - "requires": { - "lru-cache": "^4.0.1", - "shebang-command": "^1.2.0", - "which": "^1.2.9" - } - } - } - }, "nth-check": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/nth-check/-/nth-check-1.0.2.tgz", @@ -12571,43 +12341,6 @@ "is-wsl": "^1.1.0" } }, - "opn-cli": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/opn-cli/-/opn-cli-3.1.0.tgz", - "integrity": "sha1-+BmubK4LQRvQFJuFYP5siK2tIPg=", - "dev": true, - "requires": { - "file-type": "^3.6.0", - "get-stdin": "^5.0.1", - "meow": "^3.7.0", - "opn": "^4.0.0", - "temp-write": "^2.1.0" - }, - "dependencies": { - "file-type": { - "version": "3.9.0", - "resolved": "https://registry.npmjs.org/file-type/-/file-type-3.9.0.tgz", - "integrity": "sha1-JXoHg4TR24CHvESdEH1SpSZyuek=", - "dev": true - }, - "get-stdin": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/get-stdin/-/get-stdin-5.0.1.tgz", - "integrity": "sha1-Ei4WFZHiH/TFJTAwVpPyDmOTo5g=", - "dev": true - }, - "opn": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/opn/-/opn-4.0.2.tgz", - "integrity": "sha1-erwi5kTf9jsKltWrfyeQwPAavJU=", - "dev": true, - "requires": { - "object-assign": "^4.0.1", - "pinkie-promise": "^2.0.0" - } - } - } - }, "optimist": { "version": "0.6.1", "resolved": "https://registry.npmjs.org/optimist/-/optimist-0.6.1.tgz", @@ -16960,28 +16693,6 @@ "integrity": "sha1-CnwOom06Oa+n4OvqnB/AvE2qAR0=", "dev": true }, - "temp-write": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/temp-write/-/temp-write-2.1.0.tgz", - "integrity": "sha1-WYkJGODvCdVIqqNC9L00CdhATpY=", - "dev": true, - "requires": { - "graceful-fs": "^4.1.2", - "mkdirp": "^0.5.0", - "os-tmpdir": "^1.0.0", - "pify": "^2.2.0", - "pinkie-promise": "^2.0.0", - "uuid": "^2.0.1" - }, - "dependencies": { - "uuid": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/uuid/-/uuid-2.0.3.tgz", - "integrity": "sha1-Z+LoY3lyFVMN/zGOW/nc6/1Hsho=", - "dev": true - } - } - }, "tempfile": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/tempfile/-/tempfile-2.0.0.tgz", @@ -17446,12 +17157,6 @@ "integrity": "sha1-YdvC1Ttp/2CRoSoWj9fUMxB+QPE=", "dev": true }, - "tree-kill": { - "version": "1.2.2", - "resolved": "https://registry.npmjs.org/tree-kill/-/tree-kill-1.2.2.tgz", - "integrity": "sha512-L0Orpi8qGpRG//Nd+H90vFB+3iHnue1zSSGmNOOCh1GLJ7rUKVwV2HvijphGQS2UmhUZewS9VgvxYIdgr+fG1A==", - "dev": true - }, "trim": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/trim/-/trim-0.0.1.tgz", diff --git a/package.json b/package.json index 117f54a3c4..5ecda6f4a7 100644 --- a/package.json +++ b/package.json @@ -565,7 +565,7 @@ "@11ty/eleventy": "^0.8.3", "@mocha/contributors": "^1.0.4", "@mocha/docdash": "^2.1.2", - "@types/node": "^13.1.7", + "@types/node": "^13.1.8", "@types/yargs": "^15.0.0", "acorn": "^7.0.0", "assetgraph-builder": "^6.10.1", diff --git a/test/types/mocha-tests.ts b/test/types/mocha-tests.ts index b21abb9ffd..5cf209c16d 100644 --- a/test/types/mocha-tests.ts +++ b/test/types/mocha-tests.ts @@ -1,3 +1,5 @@ +/// + import { after as importedAfter, before as importedBefore, diff --git a/test/types/tsconfig.json b/test/types/tsconfig.json index 5de3cfada1..474fc7ccab 100644 --- a/test/types/tsconfig.json +++ b/test/types/tsconfig.json @@ -1,5 +1,9 @@ { "compilerOptions": { - "noEmit": true + "noEmit": true, + "experimentalDecorators": true, + "types": [], + "target": "ES2015", + "module": "CommonJS" } } diff --git a/tsconfig.json b/tsconfig.json index 63dc5da533..09b5083e0a 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,5 +1,5 @@ { - "include": ["src"], + "include": ["lib"], "compilerOptions": { "rootDir": "lib", "declarationDir": "types", @@ -9,6 +9,9 @@ "emitDeclarationOnly": true, "sourceMap": true, "declarationMap": true, - "newLine": "lf" + "newLine": "lf", + + "target": "ES2015", + "types": ["node"] } }