From 1f21f58d97b6587beff025df3e4f3ea049b111fd Mon Sep 17 00:00:00 2001 From: Simen Bekkhus Date: Mon, 11 Oct 2021 07:33:41 +0200 Subject: [PATCH] 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 3608aed77d00..5257d2d18103 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -40,10 +40,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 77ea0517a02d..e69eff9341f2 100644 --- a/package.json +++ b/package.json @@ -14,7 +14,7 @@ "@jest/globals": "workspace:*", "@jest/test-utils": "workspace:*", "@tsconfig/node10": "^1.0.8", - "@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 aec49b12999f..1400b5e7a560 100644 --- a/packages/expect/package.json +++ b/packages/expect/package.json @@ -26,7 +26,7 @@ }, "devDependencies": { "@jest/test-utils": "^27.5.0", - "@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 78722bdf32da..d49cfdcb31bf 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 6bf555c77911..cb66888292af 100644 --- a/packages/jest-config/src/readConfigFileAndSetRootDir.ts +++ b/packages/jest-config/src/readConfigFileAndSetRootDir.ts @@ -36,7 +36,7 @@ export default async function readConfigFileAndSetRootDir( } else { configObject = await requireOrImportModule(configPath); } - } catch (error: unknown) { + } catch (error) { if (isJSON) { throw new Error( `Jest: Failed to parse 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 2c635a2ecdb6..760cdca4c923 100644 --- a/packages/jest-core/src/runGlobalHook.ts +++ b/packages/jest-core/src/runGlobalHook.ts @@ -58,7 +58,7 @@ export default async ({ 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 3762d00b2963..07505acb578f 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 4b9dd6df9544..e39d37f686ac 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 58bae0a9d0b8..d9836957eaa8 100644 --- a/packages/jest-snapshot/src/index.ts +++ b/packages/jest-snapshot/src/index.ts @@ -510,7 +510,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 13f2bea9d1db..bd66e2de213d 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 d7e0c8bc1095..a31df1954281 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2592,7 +2592,7 @@ __metadata: "@jest/globals": "workspace:*" "@jest/test-utils": "workspace:*" "@tsconfig/node10": ^1.0.8 - "@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 @@ -2797,7 +2797,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": "*" @@ -4441,13 +4441,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: 4180f90b7edd95c1e5e7c130b365085bd49b8c6bc0e374c30f437aa8392ca8c8ff3af02a28181fbe736abb198f8d3122251645fa6b77b1a9db86f16ba889c019 + checksum: 3f1d69f12917f1e685b4cc15eba18b4d000e076092aff27228d6d47a631d2267c431914cf1061d2d5d052112d5a74071830a568e0a396a0aa6e608fb30b016f0 languageName: node linkType: hard @@ -9883,7 +9883,7 @@ __metadata: dependencies: "@jest/test-utils": ^27.5.0 "@jest/types": ^27.5.0 - "@tsd/typescript": ~4.3.5 + "@tsd/typescript": ~4.4.4 chalk: ^4.0.0 fast-check: ^2.0.0 immutable: ^4.0.0 @@ -20830,22 +20830,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.3 + resolution: "typescript@npm:4.4.3" bin: tsc: bin/tsc tsserver: bin/tsserver - checksum: d9a8e78d72dd19896e6bfa73ab2a0fcea6eca2700d1d6e7c33f67a970af54a3e0fed8f715a8c4e6a0ff7fc0995067b394b2003518ab0aa84cd396377e54b760c + checksum: 0da3a2a96506240557512ee49ff37a882c49c8c803444b90b98984e50d5d2e526885d57cd0f75225525413630b0e070e0e9ab4538485852fa1c158a6e7925cbb 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=8133ad" + version: 4.4.3 + resolution: "typescript@patch:typescript@npm%3A4.4.3#builtin::version=4.4.3&hash=8133ad" bin: tsc: bin/tsc tsserver: bin/tsserver - checksum: 7e9040a3ee8b62c9f499fdaeeb2ea143c079e88fadeba562ce2f7ee878cf3eba9cf6097bf8a4ead0de4b35582f71a4866d9f475af9b064fde430d55d9fc6aaac + checksum: d328b850f6e56d424dfda4b2bf2950fcc2f8bb21446f0eb9fe2d4b7a4f9b678a4f17204a31f6ad2dfb2419a69e508683d938491cecc2650aedde9423e5489825 languageName: node linkType: hard