From 88901bffacaffeaa0654c04cc1b7e27447aadb84 Mon Sep 17 00:00:00 2001 From: Simen Bekkhus Date: Tue, 2 Mar 2021 23:20:33 +0100 Subject: [PATCH 01/10] chore: update to TypeScript@4.2 --- package.json | 2 +- packages/expect/package.json | 2 +- packages/jest-circus/src/types.ts | 2 +- packages/jest-globals/src/index.ts | 2 +- packages/jest-jasmine2/src/types.ts | 2 +- packages/jest-runner/src/types.ts | 2 +- packages/jest-types/package.json | 2 +- yarn.lock | 26 +++++++++++++------------- 8 files changed, 20 insertions(+), 20 deletions(-) diff --git a/package.json b/package.json index 645f6346eca6..a929aacaa24e 100644 --- a/package.json +++ b/package.json @@ -13,7 +13,7 @@ "@jest/globals": "workspace:*", "@jest/test-utils": "workspace:*", "@tsconfig/node12": "^1.0.9", - "@tsd/typescript": "~4.1.5", + "@tsd/typescript": "~4.2.4", "@types/babel__core": "^7.0.0", "@types/babel__generator": "^7.0.0", "@types/babel__template": "^7.0.0", diff --git a/packages/expect/package.json b/packages/expect/package.json index 7687b97bc953..fbafed399a5d 100644 --- a/packages/expect/package.json +++ b/packages/expect/package.json @@ -26,7 +26,7 @@ }, "devDependencies": { "@jest/test-utils": "^27.5.1", - "@tsd/typescript": "~4.1.5", + "@tsd/typescript": "~4.2.4", "chalk": "^4.0.0", "fast-check": "^2.0.0", "immutable": "^4.0.0", diff --git a/packages/jest-circus/src/types.ts b/packages/jest-circus/src/types.ts index 98f36bf05af5..cb518790624a 100644 --- a/packages/jest-circus/src/types.ts +++ b/packages/jest-circus/src/types.ts @@ -7,7 +7,7 @@ // Used as type import type {Circus} from '@jest/types'; -import expect = require('expect'); +import type expect = require('expect'); export const STATE_SYM = Symbol( 'JEST_STATE_SYMBOL', diff --git a/packages/jest-globals/src/index.ts b/packages/jest-globals/src/index.ts index 772ee1a8c5ff..6bebf8628f84 100644 --- a/packages/jest-globals/src/index.ts +++ b/packages/jest-globals/src/index.ts @@ -7,7 +7,7 @@ import type {Jest} from '@jest/environment'; import type {Global} from '@jest/types'; -import importedExpect = require('expect'); +import type importedExpect = require('expect'); export declare const jest: Jest; diff --git a/packages/jest-jasmine2/src/types.ts b/packages/jest-jasmine2/src/types.ts index 4d0ff244005e..4efe3220864f 100644 --- a/packages/jest-jasmine2/src/types.ts +++ b/packages/jest-jasmine2/src/types.ts @@ -7,7 +7,7 @@ import type {AssertionError} from 'assert'; import type {Config} from '@jest/types'; -import expect = require('expect'); +import type expect = require('expect'); import type CallTracker from './jasmine/CallTracker'; import type Env from './jasmine/Env'; import type JsApiReporter from './jasmine/JsApiReporter'; diff --git a/packages/jest-runner/src/types.ts b/packages/jest-runner/src/types.ts index 65d0f7fdbd46..47c8194eeb30 100644 --- a/packages/jest-runner/src/types.ts +++ b/packages/jest-runner/src/types.ts @@ -5,7 +5,7 @@ * LICENSE file in the root directory of this source tree. */ -import Emittery = require('emittery'); +import type Emittery = require('emittery'); import type {JestEnvironment} from '@jest/environment'; import type { SerializableError, diff --git a/packages/jest-types/package.json b/packages/jest-types/package.json index b7fce84e5ae1..ee6d8922c9c2 100644 --- a/packages/jest-types/package.json +++ b/packages/jest-types/package.json @@ -27,7 +27,7 @@ "chalk": "^4.0.0" }, "devDependencies": { - "@tsd/typescript": "~4.1.5", + "@tsd/typescript": "~4.2.4", "tsd-lite": "^0.5.1" }, "publishConfig": { diff --git a/yarn.lock b/yarn.lock index 5004aa505599..85b11e011d93 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2600,7 +2600,7 @@ __metadata: "@jest/globals": "workspace:*" "@jest/test-utils": "workspace:*" "@tsconfig/node12": ^1.0.9 - "@tsd/typescript": ~4.1.5 + "@tsd/typescript": ~4.2.4 "@types/babel__core": ^7.0.0 "@types/babel__generator": ^7.0.0 "@types/babel__template": ^7.0.0 @@ -2803,7 +2803,7 @@ __metadata: version: 0.0.0-use.local resolution: "@jest/types@workspace:packages/jest-types" dependencies: - "@tsd/typescript": ~4.1.5 + "@tsd/typescript": ~4.2.4 "@types/istanbul-lib-coverage": ^2.0.0 "@types/istanbul-reports": ^3.0.0 "@types/node": "*" @@ -4471,13 +4471,13 @@ __metadata: languageName: node linkType: hard -"@tsd/typescript@npm:~4.1.5": - version: 4.1.5 - resolution: "@tsd/typescript@npm:4.1.5" +"@tsd/typescript@npm:~4.2.4": + version: 4.2.4 + resolution: "@tsd/typescript@npm:4.2.4" bin: tsc: typescript/bin/tsc tsserver: typescript/bin/tsserver - checksum: a4a26ccec418c9f55b50eaa8b1d24566d56cced6657812b84d075dba7c5a5267e8c0f36288bebcdac6ced9ced7dd418ff106557f18bf2b6311b695c5288591fc + checksum: 34d090bb7ac2813d50c8deb7613f67e3aaae130f9248205b2919494cfab7e74a199eacd2546f06aa58f4d6622bd8b75415bb1c7b6e3f6b8136479383948e6678 languageName: node linkType: hard @@ -9920,7 +9920,7 @@ __metadata: dependencies: "@jest/test-utils": ^27.5.1 "@jest/types": ^27.5.1 - "@tsd/typescript": ~4.1.5 + "@tsd/typescript": ~4.2.4 chalk: ^4.0.0 fast-check: ^2.0.0 immutable: ^4.0.0 @@ -20912,22 +20912,22 @@ react-native@0.64.0: linkType: hard "typescript@*, typescript@^4.0.2, typescript@^4.0.3": - version: 4.1.6 - resolution: "typescript@npm:4.1.6" + version: 4.2.4 + resolution: "typescript@npm:4.2.4" bin: tsc: bin/tsc tsserver: bin/tsserver - checksum: 54aed909f94b16178c8a8d8911871b4e1c04454a3e6c82166715e28083e7ce6271e4d1df6f82c89544a4759b07aec780785032534e9c93b254e2107a18712c05 + checksum: 89c397df192f239359ad798b96d8e8d552e12c0c189ac5676cec4c20c410d6eec636b8e59a88f2aef0a56d961a9678d99c400099be9b7cae2f7b062eb4b7b171 languageName: node linkType: hard "typescript@patch:typescript@*#~builtin, typescript@patch:typescript@^4.0.2#~builtin, typescript@patch:typescript@^4.0.3#~builtin": - version: 4.1.6 - resolution: "typescript@patch:typescript@npm%3A4.1.6#~builtin::version=4.1.6&hash=493e53" + version: 4.2.4 + resolution: "typescript@patch:typescript@npm%3A4.2.4#~builtin::version=4.2.4&hash=493e53" bin: tsc: bin/tsc tsserver: bin/tsserver - checksum: 3bd9915f236817e4e2d32dd0d90e8902875929f014bb87a478000e32adda91d12f0425931ee6f9d6a2bc7d0c9242588fcee1050ac294497dfabf27d3d73b335c + checksum: bafcad6990f5d8ea9ccff09e440ce42630b2e42a5752dde5455b55c806ae43f8726a03770577d4fc6c2aa624597f796725cc6fe2c173f558a753a2f23a5198a4 languageName: node linkType: hard From 1b50a4c9e49b30e1c4c50a801b53d8a76de5c344 Mon Sep 17 00:00:00 2001 From: Simen Bekkhus Date: Sat, 9 Oct 2021 13:14:29 +0200 Subject: [PATCH 02/10] 4.3 --- package.json | 2 +- packages/expect/package.json | 2 +- packages/jest-environment/src/index.ts | 5 ++++- packages/jest-runtime/src/index.ts | 2 +- packages/jest-types/package.json | 2 +- yarn.lock | 26 +++++++++++++------------- 6 files changed, 21 insertions(+), 18 deletions(-) diff --git a/package.json b/package.json index a929aacaa24e..d3b93f044460 100644 --- a/package.json +++ b/package.json @@ -13,7 +13,7 @@ "@jest/globals": "workspace:*", "@jest/test-utils": "workspace:*", "@tsconfig/node12": "^1.0.9", - "@tsd/typescript": "~4.2.4", + "@tsd/typescript": "~4.3.5", "@types/babel__core": "^7.0.0", "@types/babel__generator": "^7.0.0", "@types/babel__template": "^7.0.0", diff --git a/packages/expect/package.json b/packages/expect/package.json index fbafed399a5d..cb130dc3a671 100644 --- a/packages/expect/package.json +++ b/packages/expect/package.json @@ -26,7 +26,7 @@ }, "devDependencies": { "@jest/test-utils": "^27.5.1", - "@tsd/typescript": "~4.2.4", + "@tsd/typescript": "~4.3.5", "chalk": "^4.0.0", "fast-check": "^2.0.0", "immutable": "^4.0.0", diff --git a/packages/jest-environment/src/index.ts b/packages/jest-environment/src/index.ts index 509a4dac4fad..064abc12c072 100644 --- a/packages/jest-environment/src/index.ts +++ b/packages/jest-environment/src/index.ts @@ -46,7 +46,10 @@ export declare class JestEnvironment { exportConditions?: () => Array; } -export type Module = NodeModule; +export interface Module extends NodeModule { + // for some reason missing: https://nodejs.org/api/modules.html#modules_module_path + path: string; +} // TODO: Move to some separate package export interface Jest { diff --git a/packages/jest-runtime/src/index.ts b/packages/jest-runtime/src/index.ts index 410dd84d9e0b..150b4235a822 100644 --- a/packages/jest-runtime/src/index.ts +++ b/packages/jest-runtime/src/index.ts @@ -5,7 +5,7 @@ * LICENSE file in the root directory of this source tree. */ -import * as nativeModule from 'module'; +import nativeModule = require('module'); import * as path from 'path'; import {URL, fileURLToPath, pathToFileURL} from 'url'; import { diff --git a/packages/jest-types/package.json b/packages/jest-types/package.json index ee6d8922c9c2..edf6334070db 100644 --- a/packages/jest-types/package.json +++ b/packages/jest-types/package.json @@ -27,7 +27,7 @@ "chalk": "^4.0.0" }, "devDependencies": { - "@tsd/typescript": "~4.2.4", + "@tsd/typescript": "~4.3.5", "tsd-lite": "^0.5.1" }, "publishConfig": { diff --git a/yarn.lock b/yarn.lock index 85b11e011d93..ec07ff49d48e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2600,7 +2600,7 @@ __metadata: "@jest/globals": "workspace:*" "@jest/test-utils": "workspace:*" "@tsconfig/node12": ^1.0.9 - "@tsd/typescript": ~4.2.4 + "@tsd/typescript": ~4.3.5 "@types/babel__core": ^7.0.0 "@types/babel__generator": ^7.0.0 "@types/babel__template": ^7.0.0 @@ -2803,7 +2803,7 @@ __metadata: version: 0.0.0-use.local resolution: "@jest/types@workspace:packages/jest-types" dependencies: - "@tsd/typescript": ~4.2.4 + "@tsd/typescript": ~4.3.5 "@types/istanbul-lib-coverage": ^2.0.0 "@types/istanbul-reports": ^3.0.0 "@types/node": "*" @@ -4471,13 +4471,13 @@ __metadata: languageName: node linkType: hard -"@tsd/typescript@npm:~4.2.4": - version: 4.2.4 - resolution: "@tsd/typescript@npm:4.2.4" +"@tsd/typescript@npm:~4.3.5": + version: 4.3.5 + resolution: "@tsd/typescript@npm:4.3.5" bin: tsc: typescript/bin/tsc tsserver: typescript/bin/tsserver - checksum: 34d090bb7ac2813d50c8deb7613f67e3aaae130f9248205b2919494cfab7e74a199eacd2546f06aa58f4d6622bd8b75415bb1c7b6e3f6b8136479383948e6678 + checksum: 28e7ead0687b767bf56aa3456aeabe8830c6d2175364ca6f278fdda074beca20a856483948db3a068490a7ffdac35fe92891029d37912b9e7afe55fc545ccc9d languageName: node linkType: hard @@ -9920,7 +9920,7 @@ __metadata: dependencies: "@jest/test-utils": ^27.5.1 "@jest/types": ^27.5.1 - "@tsd/typescript": ~4.2.4 + "@tsd/typescript": ~4.3.5 chalk: ^4.0.0 fast-check: ^2.0.0 immutable: ^4.0.0 @@ -20912,22 +20912,22 @@ react-native@0.64.0: linkType: hard "typescript@*, typescript@^4.0.2, typescript@^4.0.3": - version: 4.2.4 - resolution: "typescript@npm:4.2.4" + version: 4.3.5 + resolution: "typescript@npm:4.3.5" bin: tsc: bin/tsc tsserver: bin/tsserver - checksum: 89c397df192f239359ad798b96d8e8d552e12c0c189ac5676cec4c20c410d6eec636b8e59a88f2aef0a56d961a9678d99c400099be9b7cae2f7b062eb4b7b171 + checksum: bab033b5e2b0790dd35b77fd005df976ef80b8d84fd2c6e63cc31808151875beae9216e5a315fe7068e8499905c3c354248fe83272cdfc13b7705635f0c66c97 languageName: node linkType: hard "typescript@patch:typescript@*#~builtin, typescript@patch:typescript@^4.0.2#~builtin, typescript@patch:typescript@^4.0.3#~builtin": - version: 4.2.4 - resolution: "typescript@patch:typescript@npm%3A4.2.4#~builtin::version=4.2.4&hash=493e53" + version: 4.3.5 + resolution: "typescript@patch:typescript@npm%3A4.3.5#~builtin::version=4.3.5&hash=493e53" bin: tsc: bin/tsc tsserver: bin/tsserver - checksum: bafcad6990f5d8ea9ccff09e440ce42630b2e42a5752dde5455b55c806ae43f8726a03770577d4fc6c2aa624597f796725cc6fe2c173f558a753a2f23a5198a4 + checksum: 61fc1a2ca5037420de5bbe17c6ddc4cbcc0d52301ed94f0a7b5821c55ff9eb96307f0816f745ca8f0fc87ed92f3951cde6d97cd6fd6bc6920c02ea63b5b26259 languageName: node linkType: hard From bd5d99c6820a888c26e5a45d76524c979d7b2cac Mon Sep 17 00:00:00 2001 From: Simen Bekkhus Date: Mon, 11 Oct 2021 07:33:41 +0200 Subject: [PATCH 03/10] 4.4 --- .eslintrc.js | 4 --- e2e/__tests__/resolveConditions.test.ts | 2 +- package.json | 2 +- packages/expect/package.json | 2 +- packages/expect/src/__tests__/isError.test.ts | 2 +- packages/expect/src/toThrowMatchers.ts | 2 +- packages/jest-circus/src/run.ts | 4 +-- packages/jest-circus/src/utils.ts | 2 +- .../src/readConfigFileAndSetRootDir.ts | 2 +- packages/jest-core/src/TestScheduler.ts | 2 +- packages/jest-core/src/cli/index.ts | 2 +- packages/jest-core/src/runGlobalHook.ts | 2 +- .../jest-fake-timers/src/legacyFakeTimers.ts | 2 +- packages/jest-jasmine2/src/PCancelable.ts | 2 +- .../jest-jasmine2/src/jasmineAsyncInstall.ts | 2 +- packages/jest-mock/src/index.ts | 2 +- packages/jest-resolve/src/resolver.ts | 2 +- packages/jest-runtime/src/index.ts | 10 +++---- packages/jest-snapshot/src/index.ts | 2 +- packages/jest-types/package.json | 2 +- yarn.lock | 26 +++++++++---------- 21 files changed, 37 insertions(+), 41 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index 58dacdd2ec56..4f18925c37c3 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -35,10 +35,6 @@ module.exports = { rules: { '@typescript-eslint/array-type': ['error', {default: 'generic'}], '@typescript-eslint/ban-types': 'error', - '@typescript-eslint/no-implicit-any-catch': [ - 'error', - {allowExplicitAny: true}, - ], '@typescript-eslint/no-unused-vars': [ 'error', {argsIgnorePattern: '^_'}, diff --git a/e2e/__tests__/resolveConditions.test.ts b/e2e/__tests__/resolveConditions.test.ts index 991a2b27e8b1..d1b8dd644a99 100644 --- a/e2e/__tests__/resolveConditions.test.ts +++ b/e2e/__tests__/resolveConditions.test.ts @@ -21,7 +21,7 @@ onNodeVersions('>=12.16.0', () => { }); try { expect(exitCode).toBe(0); - } catch (error: unknown) { + } catch (error) { console.log(`Test failed on iteration ${i + 1}`); throw error; } diff --git a/package.json b/package.json index d3b93f044460..9f26d1c2e87a 100644 --- a/package.json +++ b/package.json @@ -13,7 +13,7 @@ "@jest/globals": "workspace:*", "@jest/test-utils": "workspace:*", "@tsconfig/node12": "^1.0.9", - "@tsd/typescript": "~4.3.5", + "@tsd/typescript": "~4.4.4", "@types/babel__core": "^7.0.0", "@types/babel__generator": "^7.0.0", "@types/babel__template": "^7.0.0", diff --git a/packages/expect/package.json b/packages/expect/package.json index cb130dc3a671..998f3799f5ee 100644 --- a/packages/expect/package.json +++ b/packages/expect/package.json @@ -26,7 +26,7 @@ }, "devDependencies": { "@jest/test-utils": "^27.5.1", - "@tsd/typescript": "~4.3.5", + "@tsd/typescript": "~4.4.4", "chalk": "^4.0.0", "fast-check": "^2.0.0", "immutable": "^4.0.0", diff --git a/packages/expect/src/__tests__/isError.test.ts b/packages/expect/src/__tests__/isError.test.ts index ddfecd088f86..bb6a77c47e6d 100644 --- a/packages/expect/src/__tests__/isError.test.ts +++ b/packages/expect/src/__tests__/isError.test.ts @@ -43,7 +43,7 @@ describe('isError', () => { testErrorFromDifferentContext((win: Window) => { try { win.document.querySelectorAll(''); - } catch (e: unknown) { + } catch (e) { return e; } return null; diff --git a/packages/expect/src/toThrowMatchers.ts b/packages/expect/src/toThrowMatchers.ts index 3e5933551a49..8be9a79ae5fd 100644 --- a/packages/expect/src/toThrowMatchers.ts +++ b/packages/expect/src/toThrowMatchers.ts @@ -107,7 +107,7 @@ export const createMatcher = ( } else { try { received(); - } catch (e: unknown) { + } catch (e) { thrown = getThrown(e); } } diff --git a/packages/jest-circus/src/run.ts b/packages/jest-circus/src/run.ts index 287bad08a2dc..65d0cf283a9b 100644 --- a/packages/jest-circus/src/run.ts +++ b/packages/jest-circus/src/run.ts @@ -157,7 +157,7 @@ const _callCircusHook = async ({ timeout, }); await dispatch({describeBlock, hook, name: 'hook_success', test}); - } catch (error: unknown) { + } catch (error) { await dispatch({describeBlock, error, hook, name: 'hook_failure', test}); } }; @@ -180,7 +180,7 @@ const _callCircusTest = async ( timeout, }); await dispatch({name: 'test_fn_success', test}); - } catch (error: unknown) { + } catch (error) { await dispatch({error, name: 'test_fn_failure', test}); } }; diff --git a/packages/jest-circus/src/utils.ts b/packages/jest-circus/src/utils.ts index ff0eb059ce5f..faeb9dab00aa 100644 --- a/packages/jest-circus/src/utils.ts +++ b/packages/jest-circus/src/utils.ts @@ -253,7 +253,7 @@ export const callAsyncCircusFn = ( } else { try { returnedValue = fn.call(testContext); - } catch (error: unknown) { + } catch (error) { reject(error); return; } diff --git a/packages/jest-config/src/readConfigFileAndSetRootDir.ts b/packages/jest-config/src/readConfigFileAndSetRootDir.ts index 68155ff43b4a..a3e9d89abb58 100644 --- a/packages/jest-config/src/readConfigFileAndSetRootDir.ts +++ b/packages/jest-config/src/readConfigFileAndSetRootDir.ts @@ -39,7 +39,7 @@ export default async function readConfigFileAndSetRootDir( } else { configObject = await requireOrImportModule(configPath); } - } catch (error: unknown) { + } catch (error) { if (isTS) { throw new Error( `Jest: Failed to parse the TypeScript config file ${configPath}\n` + diff --git a/packages/jest-core/src/TestScheduler.ts b/packages/jest-core/src/TestScheduler.ts index 708e1a7bfd7e..2786a65f6753 100644 --- a/packages/jest-core/src/TestScheduler.ts +++ b/packages/jest-core/src/TestScheduler.ts @@ -286,7 +286,7 @@ class TestScheduler { ); } } - } catch (error: unknown) { + } catch (error) { if (!watcher.isInterrupted()) { throw error; } diff --git a/packages/jest-core/src/cli/index.ts b/packages/jest-core/src/cli/index.ts index 6e74f98b0250..8a546027d6b5 100644 --- a/packages/jest-core/src/cli/index.ts +++ b/packages/jest-core/src/cli/index.ts @@ -175,7 +175,7 @@ const _run10000 = async ( filterSetupPromise = (async () => { try { await rawFilter.setup(); - } catch (err: unknown) { + } catch (err) { return err; } return undefined; diff --git a/packages/jest-core/src/runGlobalHook.ts b/packages/jest-core/src/runGlobalHook.ts index 60de3085592e..93cf857ac4cd 100644 --- a/packages/jest-core/src/runGlobalHook.ts +++ b/packages/jest-core/src/runGlobalHook.ts @@ -58,7 +58,7 @@ export default async function runGlobalHook({ await globalModule(globalConfig); }, ); - } catch (error: unknown) { + } catch (error) { if (util.types.isNativeError(error)) { error.message = `Jest: Got error running ${moduleName} - ${modulePath}, reason: ${error.message}`; diff --git a/packages/jest-fake-timers/src/legacyFakeTimers.ts b/packages/jest-fake-timers/src/legacyFakeTimers.ts index 0afc385c638e..8d07c01920bf 100644 --- a/packages/jest-fake-timers/src/legacyFakeTimers.ts +++ b/packages/jest-fake-timers/src/legacyFakeTimers.ts @@ -308,7 +308,7 @@ export default class FakeTimers { let errThrown = false; try { cb(); - } catch (e: unknown) { + } catch (e) { errThrown = true; cbErr = e; } diff --git a/packages/jest-jasmine2/src/PCancelable.ts b/packages/jest-jasmine2/src/PCancelable.ts index d58e58ad0a3e..2c7b0aa826fe 100644 --- a/packages/jest-jasmine2/src/PCancelable.ts +++ b/packages/jest-jasmine2/src/PCancelable.ts @@ -75,7 +75,7 @@ export default class PCancelable implements PromiseLike { if (typeof this._cancel === 'function') { try { this._cancel(); - } catch (err: unknown) { + } catch (err) { this._reject(err); } } diff --git a/packages/jest-jasmine2/src/jasmineAsyncInstall.ts b/packages/jest-jasmine2/src/jasmineAsyncInstall.ts index 84836e81dba4..b7f705bd4b4e 100644 --- a/packages/jest-jasmine2/src/jasmineAsyncInstall.ts +++ b/packages/jest-jasmine2/src/jasmineAsyncInstall.ts @@ -212,7 +212,7 @@ function makeConcurrent( `Jest: concurrent test "${spec.getFullName()}" must return a Promise.`, ); }); - } catch (error: unknown) { + } catch (error) { promise = Promise.reject(error); } // Avoid triggering the uncaught promise rejection handler in case the test errors before diff --git a/packages/jest-mock/src/index.ts b/packages/jest-mock/src/index.ts index fb0e99fef11b..bd3e3e11c809 100644 --- a/packages/jest-mock/src/index.ts +++ b/packages/jest-mock/src/index.ts @@ -672,7 +672,7 @@ export class ModuleMocker { return undefined; })(); - } catch (error: unknown) { + } catch (error) { // Store the thrown error so we can record it, then re-throw it. thrownError = error; callDidThrowError = true; diff --git a/packages/jest-resolve/src/resolver.ts b/packages/jest-resolve/src/resolver.ts index f21bf9a4570c..4dacbc8fc5fd 100644 --- a/packages/jest-resolve/src/resolver.ts +++ b/packages/jest-resolve/src/resolver.ts @@ -123,7 +123,7 @@ export default class Resolver { paths: paths ? (nodePaths || []).concat(paths) : nodePaths, rootDir: options.rootDir, }); - } catch (e: unknown) { + } catch (e) { if (options.throwIfNotFound) { throw e; } diff --git a/packages/jest-runtime/src/index.ts b/packages/jest-runtime/src/index.ts index 150b4235a822..6d90e3845005 100644 --- a/packages/jest-runtime/src/index.ts +++ b/packages/jest-runtime/src/index.ts @@ -512,7 +512,7 @@ export default class Runtime { this._esmoduleRegistry.set(cacheKey, module); transformResolve(); - } catch (error: unknown) { + } catch (error) { transformReject(error); throw error; } @@ -838,7 +838,7 @@ export default class Runtime { options, moduleRegistry, ); - } catch (error: unknown) { + } catch (error) { moduleRegistry.delete(modulePath); throw error; } @@ -1013,7 +1013,7 @@ export default class Runtime { } else { return this.requireModule(from, moduleName); } - } catch (e: unknown) { + } catch (e) { const moduleNotFound = Resolver.tryCastModuleNotFoundError(e); if (moduleNotFound) { if ( @@ -1279,7 +1279,7 @@ export default class Runtime { return this._resolveModule(from, moduleName, { conditions: this.cjsConditions, }); - } catch (err: unknown) { + } catch (err) { const module = this._resolver.getMockModule(from, moduleName); if (module) { @@ -1718,7 +1718,7 @@ export default class Runtime { let modulePath; try { modulePath = this._resolveModule(from, moduleName, options); - } catch (e: unknown) { + } catch (e) { const manualMock = this._resolver.getMockModule(from, moduleName); if (manualMock) { this._shouldMockModuleCache.set(moduleID, true); diff --git a/packages/jest-snapshot/src/index.ts b/packages/jest-snapshot/src/index.ts index 6a5d09c0f155..0c8e627f441e 100644 --- a/packages/jest-snapshot/src/index.ts +++ b/packages/jest-snapshot/src/index.ts @@ -511,7 +511,7 @@ const _toThrowErrorMatchingSnapshot = ( } else { try { received(); - } catch (e: unknown) { + } catch (e) { error = e; } } diff --git a/packages/jest-types/package.json b/packages/jest-types/package.json index edf6334070db..c1f60645a15b 100644 --- a/packages/jest-types/package.json +++ b/packages/jest-types/package.json @@ -27,7 +27,7 @@ "chalk": "^4.0.0" }, "devDependencies": { - "@tsd/typescript": "~4.3.5", + "@tsd/typescript": "~4.4.4", "tsd-lite": "^0.5.1" }, "publishConfig": { diff --git a/yarn.lock b/yarn.lock index ec07ff49d48e..037bea4f0739 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2600,7 +2600,7 @@ __metadata: "@jest/globals": "workspace:*" "@jest/test-utils": "workspace:*" "@tsconfig/node12": ^1.0.9 - "@tsd/typescript": ~4.3.5 + "@tsd/typescript": ~4.4.4 "@types/babel__core": ^7.0.0 "@types/babel__generator": ^7.0.0 "@types/babel__template": ^7.0.0 @@ -2803,7 +2803,7 @@ __metadata: version: 0.0.0-use.local resolution: "@jest/types@workspace:packages/jest-types" dependencies: - "@tsd/typescript": ~4.3.5 + "@tsd/typescript": ~4.4.4 "@types/istanbul-lib-coverage": ^2.0.0 "@types/istanbul-reports": ^3.0.0 "@types/node": "*" @@ -4471,13 +4471,13 @@ __metadata: languageName: node linkType: hard -"@tsd/typescript@npm:~4.3.5": - version: 4.3.5 - resolution: "@tsd/typescript@npm:4.3.5" +"@tsd/typescript@npm:~4.4.4": + version: 4.4.4 + resolution: "@tsd/typescript@npm:4.4.4" bin: tsc: typescript/bin/tsc tsserver: typescript/bin/tsserver - checksum: 28e7ead0687b767bf56aa3456aeabe8830c6d2175364ca6f278fdda074beca20a856483948db3a068490a7ffdac35fe92891029d37912b9e7afe55fc545ccc9d + checksum: 092a49faaad0ff8e3a84d2d695a29125a05a9cc0801260cec84ff2b62aa826db1437c20c9d96f9de4cff724e53e7fd31051bd4b70692e043350d33ae16b2372b languageName: node linkType: hard @@ -9920,7 +9920,7 @@ __metadata: dependencies: "@jest/test-utils": ^27.5.1 "@jest/types": ^27.5.1 - "@tsd/typescript": ~4.3.5 + "@tsd/typescript": ~4.4.4 chalk: ^4.0.0 fast-check: ^2.0.0 immutable: ^4.0.0 @@ -20912,22 +20912,22 @@ react-native@0.64.0: linkType: hard "typescript@*, typescript@^4.0.2, typescript@^4.0.3": - version: 4.3.5 - resolution: "typescript@npm:4.3.5" + version: 4.4.4 + resolution: "typescript@npm:4.4.4" bin: tsc: bin/tsc tsserver: bin/tsserver - checksum: bab033b5e2b0790dd35b77fd005df976ef80b8d84fd2c6e63cc31808151875beae9216e5a315fe7068e8499905c3c354248fe83272cdfc13b7705635f0c66c97 + checksum: 89ecb8436bb48ef5594d49289f5f89103071716b6e4844278f4fb3362856e31203e187a9c76d205c3f0b674d221a058fd28310dbcbcf5d95e9a57229bb5203f1 languageName: node linkType: hard "typescript@patch:typescript@*#~builtin, typescript@patch:typescript@^4.0.2#~builtin, typescript@patch:typescript@^4.0.3#~builtin": - version: 4.3.5 - resolution: "typescript@patch:typescript@npm%3A4.3.5#~builtin::version=4.3.5&hash=493e53" + version: 4.4.4 + resolution: "typescript@patch:typescript@npm%3A4.4.4#~builtin::version=4.4.4&hash=493e53" bin: tsc: bin/tsc tsserver: bin/tsserver - checksum: 61fc1a2ca5037420de5bbe17c6ddc4cbcc0d52301ed94f0a7b5821c55ff9eb96307f0816f745ca8f0fc87ed92f3951cde6d97cd6fd6bc6920c02ea63b5b26259 + checksum: bd629ad0da4a15d79aaad56baf3ee7d96f6a181760d430ae77f8c5325df7bffd9edee57544a3970e3651e8b796fe03a5838a7eb39c6d46cc3866c0b23d36a0dd languageName: node linkType: hard From c0f9dd27eb35243c5a78a640dd05a25077d91b49 Mon Sep 17 00:00:00 2001 From: Simen Bekkhus Date: Wed, 9 Feb 2022 11:58:33 +0100 Subject: [PATCH 04/10] 4.5 --- package.json | 2 +- packages/expect/package.json | 2 +- packages/jest-types/package.json | 2 +- yarn.lock | 28 ++++++++++++++-------------- 4 files changed, 17 insertions(+), 17 deletions(-) diff --git a/package.json b/package.json index 9f26d1c2e87a..a8bc8ccf5c3a 100644 --- a/package.json +++ b/package.json @@ -13,7 +13,7 @@ "@jest/globals": "workspace:*", "@jest/test-utils": "workspace:*", "@tsconfig/node12": "^1.0.9", - "@tsd/typescript": "~4.4.4", + "@tsd/typescript": "~4.5.5", "@types/babel__core": "^7.0.0", "@types/babel__generator": "^7.0.0", "@types/babel__template": "^7.0.0", diff --git a/packages/expect/package.json b/packages/expect/package.json index 998f3799f5ee..a7048305dffb 100644 --- a/packages/expect/package.json +++ b/packages/expect/package.json @@ -26,7 +26,7 @@ }, "devDependencies": { "@jest/test-utils": "^27.5.1", - "@tsd/typescript": "~4.4.4", + "@tsd/typescript": "~4.5.5", "chalk": "^4.0.0", "fast-check": "^2.0.0", "immutable": "^4.0.0", diff --git a/packages/jest-types/package.json b/packages/jest-types/package.json index c1f60645a15b..db5e3cdda5f2 100644 --- a/packages/jest-types/package.json +++ b/packages/jest-types/package.json @@ -27,7 +27,7 @@ "chalk": "^4.0.0" }, "devDependencies": { - "@tsd/typescript": "~4.4.4", + "@tsd/typescript": "~4.5.5", "tsd-lite": "^0.5.1" }, "publishConfig": { diff --git a/yarn.lock b/yarn.lock index 037bea4f0739..6ed4d3de8b9d 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2600,7 +2600,7 @@ __metadata: "@jest/globals": "workspace:*" "@jest/test-utils": "workspace:*" "@tsconfig/node12": ^1.0.9 - "@tsd/typescript": ~4.4.4 + "@tsd/typescript": ~4.5.5 "@types/babel__core": ^7.0.0 "@types/babel__generator": ^7.0.0 "@types/babel__template": ^7.0.0 @@ -2803,7 +2803,7 @@ __metadata: version: 0.0.0-use.local resolution: "@jest/types@workspace:packages/jest-types" dependencies: - "@tsd/typescript": ~4.4.4 + "@tsd/typescript": ~4.5.5 "@types/istanbul-lib-coverage": ^2.0.0 "@types/istanbul-reports": ^3.0.0 "@types/node": "*" @@ -4471,13 +4471,13 @@ __metadata: languageName: node linkType: hard -"@tsd/typescript@npm:~4.4.4": - version: 4.4.4 - resolution: "@tsd/typescript@npm:4.4.4" +"@tsd/typescript@npm:~4.5.5": + version: 4.5.5 + resolution: "@tsd/typescript@npm:4.5.5" bin: tsc: typescript/bin/tsc tsserver: typescript/bin/tsserver - checksum: 092a49faaad0ff8e3a84d2d695a29125a05a9cc0801260cec84ff2b62aa826db1437c20c9d96f9de4cff724e53e7fd31051bd4b70692e043350d33ae16b2372b + checksum: 6b57a087b713530966f073b47837c47a52adf7f4b036495853283ff0a6d7b39ec6d6a59105ca4708bb715f7a8551f4dd004de20ca0b72c396103c360841b6aab languageName: node linkType: hard @@ -9920,7 +9920,7 @@ __metadata: dependencies: "@jest/test-utils": ^27.5.1 "@jest/types": ^27.5.1 - "@tsd/typescript": ~4.4.4 + "@tsd/typescript": ~4.5.5 chalk: ^4.0.0 fast-check: ^2.0.0 immutable: ^4.0.0 @@ -20911,23 +20911,23 @@ react-native@0.64.0: languageName: node linkType: hard -"typescript@*, typescript@^4.0.2, typescript@^4.0.3": - version: 4.4.4 - resolution: "typescript@npm:4.4.4" +"typescript@*, typescript@npm:^4.0.2, typescript@npm:^4.0.3": + version: 4.5.5 + resolution: "typescript@npm:4.5.5" bin: tsc: bin/tsc tsserver: bin/tsserver - checksum: 89ecb8436bb48ef5594d49289f5f89103071716b6e4844278f4fb3362856e31203e187a9c76d205c3f0b674d221a058fd28310dbcbcf5d95e9a57229bb5203f1 + checksum: 506f4c919dc8aeaafa92068c997f1d213b9df4d9756d0fae1a1e7ab66b585ab3498050e236113a1c9e57ee08c21ec6814ca7a7f61378c058d79af50a4b1f5a5e languageName: node linkType: hard "typescript@patch:typescript@*#~builtin, typescript@patch:typescript@^4.0.2#~builtin, typescript@patch:typescript@^4.0.3#~builtin": - version: 4.4.4 - resolution: "typescript@patch:typescript@npm%3A4.4.4#~builtin::version=4.4.4&hash=493e53" + version: 4.5.5 + resolution: "typescript@patch:typescript@npm%3A4.5.5#~builtin::version=4.5.5&hash=493e53" bin: tsc: bin/tsc tsserver: bin/tsserver - checksum: bd629ad0da4a15d79aaad56baf3ee7d96f6a181760d430ae77f8c5325df7bffd9edee57544a3970e3651e8b796fe03a5838a7eb39c6d46cc3866c0b23d36a0dd + checksum: c05c318d79c690f101d7ffb34cd6c7d6bbd884d3af9cefe7749ad0cd6be43c7082f098280982ca945dcba23fde34a08fed9602bb26540936baf8c0520727d3ba languageName: node linkType: hard From a4d1ded3695e7645febc364c5e38165d12414dac Mon Sep 17 00:00:00 2001 From: Simen Bekkhus Date: Wed, 9 Feb 2022 12:06:29 +0100 Subject: [PATCH 05/10] minimum TS is 4.2 --- .github/workflows/nodejs.yml | 2 +- scripts/verifyOldTs.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/nodejs.yml b/.github/workflows/nodejs.yml index f311a44a361c..5cc10ebc1c8d 100644 --- a/.github/workflows/nodejs.yml +++ b/.github/workflows/nodejs.yml @@ -58,7 +58,7 @@ jobs: run: yarn build - name: test typings run: yarn test-types - - name: verify TypeScript@3.8 compatibility + - name: verify TypeScript@4.2 compatibility run: yarn verify-old-ts - name: verify Yarn PnP compatibility run: yarn verify-pnp diff --git a/scripts/verifyOldTs.js b/scripts/verifyOldTs.js index 543b9c5c0d22..3d91fce74942 100644 --- a/scripts/verifyOldTs.js +++ b/scripts/verifyOldTs.js @@ -29,7 +29,7 @@ const tsConfig = { }; const cwd = tempy.directory(); -const tsVersion = '3.8'; +const tsVersion = '4.2'; try { fs.writeFileSync(path.join(cwd, '.yarnrc.yml'), 'nodeLinker: node-modules\n'); From c5fccd189412ed77436e14175d707405d1794a5b Mon Sep 17 00:00:00 2001 From: Simen Bekkhus Date: Wed, 9 Feb 2022 12:09:14 +0100 Subject: [PATCH 06/10] use @tsconfig/node12 in test --- scripts/verifyOldTs.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/scripts/verifyOldTs.js b/scripts/verifyOldTs.js index 3d91fce74942..63fb10a88e24 100644 --- a/scripts/verifyOldTs.js +++ b/scripts/verifyOldTs.js @@ -16,17 +16,17 @@ const tempy = require('tempy'); const jestDirectory = path.resolve(__dirname, '../packages/jest'); +/* eslint-disable sort-keys */ const tsConfig = { + extends: '@tsconfig/node12/tsconfig.json', compilerOptions: { esModuleInterop: false, - lib: ['es2018'], - module: 'commonjs', moduleResolution: 'node', noEmit: true, - strict: true, - target: 'es5', }, }; +/* eslint-enable */ + const cwd = tempy.directory(); const tsVersion = '4.2'; @@ -34,7 +34,7 @@ const tsVersion = '4.2'; try { fs.writeFileSync(path.join(cwd, '.yarnrc.yml'), 'nodeLinker: node-modules\n'); execa.sync('yarn', ['init', '--yes'], {cwd, stdio: 'inherit'}); - execa.sync('yarn', ['add', `typescript@~${tsVersion}`], { + execa.sync('yarn', ['add', `typescript@~${tsVersion}`, '@tsconfig/node12'], { cwd, stdio: 'inherit', }); From 256503da1e74e5718695dae0a155dd1a561db04a Mon Sep 17 00:00:00 2001 From: Simen Bekkhus Date: Wed, 9 Feb 2022 12:16:17 +0100 Subject: [PATCH 07/10] runner@3 --- package.json | 2 +- yarn.lock | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index a8bc8ccf5c3a..99785fbb1fd2 100644 --- a/package.json +++ b/package.json @@ -55,7 +55,7 @@ "jest-changed-files": "workspace:*", "jest-junit": "^13.0.0", "jest-mock": "workspace:*", - "jest-runner-tsd": "^2.0.0", + "jest-runner-tsd": "^3.0.0", "jest-silent-reporter": "^0.5.0", "jest-snapshot": "workspace:*", "jest-watch-typeahead": "^0.6.0", diff --git a/yarn.lock b/yarn.lock index 6ed4d3de8b9d..c3fd68653256 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2642,7 +2642,7 @@ __metadata: jest-changed-files: "workspace:*" jest-junit: ^13.0.0 jest-mock: "workspace:*" - jest-runner-tsd: ^2.0.0 + jest-runner-tsd: ^3.0.0 jest-silent-reporter: ^0.5.0 jest-snapshot: "workspace:*" jest-watch-typeahead: ^0.6.0 @@ -13004,9 +13004,9 @@ __metadata: languageName: unknown linkType: soft -"jest-runner-tsd@npm:^2.0.0": - version: 2.0.0 - resolution: "jest-runner-tsd@npm:2.0.0" +"jest-runner-tsd@npm:^3.0.0": + version: 3.0.0 + resolution: "jest-runner-tsd@npm:3.0.0" dependencies: "@babel/code-frame": ^7.15.8 chalk: ^4.1.2 @@ -13014,7 +13014,7 @@ __metadata: tsd-lite: ^0.5.0 peerDependencies: "@tsd/typescript": ^3.8.3 || ^4.0.7 - checksum: 5c86e565036b4d5dd11c2669d5e8ac8508d794c6ee39044ae10f979d5b5ead7d98b6cae34bb1b31d4d197d3fe0bcc11a85ef158aaa61d7ab955c008758ac646d + checksum: 33f7145d7dc983ccfa9706e9926c57d30957265bf3c2171a8ecca5bfd7f3ab06b4dd668edcf02b0bd7f356020c4999d16d76aa666eed5b64da8d73ef7b12a061 languageName: node linkType: hard From 04d90e46b480e12c6d431edf46a2d6f8e5bdbfb2 Mon Sep 17 00:00:00 2001 From: Simen Bekkhus Date: Wed, 9 Feb 2022 12:18:18 +0100 Subject: [PATCH 08/10] changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index f46fc07180b5..a67810c12ac3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ ### Chore & Maintenance - `[*]` [**BREAKING**] Drop support for Node v10 and v15 and target first LTS `16.13.0` ([#12220](https://github.com/facebook/jest/pull/12220)) +- `[*]` [**BREAKING**] Drop support for `typescript@3.8`, minimum version is now `4.2` ([#11142](https://github.com/facebook/jest/pull/11142)) - `[@jest/core]` Use `index.ts` instead of `jest.ts` as main export ([#12329](https://github.com/facebook/jest/pull/12329)) - `[jest]` Use `index.ts` instead of `jest.ts` as main export ([#12329](https://github.com/facebook/jest/pull/12329)) From 2b4c3a02c3fba939daebf98f1dbff04f474be5b1 Mon Sep 17 00:00:00 2001 From: Simen Bekkhus Date: Wed, 9 Feb 2022 12:20:07 +0100 Subject: [PATCH 09/10] less diff --- packages/jest-environment/src/index.ts | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/packages/jest-environment/src/index.ts b/packages/jest-environment/src/index.ts index 064abc12c072..509a4dac4fad 100644 --- a/packages/jest-environment/src/index.ts +++ b/packages/jest-environment/src/index.ts @@ -46,10 +46,7 @@ export declare class JestEnvironment { exportConditions?: () => Array; } -export interface Module extends NodeModule { - // for some reason missing: https://nodejs.org/api/modules.html#modules_module_path - path: string; -} +export type Module = NodeModule; // TODO: Move to some separate package export interface Jest { From 277026b5275e3fd09d686646518078b977ead5ca Mon Sep 17 00:00:00 2001 From: Simen Bekkhus Date: Wed, 9 Feb 2022 12:21:07 +0100 Subject: [PATCH 10/10] bump type-fest --- package.json | 2 +- yarn.lock | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index 99785fbb1fd2..31aea41b6969 100644 --- a/package.json +++ b/package.json @@ -79,7 +79,7 @@ "tempy": "^1.0.0", "throat": "^6.0.1", "ts-node": "^9.0.0", - "type-fest": "^1.1.1", + "type-fest": "^2.11.2", "typescript": "^4.0.2", "which": "^2.0.1" }, diff --git a/yarn.lock b/yarn.lock index c3fd68653256..354c7cd35496 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2666,7 +2666,7 @@ __metadata: tempy: ^1.0.0 throat: ^6.0.1 ts-node: ^9.0.0 - type-fest: ^1.1.1 + type-fest: ^2.11.2 typescript: ^4.0.2 which: ^2.0.1 languageName: unknown @@ -20878,10 +20878,10 @@ react-native@0.64.0: languageName: node linkType: hard -"type-fest@npm:^1.1.1": - version: 1.4.0 - resolution: "type-fest@npm:1.4.0" - checksum: b011c3388665b097ae6a109a437a04d6f61d81b7357f74cbcb02246f2f5bd72b888ae33631b99871388122ba0a87f4ff1c94078e7119ff22c70e52c0ff828201 +"type-fest@npm:^2.11.2": + version: 2.11.2 + resolution: "type-fest@npm:2.11.2" + checksum: b36f73b9e739d4044f511fa3233eb36d365f5fbf5b120810ec5c6a31b8a6c7a2caeba2fb725491ccfb41a37aac8862e67f4383fc178a0c6074d27c424fe7c764 languageName: node linkType: hard