Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: update to [email protected] #11142

Merged
merged 10 commits into from
Feb 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: '^_'},
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 `[email protected]`, 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))

Expand Down
2 changes: 1 addition & 1 deletion e2e/__tests__/resolveConditions.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"@jest/globals": "workspace:*",
"@jest/test-utils": "workspace:*",
"@tsconfig/node12": "^1.0.9",
"@tsd/typescript": "~4.1.5",
"@tsd/typescript": "~4.5.5",
"@types/babel__core": "^7.0.0",
"@types/babel__generator": "^7.0.0",
"@types/babel__template": "^7.0.0",
Expand Down Expand Up @@ -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",
Expand All @@ -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"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/expect/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
},
"devDependencies": {
"@jest/test-utils": "^27.5.1",
"@tsd/typescript": "~4.1.5",
"@tsd/typescript": "~4.5.5",
"chalk": "^4.0.0",
"fast-check": "^2.0.0",
"immutable": "^4.0.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/expect/src/__tests__/isError.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ describe('isError', () => {
testErrorFromDifferentContext((win: Window) => {
try {
win.document.querySelectorAll('');
} catch (e: unknown) {
} catch (e) {
return e;
}
return null;
Expand Down
2 changes: 1 addition & 1 deletion packages/expect/src/toThrowMatchers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ export const createMatcher = (
} else {
try {
received();
} catch (e: unknown) {
} catch (e) {
thrown = getThrown(e);
}
}
Expand Down
4 changes: 2 additions & 2 deletions packages/jest-circus/src/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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});
}
};
Expand All @@ -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});
}
};
Expand Down
2 changes: 1 addition & 1 deletion packages/jest-circus/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
2 changes: 1 addition & 1 deletion packages/jest-circus/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ export const callAsyncCircusFn = (
} else {
try {
returnedValue = fn.call(testContext);
} catch (error: unknown) {
} catch (error) {
reject(error);
return;
}
Expand Down
2 changes: 1 addition & 1 deletion packages/jest-config/src/readConfigFileAndSetRootDir.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export default async function readConfigFileAndSetRootDir(
} else {
configObject = await requireOrImportModule<any>(configPath);
}
} catch (error: unknown) {
} catch (error) {
if (isTS) {
throw new Error(
`Jest: Failed to parse the TypeScript config file ${configPath}\n` +
Expand Down
2 changes: 1 addition & 1 deletion packages/jest-core/src/TestScheduler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ class TestScheduler {
);
}
}
} catch (error: unknown) {
} catch (error) {
if (!watcher.isInterrupted()) {
throw error;
}
Expand Down
2 changes: 1 addition & 1 deletion packages/jest-core/src/cli/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ const _run10000 = async (
filterSetupPromise = (async () => {
try {
await rawFilter.setup();
} catch (err: unknown) {
} catch (err) {
return err;
}
return undefined;
Expand Down
2 changes: 1 addition & 1 deletion packages/jest-core/src/runGlobalHook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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}`;

Expand Down
2 changes: 1 addition & 1 deletion packages/jest-fake-timers/src/legacyFakeTimers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ export default class FakeTimers<TimerRef> {
let errThrown = false;
try {
cb();
} catch (e: unknown) {
} catch (e) {
errThrown = true;
cbErr = e;
}
Expand Down
2 changes: 1 addition & 1 deletion packages/jest-globals/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion packages/jest-jasmine2/src/PCancelable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ export default class PCancelable<T> implements PromiseLike<T> {
if (typeof this._cancel === 'function') {
try {
this._cancel();
} catch (err: unknown) {
} catch (err) {
this._reject(err);
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/jest-jasmine2/src/jasmineAsyncInstall.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion packages/jest-jasmine2/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
2 changes: 1 addition & 1 deletion packages/jest-mock/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion packages/jest-resolve/src/resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion packages/jest-runner/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
12 changes: 6 additions & 6 deletions packages/jest-runtime/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -512,7 +512,7 @@ export default class Runtime {
this._esmoduleRegistry.set(cacheKey, module);

transformResolve();
} catch (error: unknown) {
} catch (error) {
transformReject(error);
throw error;
}
Expand Down Expand Up @@ -838,7 +838,7 @@ export default class Runtime {
options,
moduleRegistry,
);
} catch (error: unknown) {
} catch (error) {
moduleRegistry.delete(modulePath);
throw error;
}
Expand Down Expand Up @@ -1013,7 +1013,7 @@ export default class Runtime {
} else {
return this.requireModule<T>(from, moduleName);
}
} catch (e: unknown) {
} catch (e) {
const moduleNotFound = Resolver.tryCastModuleNotFoundError(e);
if (moduleNotFound) {
if (
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion packages/jest-snapshot/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -511,7 +511,7 @@ const _toThrowErrorMatchingSnapshot = (
} else {
try {
received();
} catch (e: unknown) {
} catch (e) {
error = e;
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/jest-types/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"chalk": "^4.0.0"
},
"devDependencies": {
"@tsd/typescript": "~4.1.5",
"@tsd/typescript": "~4.5.5",
"tsd-lite": "^0.5.1"
},
"publishConfig": {
Expand Down
12 changes: 6 additions & 6 deletions scripts/verifyOldTs.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,25 +16,25 @@ 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 = '3.8';
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',
});
Expand Down
Loading