From d4057ce23bcc3ed9ac83bab9d7dd7a2339bfaa8a Mon Sep 17 00:00:00 2001 From: Simen Bekkhus Date: Thu, 26 Mar 2020 09:55:58 +0100 Subject: [PATCH] fix: downlevel .d.ts files for compat with older TS versions (#9705) --- CHANGELOG.md | 2 + package.json | 2 + packages/babel-jest/package.json | 7 +++ packages/babel-plugin-jest-hoist/package.json | 7 +++ packages/diff-sequences/package.json | 7 +++ packages/expect/package.json | 7 +++ packages/jest-changed-files/package.json | 7 +++ packages/jest-circus/package.json | 7 +++ packages/jest-cli/package.json | 7 +++ packages/jest-config/package.json | 7 +++ packages/jest-console/package.json | 7 +++ packages/jest-diff/package.json | 7 +++ packages/jest-each/package.json | 7 +++ packages/jest-environment-jsdom/package.json | 7 +++ packages/jest-environment-node/package.json | 7 +++ packages/jest-environment/package.json | 7 +++ packages/jest-fake-timers/package.json | 7 +++ packages/jest-get-type/package.json | 7 +++ packages/jest-haste-map/package.json | 7 +++ packages/jest-jasmine2/package.json | 7 +++ packages/jest-leak-detector/package.json | 7 +++ packages/jest-matcher-utils/package.json | 7 +++ packages/jest-message-util/package.json | 7 +++ packages/jest-mock/package.json | 7 +++ packages/jest-regex-util/package.json | 7 +++ packages/jest-repl/package.json | 7 +++ packages/jest-reporters/package.json | 7 +++ .../jest-resolve-dependencies/package.json | 7 +++ packages/jest-resolve/package.json | 7 +++ packages/jest-runner/package.json | 7 +++ packages/jest-runtime/package.json | 8 +++- packages/jest-serializer/package.json | 7 +++ packages/jest-snapshot/package.json | 7 +++ packages/jest-source-map/package.json | 7 +++ packages/jest-test-result/package.json | 7 +++ packages/jest-test-sequencer/package.json | 7 +++ packages/jest-types/package.json | 7 +++ packages/jest-util/package.json | 7 +++ packages/jest-validate/package.json | 7 +++ packages/jest-worker/package.json | 7 +++ packages/pretty-format/package.json | 7 +++ packages/test-utils/package.json | 7 +++ scripts/buildTs.js | 43 ++++++++++++++++++- yarn.lock | 10 ++++- 44 files changed, 335 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3336b6913604..23311390fd24 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,8 @@ ### Fixes +- `[*]` Downlevel TypeScript definitions files for compatibility with TS<3.8 ([#9705](https://github.com/facebook/jest/pull/9705)) + ### Chore & Maintenance ### Performance diff --git a/package.json b/package.json index 5e154e8f8553..65abe2a0aa1e 100644 --- a/package.json +++ b/package.json @@ -32,6 +32,7 @@ "codecov": "^3.0.0", "debug": "^4.0.1", "dedent": "^0.7.0", + "downlevel-dts": "^0.4.0", "eslint": "^6.2.2", "eslint-config-prettier": "^6.1.0", "eslint-plugin-babel": "^5.1.0", @@ -76,6 +77,7 @@ "slash": "^3.0.0", "string-length": "^3.1.0", "strip-ansi": "^6.0.0", + "throat": "^5.0.0", "typescript": "^3.8.2", "webpack": "^4.28.4", "which": "^2.0.1" diff --git a/packages/babel-jest/package.json b/packages/babel-jest/package.json index b80ab144986e..f1e1bd370ceb 100644 --- a/packages/babel-jest/package.json +++ b/packages/babel-jest/package.json @@ -10,6 +10,13 @@ "license": "MIT", "main": "build/index.js", "types": "build/index.d.ts", + "typesVersions": { + "<3.8": { + "build/*": [ + "build/ts3.4/*" + ] + } + }, "dependencies": { "@jest/transform": "^25.2.0", "@jest/types": "^25.2.0", diff --git a/packages/babel-plugin-jest-hoist/package.json b/packages/babel-plugin-jest-hoist/package.json index 7f4e45e659c5..1b122c4a5e9e 100644 --- a/packages/babel-plugin-jest-hoist/package.json +++ b/packages/babel-plugin-jest-hoist/package.json @@ -12,6 +12,13 @@ "license": "MIT", "main": "build/index.js", "types": "build/index.d.ts", + "typesVersions": { + "<3.8": { + "build/*": [ + "build/ts3.4/*" + ] + } + }, "dependencies": { "@types/babel__traverse": "^7.0.6" }, diff --git a/packages/diff-sequences/package.json b/packages/diff-sequences/package.json index 1dbf39d6b170..a0061888a85d 100644 --- a/packages/diff-sequences/package.json +++ b/packages/diff-sequences/package.json @@ -20,6 +20,13 @@ }, "main": "build/index.js", "types": "build/index.d.ts", + "typesVersions": { + "<3.8": { + "build/*": [ + "build/ts3.4/*" + ] + } + }, "scripts": { "perf": "node --expose-gc perf/index.js" }, diff --git a/packages/expect/package.json b/packages/expect/package.json index 6fb6d71b2050..3864650d02f8 100644 --- a/packages/expect/package.json +++ b/packages/expect/package.json @@ -9,6 +9,13 @@ "license": "MIT", "main": "build/index.js", "types": "build/index.d.ts", + "typesVersions": { + "<3.8": { + "build/*": [ + "build/ts3.4/*" + ] + } + }, "browser": "build-es5/index.js", "dependencies": { "@jest/types": "^25.2.0", diff --git a/packages/jest-changed-files/package.json b/packages/jest-changed-files/package.json index 65c60b6ebb8a..c45379dd4733 100644 --- a/packages/jest-changed-files/package.json +++ b/packages/jest-changed-files/package.json @@ -9,6 +9,13 @@ "license": "MIT", "main": "build/index.js", "types": "build/index.d.ts", + "typesVersions": { + "<3.8": { + "build/*": [ + "build/ts3.4/*" + ] + } + }, "dependencies": { "@jest/types": "^25.2.0", "execa": "^3.2.0", diff --git a/packages/jest-circus/package.json b/packages/jest-circus/package.json index 1e52802a2de9..d5d9c984769b 100644 --- a/packages/jest-circus/package.json +++ b/packages/jest-circus/package.json @@ -9,6 +9,13 @@ "license": "MIT", "main": "build/index.js", "types": "build/index.d.ts", + "typesVersions": { + "<3.8": { + "build/*": [ + "build/ts3.4/*" + ] + } + }, "dependencies": { "@babel/traverse": "^7.1.0", "@jest/environment": "^25.2.0", diff --git a/packages/jest-cli/package.json b/packages/jest-cli/package.json index 14b3ead5b9f7..8bd07bc997b9 100644 --- a/packages/jest-cli/package.json +++ b/packages/jest-cli/package.json @@ -4,6 +4,13 @@ "version": "25.2.0", "main": "build/index.js", "types": "build/index.d.ts", + "typesVersions": { + "<3.8": { + "build/*": [ + "build/ts3.4/*" + ] + } + }, "dependencies": { "@jest/core": "^25.2.0", "@jest/test-result": "^25.2.0", diff --git a/packages/jest-config/package.json b/packages/jest-config/package.json index 712727e052b5..b450c0fee015 100644 --- a/packages/jest-config/package.json +++ b/packages/jest-config/package.json @@ -9,6 +9,13 @@ "license": "MIT", "main": "build/index.js", "types": "build/index.d.ts", + "typesVersions": { + "<3.8": { + "build/*": [ + "build/ts3.4/*" + ] + } + }, "dependencies": { "@babel/core": "^7.1.0", "@jest/test-sequencer": "^25.2.0", diff --git a/packages/jest-console/package.json b/packages/jest-console/package.json index 320ba3f8e7cd..59ebeccc31f0 100644 --- a/packages/jest-console/package.json +++ b/packages/jest-console/package.json @@ -9,6 +9,13 @@ "license": "MIT", "main": "build/index.js", "types": "build/index.d.ts", + "typesVersions": { + "<3.8": { + "build/*": [ + "build/ts3.4/*" + ] + } + }, "dependencies": { "@jest/source-map": "^25.2.0", "chalk": "^3.0.0", diff --git a/packages/jest-diff/package.json b/packages/jest-diff/package.json index dbbaa458899f..3ab461b66d8a 100644 --- a/packages/jest-diff/package.json +++ b/packages/jest-diff/package.json @@ -9,6 +9,13 @@ "license": "MIT", "main": "build/index.js", "types": "build/index.d.ts", + "typesVersions": { + "<3.8": { + "build/*": [ + "build/ts3.4/*" + ] + } + }, "dependencies": { "chalk": "^3.0.0", "diff-sequences": "^25.2.0", diff --git a/packages/jest-each/package.json b/packages/jest-each/package.json index a6b5c5fbc45e..5e330d82c41d 100644 --- a/packages/jest-each/package.json +++ b/packages/jest-each/package.json @@ -4,6 +4,13 @@ "description": "Parameterised tests for Jest", "main": "build/index.js", "types": "build/index.d.ts", + "typesVersions": { + "<3.8": { + "build/*": [ + "build/ts3.4/*" + ] + } + }, "repository": { "type": "git", "url": "https://github.com/facebook/jest.git", diff --git a/packages/jest-environment-jsdom/package.json b/packages/jest-environment-jsdom/package.json index 900a71dbf82a..500c7d4f50c7 100644 --- a/packages/jest-environment-jsdom/package.json +++ b/packages/jest-environment-jsdom/package.json @@ -9,6 +9,13 @@ "license": "MIT", "main": "build/index.js", "types": "build/index.d.ts", + "typesVersions": { + "<3.8": { + "build/*": [ + "build/ts3.4/*" + ] + } + }, "dependencies": { "@jest/environment": "^25.2.0", "@jest/fake-timers": "^25.2.0", diff --git a/packages/jest-environment-node/package.json b/packages/jest-environment-node/package.json index a4c20b0dc085..0df59cf98c43 100644 --- a/packages/jest-environment-node/package.json +++ b/packages/jest-environment-node/package.json @@ -9,6 +9,13 @@ "license": "MIT", "main": "build/index.js", "types": "build/index.d.ts", + "typesVersions": { + "<3.8": { + "build/*": [ + "build/ts3.4/*" + ] + } + }, "dependencies": { "@jest/environment": "^25.2.0", "@jest/fake-timers": "^25.2.0", diff --git a/packages/jest-environment/package.json b/packages/jest-environment/package.json index 3d2eaf5a3cea..5e8861d253f9 100644 --- a/packages/jest-environment/package.json +++ b/packages/jest-environment/package.json @@ -9,6 +9,13 @@ "license": "MIT", "main": "build/index.js", "types": "build/index.d.ts", + "typesVersions": { + "<3.8": { + "build/*": [ + "build/ts3.4/*" + ] + } + }, "dependencies": { "@jest/fake-timers": "^25.2.0", "@jest/types": "^25.2.0", diff --git a/packages/jest-fake-timers/package.json b/packages/jest-fake-timers/package.json index 190f792defca..de69e1f0e6c4 100644 --- a/packages/jest-fake-timers/package.json +++ b/packages/jest-fake-timers/package.json @@ -9,6 +9,13 @@ "license": "MIT", "main": "build/index.js", "types": "build/index.d.ts", + "typesVersions": { + "<3.8": { + "build/*": [ + "build/ts3.4/*" + ] + } + }, "dependencies": { "@jest/types": "^25.2.0", "jest-message-util": "^25.2.0", diff --git a/packages/jest-get-type/package.json b/packages/jest-get-type/package.json index 5f7a6d447064..afcf4852904c 100644 --- a/packages/jest-get-type/package.json +++ b/packages/jest-get-type/package.json @@ -13,6 +13,13 @@ "license": "MIT", "main": "build/index.js", "types": "build/index.d.ts", + "typesVersions": { + "<3.8": { + "build/*": [ + "build/ts3.4/*" + ] + } + }, "publishConfig": { "access": "public" }, diff --git a/packages/jest-haste-map/package.json b/packages/jest-haste-map/package.json index 78087d601a0e..4b1c59195f6a 100644 --- a/packages/jest-haste-map/package.json +++ b/packages/jest-haste-map/package.json @@ -9,6 +9,13 @@ "license": "MIT", "main": "build/index.js", "types": "build/index.d.ts", + "typesVersions": { + "<3.8": { + "build/*": [ + "build/ts3.4/*" + ] + } + }, "dependencies": { "@jest/types": "^25.2.0", "anymatch": "^3.0.3", diff --git a/packages/jest-jasmine2/package.json b/packages/jest-jasmine2/package.json index 186dad04538e..89b4db2ccec6 100644 --- a/packages/jest-jasmine2/package.json +++ b/packages/jest-jasmine2/package.json @@ -9,6 +9,13 @@ "license": "MIT", "main": "build/index.js", "types": "build/index.d.ts", + "typesVersions": { + "<3.8": { + "build/*": [ + "build/ts3.4/*" + ] + } + }, "dependencies": { "@babel/traverse": "^7.1.0", "@jest/environment": "^25.2.0", diff --git a/packages/jest-leak-detector/package.json b/packages/jest-leak-detector/package.json index 0a78b25638c7..59df84036f9b 100644 --- a/packages/jest-leak-detector/package.json +++ b/packages/jest-leak-detector/package.json @@ -9,6 +9,13 @@ "license": "MIT", "main": "build/index.js", "types": "build/index.d.ts", + "typesVersions": { + "<3.8": { + "build/*": [ + "build/ts3.4/*" + ] + } + }, "dependencies": { "jest-get-type": "^25.1.0", "pretty-format": "^25.2.0" diff --git a/packages/jest-matcher-utils/package.json b/packages/jest-matcher-utils/package.json index e79d5b96fe44..595a4ef039db 100644 --- a/packages/jest-matcher-utils/package.json +++ b/packages/jest-matcher-utils/package.json @@ -13,6 +13,13 @@ "license": "MIT", "main": "build/index.js", "types": "build/index.d.ts", + "typesVersions": { + "<3.8": { + "build/*": [ + "build/ts3.4/*" + ] + } + }, "dependencies": { "chalk": "^3.0.0", "jest-diff": "^25.2.0", diff --git a/packages/jest-message-util/package.json b/packages/jest-message-util/package.json index 7bc4251cc6d5..b6bb9ef2585d 100644 --- a/packages/jest-message-util/package.json +++ b/packages/jest-message-util/package.json @@ -12,6 +12,13 @@ "license": "MIT", "main": "build/index.js", "types": "build/index.d.ts", + "typesVersions": { + "<3.8": { + "build/*": [ + "build/ts3.4/*" + ] + } + }, "dependencies": { "@babel/code-frame": "^7.0.0", "@jest/test-result": "^25.2.0", diff --git a/packages/jest-mock/package.json b/packages/jest-mock/package.json index cbaeee524c0c..a9fb03fd7023 100644 --- a/packages/jest-mock/package.json +++ b/packages/jest-mock/package.json @@ -18,6 +18,13 @@ "license": "MIT", "main": "build/index.js", "types": "build/index.d.ts", + "typesVersions": { + "<3.8": { + "build/*": [ + "build/ts3.4/*" + ] + } + }, "browser": "build-es5/index.js", "publishConfig": { "access": "public" diff --git a/packages/jest-regex-util/package.json b/packages/jest-regex-util/package.json index 0128f53a1987..10d6cc073b9d 100644 --- a/packages/jest-regex-util/package.json +++ b/packages/jest-regex-util/package.json @@ -15,6 +15,13 @@ "license": "MIT", "main": "build/index.js", "types": "build/index.d.ts", + "typesVersions": { + "<3.8": { + "build/*": [ + "build/ts3.4/*" + ] + } + }, "publishConfig": { "access": "public" }, diff --git a/packages/jest-repl/package.json b/packages/jest-repl/package.json index 531895a40b6f..67497f4584c8 100644 --- a/packages/jest-repl/package.json +++ b/packages/jest-repl/package.json @@ -9,6 +9,13 @@ "license": "MIT", "main": "build/index.js", "types": "build/index.d.ts", + "typesVersions": { + "<3.8": { + "build/*": [ + "build/ts3.4/*" + ] + } + }, "dependencies": { "@jest/transform": "^25.2.0", "@jest/types": "^25.2.0", diff --git a/packages/jest-reporters/package.json b/packages/jest-reporters/package.json index 1429c71684cf..0be5cf704fa1 100644 --- a/packages/jest-reporters/package.json +++ b/packages/jest-reporters/package.json @@ -4,6 +4,13 @@ "version": "25.2.0", "main": "build/index.js", "types": "build/index.d.ts", + "typesVersions": { + "<3.8": { + "build/*": [ + "build/ts3.4/*" + ] + } + }, "dependencies": { "@bcoe/v8-coverage": "^0.2.3", "@jest/console": "^25.2.0", diff --git a/packages/jest-resolve-dependencies/package.json b/packages/jest-resolve-dependencies/package.json index b41a5f5f473e..1d7ffb2f1a4c 100644 --- a/packages/jest-resolve-dependencies/package.json +++ b/packages/jest-resolve-dependencies/package.json @@ -9,6 +9,13 @@ "license": "MIT", "main": "build/index.js", "types": "build/index.d.ts", + "typesVersions": { + "<3.8": { + "build/*": [ + "build/ts3.4/*" + ] + } + }, "dependencies": { "@jest/types": "^25.2.0", "jest-regex-util": "^25.2.0", diff --git a/packages/jest-resolve/package.json b/packages/jest-resolve/package.json index a9157cede552..0d1427e35e9b 100644 --- a/packages/jest-resolve/package.json +++ b/packages/jest-resolve/package.json @@ -9,6 +9,13 @@ "license": "MIT", "main": "build/index.js", "types": "build/index.d.ts", + "typesVersions": { + "<3.8": { + "build/*": [ + "build/ts3.4/*" + ] + } + }, "dependencies": { "@jest/types": "^25.2.0", "browser-resolve": "^1.11.3", diff --git a/packages/jest-runner/package.json b/packages/jest-runner/package.json index 82513348cc17..9c6426d04d5f 100644 --- a/packages/jest-runner/package.json +++ b/packages/jest-runner/package.json @@ -9,6 +9,13 @@ "license": "MIT", "main": "build/index.js", "types": "build/index.d.ts", + "typesVersions": { + "<3.8": { + "build/*": [ + "build/ts3.4/*" + ] + } + }, "dependencies": { "@jest/console": "^25.2.0", "@jest/environment": "^25.2.0", diff --git a/packages/jest-runtime/package.json b/packages/jest-runtime/package.json index 27bba3d29d5f..68cbe37adaac 100644 --- a/packages/jest-runtime/package.json +++ b/packages/jest-runtime/package.json @@ -9,6 +9,13 @@ "license": "MIT", "main": "build/index.js", "types": "build/index.d.ts", + "typesVersions": { + "<3.8": { + "build/*": [ + "build/ts3.4/*" + ] + } + }, "dependencies": { "@jest/console": "^25.2.0", "@jest/environment": "^25.2.0", @@ -41,7 +48,6 @@ "@types/exit": "^0.1.30", "@types/glob": "^7.1.1", "@types/graceful-fs": "^4.1.2", - "@types/yargs": "^15.0.3", "execa": "^3.2.0", "jest-environment-node": "^25.2.0", "jest-snapshot-serializer-raw": "^1.1.0" diff --git a/packages/jest-serializer/package.json b/packages/jest-serializer/package.json index 28b089777fd7..26b15dc06801 100644 --- a/packages/jest-serializer/package.json +++ b/packages/jest-serializer/package.json @@ -15,6 +15,13 @@ "license": "MIT", "main": "build/index.js", "types": "build/index.d.ts", + "typesVersions": { + "<3.8": { + "build/*": [ + "build/ts3.4/*" + ] + } + }, "publishConfig": { "access": "public" }, diff --git a/packages/jest-snapshot/package.json b/packages/jest-snapshot/package.json index 6d52f5728835..2c8896435d14 100644 --- a/packages/jest-snapshot/package.json +++ b/packages/jest-snapshot/package.json @@ -9,6 +9,13 @@ "license": "MIT", "main": "build/index.js", "types": "build/index.d.ts", + "typesVersions": { + "<3.8": { + "build/*": [ + "build/ts3.4/*" + ] + } + }, "dependencies": { "@babel/types": "^7.0.0", "@jest/types": "^25.2.0", diff --git a/packages/jest-source-map/package.json b/packages/jest-source-map/package.json index f02e58df1019..adbf9928a501 100644 --- a/packages/jest-source-map/package.json +++ b/packages/jest-source-map/package.json @@ -9,6 +9,13 @@ "license": "MIT", "main": "build/index.js", "types": "build/index.d.ts", + "typesVersions": { + "<3.8": { + "build/*": [ + "build/ts3.4/*" + ] + } + }, "dependencies": { "callsites": "^3.0.0", "graceful-fs": "^4.2.3", diff --git a/packages/jest-test-result/package.json b/packages/jest-test-result/package.json index 29eda8600103..854273c93d2c 100644 --- a/packages/jest-test-result/package.json +++ b/packages/jest-test-result/package.json @@ -9,6 +9,13 @@ "license": "MIT", "main": "build/index.js", "types": "build/index.d.ts", + "typesVersions": { + "<3.8": { + "build/*": [ + "build/ts3.4/*" + ] + } + }, "dependencies": { "@jest/console": "^25.2.0", "@jest/transform": "^25.2.0", diff --git a/packages/jest-test-sequencer/package.json b/packages/jest-test-sequencer/package.json index ddc6e65ff04c..cb4f57f4bd7d 100644 --- a/packages/jest-test-sequencer/package.json +++ b/packages/jest-test-sequencer/package.json @@ -9,6 +9,13 @@ "license": "MIT", "main": "build/index.js", "types": "build/index.d.ts", + "typesVersions": { + "<3.8": { + "build/*": [ + "build/ts3.4/*" + ] + } + }, "dependencies": { "@jest/test-result": "^25.2.0", "jest-haste-map": "^25.2.0", diff --git a/packages/jest-types/package.json b/packages/jest-types/package.json index cfbd69075cbf..f0228ac51843 100644 --- a/packages/jest-types/package.json +++ b/packages/jest-types/package.json @@ -12,6 +12,13 @@ "license": "MIT", "main": "build/index.js", "types": "build/index.d.ts", + "typesVersions": { + "<3.8": { + "build/*": [ + "build/ts3.4/*" + ] + } + }, "dependencies": { "@types/istanbul-lib-coverage": "^2.0.0", "@types/istanbul-reports": "^1.1.1", diff --git a/packages/jest-util/package.json b/packages/jest-util/package.json index a608523240e0..3a634ed2a0fd 100644 --- a/packages/jest-util/package.json +++ b/packages/jest-util/package.json @@ -9,6 +9,13 @@ "license": "MIT", "main": "build/index.js", "types": "build/index.d.ts", + "typesVersions": { + "<3.8": { + "build/*": [ + "build/ts3.4/*" + ] + } + }, "dependencies": { "@jest/types": "^25.2.0", "chalk": "^3.0.0", diff --git a/packages/jest-validate/package.json b/packages/jest-validate/package.json index f41e115f5576..cd9c0513545a 100644 --- a/packages/jest-validate/package.json +++ b/packages/jest-validate/package.json @@ -9,6 +9,13 @@ "license": "MIT", "main": "build/index.js", "types": "build/index.d.ts", + "typesVersions": { + "<3.8": { + "build/*": [ + "build/ts3.4/*" + ] + } + }, "dependencies": { "@jest/types": "^25.2.0", "camelcase": "^5.3.1", diff --git a/packages/jest-worker/package.json b/packages/jest-worker/package.json index 15dba7309fa0..fa929160d9ff 100644 --- a/packages/jest-worker/package.json +++ b/packages/jest-worker/package.json @@ -9,6 +9,13 @@ "license": "MIT", "main": "build/index.js", "types": "build/index.d.ts", + "typesVersions": { + "<3.8": { + "build/*": [ + "build/ts3.4/*" + ] + } + }, "dependencies": { "merge-stream": "^2.0.0", "supports-color": "^7.0.0" diff --git a/packages/pretty-format/package.json b/packages/pretty-format/package.json index 919d27603924..c40457e9de25 100644 --- a/packages/pretty-format/package.json +++ b/packages/pretty-format/package.json @@ -10,6 +10,13 @@ "description": "Stringify any JavaScript value.", "main": "build/index.js", "types": "build/index.d.ts", + "typesVersions": { + "<3.8": { + "build/*": [ + "build/ts3.4/*" + ] + } + }, "browser": "build-es5/index.js", "author": "James Kyle ", "dependencies": { diff --git a/packages/test-utils/package.json b/packages/test-utils/package.json index ba2bc21d2eae..f060f80f970a 100644 --- a/packages/test-utils/package.json +++ b/packages/test-utils/package.json @@ -5,6 +5,13 @@ "license": "MIT", "main": "build/index.js", "types": "build/index.d.ts", + "typesVersions": { + "<3.8": { + "build/*": [ + "build/ts3.4/*" + ] + } + }, "dependencies": { "@types/jest": "*", "@types/node": "*", diff --git a/scripts/buildTs.js b/scripts/buildTs.js index c2da899321bb..1f549c242694 100644 --- a/scripts/buildTs.js +++ b/scripts/buildTs.js @@ -8,10 +8,13 @@ 'use strict'; const fs = require('fs'); +const os = require('os'); const path = require('path'); const chalk = require('chalk'); const execa = require('execa'); +const rimraf = require('rimraf'); +const throat = require('throat'); const {getPackages} = require('./buildUtils'); const packages = getPackages(); @@ -20,7 +23,13 @@ const packagesWithTs = packages.filter(p => fs.existsSync(path.resolve(p, 'tsconfig.json')) ); -const args = ['tsc', '-b', ...packagesWithTs, ...process.argv.slice(2)]; +const args = [ + '--silent', + 'tsc', + '-b', + ...packagesWithTs, + ...process.argv.slice(2), +]; console.log(chalk.inverse(' Building TypeScript definition files ')); @@ -36,3 +45,35 @@ try { console.error(e.stack); process.exitCode = 1; } + +const downlevelArgs = ['--silent', 'downlevel-dts', 'build', 'build/ts3.4']; + +console.log(chalk.inverse(' Downleveling TypeScript definition files ')); + +// we want to limit the number of processes we spawn +const cpus = Math.max(1, os.cpus().length - 1); + +Promise.all( + packagesWithTs.map( + throat(cpus, pkgDir => { + // otherwise we get nested `ts3.4` directories + rimraf.sync(path.resolve(pkgDir, 'build/ts3.4')); + + return execa('yarn', downlevelArgs, {cwd: pkgDir, stdio: 'inherit'}); + }) + ) +) + .then(() => { + console.log( + chalk.inverse.green( + ' Successfully downleveled TypeScript definition files ' + ) + ); + }) + .catch(e => { + console.error( + chalk.inverse.red(' Unable to downlevel TypeScript definition files ') + ); + console.error(e.stack); + process.exitCode = 1; + }); diff --git a/yarn.lock b/yarn.lock index 0e3dd886f653..bb406fddf6f9 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5622,6 +5622,14 @@ dot-prop@^5.2.0: dependencies: is-obj "^2.0.0" +downlevel-dts@^0.4.0: + version "0.4.0" + resolved "https://registry.yarnpkg.com/downlevel-dts/-/downlevel-dts-0.4.0.tgz#43f9f649c8b137373d76b4ee396d5a0227c10ddb" + integrity sha512-nh5vM3n2pRhPwZqh0iWo5gpItPAYEGEWw9yd0YpI+lO60B7A3A6iJlxDbt7kKVNbqBXKsptL+jwE/Yg5Go66WQ== + dependencies: + shelljs "^0.8.3" + typescript "^3.8.0-dev.20200111" + download@^6.2.2: version "6.2.5" resolved "https://registry.yarnpkg.com/download/-/download-6.2.5.tgz#acd6a542e4cd0bb42ca70cfc98c9e43b07039714" @@ -14272,7 +14280,7 @@ typedarray@^0.0.6: resolved "https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777" integrity sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c= -typescript@*, typescript@^3.8.2: +typescript@*, typescript@^3.8.0-dev.20200111, typescript@^3.8.2: version "3.8.3" resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.8.3.tgz#409eb8544ea0335711205869ec458ab109ee1061" integrity sha512-MYlEfn5VrLNsgudQTVJeNaQFUAI7DkhnOjdpAp4T+ku1TfQClewlbSuTVHiA+8skNBgaf02TL/kLOvig4y3G8w==