diff --git a/CHANGELOG.md b/CHANGELOG.md index 2e88fb52389d..5e632c6e6ac3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ ### Chore & Maintenance +- `[*]` Add missing dependency on `@types/node` ([#10248](https://github.com/facebook/jest/pull/10248)) - `[jest-jasmine2]` Convert `PCancelable` to TypeScript ([#10215](https://github.com/facebook/jest/pull/10215)) - `[jest-jasmine2]` Refine typings of `queueRunner` ([#10215](https://github.com/facebook/jest/pull/10215)) - `[jest-jasmine2]` Remove usage of `Function` type ([#10216](https://github.com/facebook/jest/pull/10216)) diff --git a/packages/jest-circus/package.json b/packages/jest-circus/package.json index a99bb128c5e1..5c618968dd2f 100644 --- a/packages/jest-circus/package.json +++ b/packages/jest-circus/package.json @@ -14,6 +14,7 @@ "@jest/environment": "^26.1.0", "@jest/test-result": "^26.1.0", "@jest/types": "^26.1.0", + "@types/node": "*", "chalk": "^4.0.0", "co": "^4.6.0", "dedent": "^0.7.0", diff --git a/packages/jest-console/package.json b/packages/jest-console/package.json index 493ea4921278..44e45f7350d8 100644 --- a/packages/jest-console/package.json +++ b/packages/jest-console/package.json @@ -11,6 +11,7 @@ "types": "build/index.d.ts", "dependencies": { "@jest/types": "^26.1.0", + "@types/node": "*", "chalk": "^4.0.0", "jest-message-util": "^26.1.0", "jest-util": "^26.1.0", diff --git a/packages/jest-core/package.json b/packages/jest-core/package.json index 2cf64377f5af..862d3c54995a 100644 --- a/packages/jest-core/package.json +++ b/packages/jest-core/package.json @@ -10,6 +10,7 @@ "@jest/test-result": "^26.1.0", "@jest/transform": "^26.1.0", "@jest/types": "^26.1.0", + "@types/node": "*", "ansi-escapes": "^4.2.1", "chalk": "^4.0.0", "exit": "^0.1.2", @@ -38,7 +39,6 @@ "@types/exit": "^0.1.30", "@types/graceful-fs": "^4.1.2", "@types/micromatch": "^4.0.0", - "@types/node": "*", "@types/rimraf": "^3.0.0", "jest-snapshot-serializer-raw": "^1.1.0" }, diff --git a/packages/jest-environment-jsdom/package.json b/packages/jest-environment-jsdom/package.json index e21bd19afec1..307e03616c36 100644 --- a/packages/jest-environment-jsdom/package.json +++ b/packages/jest-environment-jsdom/package.json @@ -13,6 +13,7 @@ "@jest/environment": "^26.1.0", "@jest/fake-timers": "^26.1.0", "@jest/types": "^26.1.0", + "@types/node": "*", "jest-mock": "^26.1.0", "jest-util": "^26.1.0", "jsdom": "^16.2.2" diff --git a/packages/jest-environment-node/package.json b/packages/jest-environment-node/package.json index 4406f44fe3c0..6e822bec8151 100644 --- a/packages/jest-environment-node/package.json +++ b/packages/jest-environment-node/package.json @@ -13,6 +13,7 @@ "@jest/environment": "^26.1.0", "@jest/fake-timers": "^26.1.0", "@jest/types": "^26.1.0", + "@types/node": "*", "jest-mock": "^26.1.0", "jest-util": "^26.1.0" }, diff --git a/packages/jest-environment/package.json b/packages/jest-environment/package.json index 8a9d04b316ab..8d0d94817c0e 100644 --- a/packages/jest-environment/package.json +++ b/packages/jest-environment/package.json @@ -12,11 +12,9 @@ "dependencies": { "@jest/fake-timers": "^26.1.0", "@jest/types": "^26.1.0", + "@types/node": "*", "jest-mock": "^26.1.0" }, - "devDependencies": { - "@types/node": "*" - }, "engines": { "node": ">= 10.14.2" }, diff --git a/packages/jest-fake-timers/package.json b/packages/jest-fake-timers/package.json index 8f62d5f004a7..05cfaa797abc 100644 --- a/packages/jest-fake-timers/package.json +++ b/packages/jest-fake-timers/package.json @@ -12,12 +12,12 @@ "dependencies": { "@jest/types": "^26.1.0", "@sinonjs/fake-timers": "^6.0.1", + "@types/node": "*", "jest-message-util": "^26.1.0", "jest-mock": "^26.1.0", "jest-util": "^26.1.0" }, "devDependencies": { - "@types/node": "*", "@types/sinonjs__fake-timers": "^6.0.1" }, "engines": { diff --git a/packages/jest-globals/tsconfig.json b/packages/jest-globals/tsconfig.json index b6678e5f0aed..f6060ca2e675 100644 --- a/packages/jest-globals/tsconfig.json +++ b/packages/jest-globals/tsconfig.json @@ -2,7 +2,7 @@ "extends": "../../tsconfig.json", "compilerOptions": { // we don't want `@types/jest` to be referenced - "types": ["node"], + "types": [], "rootDir": "src", "outDir": "build" }, diff --git a/packages/jest-haste-map/package.json b/packages/jest-haste-map/package.json index adaae2e44f74..76e34ab3ea23 100644 --- a/packages/jest-haste-map/package.json +++ b/packages/jest-haste-map/package.json @@ -12,6 +12,7 @@ "dependencies": { "@jest/types": "^26.1.0", "@types/graceful-fs": "^4.1.2", + "@types/node": "*", "anymatch": "^3.0.3", "fb-watchman": "^2.0.0", "graceful-fs": "^4.2.4", @@ -28,7 +29,6 @@ "@types/anymatch": "^1.3.1", "@types/fb-watchman": "^2.0.0", "@types/micromatch": "^4.0.0", - "@types/node": "*", "@types/sane": "^2.0.0", "@types/which": "^1.3.2" }, diff --git a/packages/jest-jasmine2/package.json b/packages/jest-jasmine2/package.json index c9e52fb7490b..6c956b36079a 100644 --- a/packages/jest-jasmine2/package.json +++ b/packages/jest-jasmine2/package.json @@ -15,6 +15,7 @@ "@jest/source-map": "^26.1.0", "@jest/test-result": "^26.1.0", "@jest/types": "^26.1.0", + "@types/node": "*", "chalk": "^4.0.0", "co": "^4.6.0", "expect": "^26.1.0", diff --git a/packages/jest-mock/package.json b/packages/jest-mock/package.json index 49884eb6e748..915678cedf8e 100644 --- a/packages/jest-mock/package.json +++ b/packages/jest-mock/package.json @@ -10,9 +10,7 @@ "node": ">= 10.14.2" }, "dependencies": { - "@jest/types": "^26.1.0" - }, - "devDependencies": { + "@jest/types": "^26.1.0", "@types/node": "*" }, "license": "MIT", diff --git a/packages/jest-runner/package.json b/packages/jest-runner/package.json index 7865fcb759e6..9a1b9cf755dc 100644 --- a/packages/jest-runner/package.json +++ b/packages/jest-runner/package.json @@ -14,6 +14,7 @@ "@jest/environment": "^26.1.0", "@jest/test-result": "^26.1.0", "@jest/types": "^26.1.0", + "@types/node": "*", "chalk": "^4.0.0", "exit": "^0.1.2", "graceful-fs": "^4.2.4", @@ -33,7 +34,6 @@ "devDependencies": { "@types/exit": "^0.1.30", "@types/graceful-fs": "^4.1.2", - "@types/node": "*", "@types/source-map-support": "^0.5.0", "jest-circus": "^26.1.0" }, diff --git a/packages/jest-serializer/package.json b/packages/jest-serializer/package.json index 8d7bd50f1493..ee85d32d0813 100644 --- a/packages/jest-serializer/package.json +++ b/packages/jest-serializer/package.json @@ -7,10 +7,10 @@ "directory": "packages/jest-serializer" }, "devDependencies": { - "@types/graceful-fs": "^4.1.3", - "@types/node": "*" + "@types/graceful-fs": "^4.1.3" }, "dependencies": { + "@types/node": "*", "graceful-fs": "^4.2.4" }, "engines": { diff --git a/packages/jest-types/package.json b/packages/jest-types/package.json index 3c568f119ae4..c58a4b38c392 100644 --- a/packages/jest-types/package.json +++ b/packages/jest-types/package.json @@ -15,12 +15,10 @@ "dependencies": { "@types/istanbul-lib-coverage": "^2.0.0", "@types/istanbul-reports": "^1.1.1", + "@types/node": "*", "@types/yargs": "^15.0.0", "chalk": "^4.0.0" }, - "devDependencies": { - "@types/node": "*" - }, "publishConfig": { "access": "public" }, diff --git a/packages/jest-util/package.json b/packages/jest-util/package.json index 342587f6bbf2..0d4254e9e6ce 100644 --- a/packages/jest-util/package.json +++ b/packages/jest-util/package.json @@ -11,6 +11,7 @@ "types": "build/index.d.ts", "dependencies": { "@jest/types": "^26.1.0", + "@types/node": "*", "chalk": "^4.0.0", "graceful-fs": "^4.2.4", "is-ci": "^2.0.0", @@ -19,8 +20,7 @@ "devDependencies": { "@types/graceful-fs": "^4.1.2", "@types/is-ci": "^2.0.0", - "@types/micromatch": "^4.0.0", - "@types/node": "*" + "@types/micromatch": "^4.0.0" }, "engines": { "node": ">= 10.14.2" diff --git a/packages/jest-watcher/package.json b/packages/jest-watcher/package.json index d1c10ea44a57..e1625cb7fc1a 100644 --- a/packages/jest-watcher/package.json +++ b/packages/jest-watcher/package.json @@ -7,14 +7,12 @@ "dependencies": { "@jest/test-result": "^26.1.0", "@jest/types": "^26.1.0", + "@types/node": "*", "ansi-escapes": "^4.2.1", "chalk": "^4.0.0", "jest-util": "^26.1.0", "string-length": "^4.0.1" }, - "devDependencies": { - "@types/node": "*" - }, "repository": { "type": "git", "url": "https://github.com/facebook/jest", diff --git a/packages/jest-worker/package.json b/packages/jest-worker/package.json index a0b890832260..04d9f3c2abd7 100644 --- a/packages/jest-worker/package.json +++ b/packages/jest-worker/package.json @@ -10,12 +10,12 @@ "main": "build/index.js", "types": "build/index.d.ts", "dependencies": { + "@types/node": "*", "merge-stream": "^2.0.0", "supports-color": "^7.0.0" }, "devDependencies": { "@types/merge-stream": "^1.1.2", - "@types/node": "*", "@types/supports-color": "^5.3.0", "get-stream": "^5.1.0", "worker-farm": "^1.6.0" diff --git a/scripts/buildTs.js b/scripts/buildTs.js index d843a9813514..319da312e20e 100644 --- a/scripts/buildTs.js +++ b/scripts/buildTs.js @@ -32,7 +32,7 @@ packagesWithTs.forEach(pkgDir => { assert.ok(pkg.types, `Package ${pkg.name} is missing \`types\` field`); - assert.equal( + assert.strictEqual( pkg.types, pkg.main.replace(/\.js$/, '.d.ts'), `\`main\` and \`types\` field of ${pkg.name} does not match`, @@ -72,8 +72,11 @@ Promise.all( globbed.map(file => Promise.all([file, readFilePromise(file, 'utf8')])), ); - const filesWithReferences = files + const filesWithTypeReferences = files .filter(([, content]) => content.includes('/// hit.length > 0); + + const filesWithReferences = filesWithTypeReferences .map(([name, content]) => [ name, content @@ -98,6 +101,24 @@ Promise.all( process.exit(1); } + + const filesWithNodeReference = filesWithTypeReferences.map( + ([filename]) => filename, + ); + + if (filesWithNodeReference.length > 0) { + const pkg = require(pkgDir + '/package.json'); + + assert.ok( + pkg.dependencies, + `Package \`${pkg.name}\` is missing \`dependencies\``, + ); + assert.strictEqual( + pkg.dependencies['@types/node'], + '*', + `Package \`${pkg.name}\` is missing a dependency on \`@types/node\``, + ); + } }), ), ).catch(e => { diff --git a/yarn.lock b/yarn.lock index 9a626e75e49c..5f375494bdc6 100644 --- a/yarn.lock +++ b/yarn.lock @@ -11036,6 +11036,7 @@ fsevents@^1.2.7: "@types/co": ^4.6.0 "@types/dedent": ^0.7.0 "@types/graceful-fs": ^4.1.3 + "@types/node": "*" "@types/stack-utils": ^1.0.1 chalk: ^4.0.0 co: ^4.6.0 @@ -11155,6 +11156,7 @@ fsevents@^1.2.7: "@jest/fake-timers": ^26.1.0 "@jest/types": ^26.1.0 "@types/jsdom": ^16.2.1 + "@types/node": "*" jest-mock: ^26.1.0 jest-util: ^26.1.0 jsdom: ^16.2.2 @@ -11168,6 +11170,7 @@ fsevents@^1.2.7: "@jest/environment": ^26.1.0 "@jest/fake-timers": ^26.1.0 "@jest/types": ^26.1.0 + "@types/node": "*" jest-mock: ^26.1.0 jest-util: ^26.1.0 languageName: unknown @@ -11250,6 +11253,7 @@ fsevents@^1.2.7: "@jest/types": ^26.1.0 "@types/babel__traverse": ^7.0.4 "@types/co": ^4.6.2 + "@types/node": "*" chalk: ^4.0.0 co: ^4.6.0 expect: ^26.1.0