From 81259f3e1e948dc71ef82406031e3cb381483e88 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 +- 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 +- .../jest-config/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 +- packages/jest-fake-timers/src/legacyFakeTimers.ts | 2 +- packages/jest-jasmine2/src/PCancelable.ts | 2 +- packages/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 +- yarn.lock | 12 ++++++------ 18 files changed, 27 insertions(+), 31 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index 444c0d1924c9..fd3b6eaa84a1 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -37,10 +37,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 375257ac7640..ee7c00f6f12d 100644 --- a/e2e/__tests__/resolveConditions.test.ts +++ b/e2e/__tests__/resolveConditions.test.ts @@ -26,7 +26,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/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 09a2aaa8c896..2bff8dfd3a7c 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 6a31a66c32b7..be33f5b41bbc 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); } diff --git a/packages/jest-mock/src/index.ts b/packages/jest-mock/src/index.ts index 0d0cdce00a8c..e92b0b3eb80c 100644 --- a/packages/jest-mock/src/index.ts +++ b/packages/jest-mock/src/index.ts @@ -595,7 +595,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 f5c668b85b43..315537ae4fcd 100644 --- a/packages/jest-resolve/src/resolver.ts +++ b/packages/jest-resolve/src/resolver.ts @@ -122,7 +122,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 9fc2a52d33ea..5fdaf0ad65c1 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 d9c7fed4dc38..3849c7dc4db8 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/yarn.lock b/yarn.lock index 75e3a124b5e2..475980a84870 100644 --- a/yarn.lock +++ b/yarn.lock @@ -21198,22 +21198,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