Skip to content

Commit 4a59daa

Browse files
authored
chore: use import type (#9693)
1 parent 244f7dc commit 4a59daa

File tree

220 files changed

+430
-419
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

220 files changed

+430
-419
lines changed

TestUtils.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@
55
* LICENSE file in the root directory of this source tree.
66
*/
77

8-
// eslint-disable-next-line import/no-extraneous-dependencies
9-
import {Config} from '@jest/types';
8+
import type {Config} from '@jest/types';
109

1110
const DEFAULT_GLOBAL_CONFIG: Config.GlobalConfig = {
1211
bail: 0,

e2e/Utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
import * as fs from 'fs';
99
import * as path from 'path';
10-
import {Config} from '@jest/types';
10+
import type {Config} from '@jest/types';
1111

1212
// eslint-disable-next-line import/named
1313
import {ExecaReturnValue, sync as spawnSync} from 'execa';

e2e/babel-plugin-jest-hoist/entry.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@
55
* LICENSE file in the root directory of this source tree.
66
*/
77

8-
import {Color} from './types';
8+
import type {Color} from './types';
99

1010
export const color: Color = 'red';

e2e/runJest.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import * as path from 'path';
1010
import * as fs from 'fs';
1111
import {Writable} from 'stream';
1212
import execa = require('execa');
13-
import {FormattedTestResults} from '@jest/test-result';
13+
import type {FormattedTestResults} from '@jest/test-result';
1414
import stripAnsi = require('strip-ansi');
1515
import {normalizeIcons} from './Utils';
1616

packages/babel-jest/src/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
import {createHash} from 'crypto';
99
import * as fs from 'fs';
1010
import * as path from 'path';
11-
import {Transformer} from '@jest/transform';
12-
import {Config} from '@jest/types';
11+
import type {Transformer} from '@jest/transform';
12+
import type {Config} from '@jest/types';
1313
import {
1414
PartialConfig,
1515
TransformOptions,

packages/babel-plugin-jest-hoist/src/index.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,8 @@
66
*
77
*/
88

9-
// Only used for types
10-
/* eslint-disable import/no-extraneous-dependencies */
11-
import {NodePath, Visitor} from '@babel/traverse';
12-
import {Identifier} from '@babel/types';
13-
/* eslint-enable */
9+
import type {NodePath, Visitor} from '@babel/traverse';
10+
import type {Identifier} from '@babel/types';
1411

1512
// We allow `jest`, `expect`, `require`, all default Node.js globals and all
1613
// ES2015 built-ins to be used inside of a `jest.mock` factory.

packages/expect/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*/
88

99
import * as matcherUtils from 'jest-matcher-utils';
10-
import {
10+
import type {
1111
AsyncExpectationResult,
1212
Expect,
1313
ExpectationResult,

packages/expect/src/jasmineUtils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
2424

2525
/* eslint-disable */
2626

27-
import {Tester} from './types';
27+
import type {Tester} from './types';
2828

2929
// Extracted out of jasmine 2.5.2
3030
export function equals(

packages/expect/src/jestMatchersObject.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*/
88

99
import {AsymmetricMatcher} from './asymmetricMatchers';
10-
import {Expect, MatchersObject, SyncExpectationResult} from './types';
10+
import type {Expect, MatchersObject, SyncExpectationResult} from './types';
1111

1212
// Global matchers object holds the list of available matchers and
1313
// the state, that can hold matcher specific values that change over time.

packages/expect/src/matchers.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import {
2525
printWithType,
2626
stringify,
2727
} from 'jest-matcher-utils';
28-
import {MatcherState, MatchersObject} from './types';
28+
import type {MatcherState, MatchersObject} from './types';
2929
import {
3030
printCloseTo,
3131
printExpectedConstructorName,

packages/expect/src/spyMatchers.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,11 @@ import {
2121
printWithType,
2222
stringify,
2323
} from 'jest-matcher-utils';
24-
import {MatcherState, MatchersObject, SyncExpectationResult} from './types';
24+
import type {
25+
MatcherState,
26+
MatchersObject,
27+
SyncExpectationResult,
28+
} from './types';
2529
import {equals} from './jasmineUtils';
2630
import {iterableEquality} from './utils';
2731

packages/expect/src/toThrowMatchers.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import {
2626
printReceivedStringContainExpectedResult,
2727
printReceivedStringContainExpectedSubstring,
2828
} from './print';
29-
import {
29+
import type {
3030
ExpectationResult,
3131
MatcherState,
3232
MatchersObject,

packages/expect/src/types.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
* LICENSE file in the root directory of this source tree.
66
*
77
*/
8-
import {Config} from '@jest/types';
9-
import * as jestMatcherUtils from 'jest-matcher-utils';
8+
import type {Config} from '@jest/types';
9+
import type * as jestMatcherUtils from 'jest-matcher-utils';
1010
import {INTERNAL_MATCHER_FLAG} from './jestMatchersObject';
1111

1212
export type SyncExpectationResult = {

packages/jest-changed-files/src/git.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88

99
import * as path from 'path';
1010
import execa = require('execa');
11-
import {Config} from '@jest/types';
11+
import type {Config} from '@jest/types';
1212

13-
import {SCMAdapter} from './types';
13+
import type {SCMAdapter} from './types';
1414

1515
const findChangedFilesUsingCommand = async (
1616
args: Array<string>,

packages/jest-changed-files/src/hg.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88

99
import * as path from 'path';
1010
import execa = require('execa');
11-
import {Config} from '@jest/types';
11+
import type {Config} from '@jest/types';
1212

13-
import {SCMAdapter} from './types';
13+
import type {SCMAdapter} from './types';
1414

1515
const env = {...process.env, HGPLAIN: '1'};
1616

packages/jest-changed-files/src/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,15 @@
77
*/
88

99
import throat from 'throat';
10-
import {Config} from '@jest/types';
10+
import type {Config} from '@jest/types';
1111

12-
import {ChangedFilesPromise, Options, Repos, SCMAdapter} from './types';
12+
import type {ChangedFilesPromise, Options, Repos, SCMAdapter} from './types';
1313
import git from './git';
1414
import hg from './hg';
1515

1616
type RootPromise = ReturnType<SCMAdapter['getRoot']>;
1717

18-
export {ChangedFiles, ChangedFilesPromise} from './types';
18+
export type {ChangedFiles, ChangedFilesPromise} from './types';
1919

2020
function notEmpty<T>(value: T | null | undefined): value is T {
2121
return value != null;

packages/jest-changed-files/src/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* LICENSE file in the root directory of this source tree.
66
*/
77

8-
import {Config} from '@jest/types';
8+
import type {Config} from '@jest/types';
99

1010
export type Options = {
1111
lastCommit?: boolean;

packages/jest-circus/src/__tests__/circusItTestError.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* LICENSE file in the root directory of this source tree.
66
*/
77

8-
import {Global} from '@jest/types';
8+
import type {Global} from '@jest/types';
99

1010
let circusIt: Global.It;
1111
let circusTest: Global.It;

packages/jest-circus/src/__tests__/circusItTodoTestError.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* LICENSE file in the root directory of this source tree.
66
*/
77

8-
import {Global} from '@jest/types';
8+
import type {Global} from '@jest/types';
99

1010
let circusIt: Global.It;
1111

packages/jest-circus/src/eventHandler.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* LICENSE file in the root directory of this source tree.
66
*/
77

8-
import {Circus} from '@jest/types';
8+
import type {Circus} from '@jest/types';
99
import {TEST_TIMEOUT_SYMBOL} from './types';
1010

1111
import {

packages/jest-circus/src/formatNodeAssertErrors.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*/
77

88
import {AssertionError} from 'assert';
9-
import {Circus} from '@jest/types';
9+
import type {Circus} from '@jest/types';
1010
import {
1111
DiffOptions,
1212
diff,

packages/jest-circus/src/globalErrorHandlers.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* LICENSE file in the root directory of this source tree.
66
*/
77

8-
import {Circus} from '@jest/types';
8+
import type {Circus} from '@jest/types';
99
import {dispatch} from './state';
1010

1111
const uncaught: NodeJS.UncaughtExceptionListener &

packages/jest-circus/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import chalk = require('chalk');
99
import {bind as bindEach} from 'jest-each';
1010
import {formatExecError} from 'jest-message-util';
1111
import {ErrorWithStack, isPromise} from 'jest-util';
12-
import {Circus, Global} from '@jest/types';
12+
import type {Circus, Global} from '@jest/types';
1313
import {dispatch} from './state';
1414

1515
type THook = (fn: Circus.HookFn, timeout?: number) => void;

packages/jest-circus/src/legacy-code-todo-rewrite/jestAdapter.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@
66
*/
77

88
import * as path from 'path';
9-
import {Config} from '@jest/types';
10-
import {JestEnvironment} from '@jest/environment';
11-
import {TestResult} from '@jest/test-result';
9+
import type {Config} from '@jest/types';
10+
import type {JestEnvironment} from '@jest/environment';
11+
import type {TestResult} from '@jest/test-result';
1212
import Runtime = require('jest-runtime');
13-
import {SnapshotStateType} from 'jest-snapshot';
13+
import type {SnapshotStateType} from 'jest-snapshot';
1414

1515
const FRAMEWORK_INITIALIZER = require.resolve('./jestAdapterInit');
1616

packages/jest-circus/src/legacy-code-todo-rewrite/jestAdapterInit.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
* LICENSE file in the root directory of this source tree.
66
*/
77

8-
import {Circus, Config, Global} from '@jest/types';
9-
import {JestEnvironment} from '@jest/environment';
8+
import type {Circus, Config, Global} from '@jest/types';
9+
import type {JestEnvironment} from '@jest/environment';
1010
import {
1111
AssertionResult,
1212
Status,

packages/jest-circus/src/run.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* LICENSE file in the root directory of this source tree.
66
*/
77

8-
import {Circus} from '@jest/types';
8+
import type {Circus} from '@jest/types';
99
import {RETRY_TIMES} from './types';
1010

1111
import {dispatch, getState} from './state';

packages/jest-circus/src/state.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* LICENSE file in the root directory of this source tree.
66
*/
77

8-
import {Circus} from '@jest/types';
8+
import type {Circus} from '@jest/types';
99
import {STATE_SYM} from './types';
1010

1111
import {makeDescribe} from './utils';

packages/jest-circus/src/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
// eslint-disable-next-line @typescript-eslint/no-unused-vars
1010
import expect = require('expect');
1111
// eslint-disable-next-line @typescript-eslint/no-unused-vars
12-
import {Circus} from '@jest/types';
12+
import type {Circus} from '@jest/types';
1313

1414
export const STATE_SYM = (Symbol(
1515
'JEST_STATE_SYMBOL',

packages/jest-circus/src/utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* LICENSE file in the root directory of this source tree.
66
*/
77

8-
import {Circus} from '@jest/types';
8+
import type {Circus} from '@jest/types';
99
import {convertDescriptorToString} from 'jest-util';
1010
import isGeneratorFn from 'is-generator-fn';
1111
import co from 'co';

packages/jest-cli/src/__tests__/cli/args.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*
77
*/
88

9-
import {Config} from '@jest/types';
9+
import type {Config} from '@jest/types';
1010
import {constants} from 'jest-config';
1111
import {check} from '../../cli/args';
1212
import {buildArgv} from '../../cli';

packages/jest-cli/src/cli/args.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* LICENSE file in the root directory of this source tree.
66
*/
77

8-
import {Config} from '@jest/types';
8+
import type {Config} from '@jest/types';
99
import {constants, isJSONString} from 'jest-config';
1010
import isCI = require('is-ci');
1111

packages/jest-cli/src/cli/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
*/
77

88
import * as path from 'path';
9-
import {Config} from '@jest/types';
10-
import {AggregatedResult} from '@jest/test-result';
9+
import type {Config} from '@jest/types';
10+
import type {AggregatedResult} from '@jest/test-result';
1111
import {clearLine} from 'jest-util';
1212
import {validateCLIOptions} from 'jest-validate';
1313
import {deprecationEntries} from 'jest-config';

packages/jest-cli/src/init/generate_config_file.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* LICENSE file in the root directory of this source tree.
66
*/
77

8-
import {Config} from '@jest/types';
8+
import type {Config} from '@jest/types';
99
import {defaults, descriptions} from 'jest-config';
1010

1111
const stringifyOption = (

packages/jest-cli/src/init/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import defaultQuestions, {testScriptQuestion} from './questions';
1515
import {MalformedPackageJsonError, NotFoundPackageJsonError} from './errors';
1616
import generateConfigFile from './generate_config_file';
1717
import modifyPackageJson from './modify_package_json';
18-
import {ProjectPackageJson} from './types';
18+
import type {ProjectPackageJson} from './types';
1919

2020
const {
2121
JEST_CONFIG_BASE_NAME,

packages/jest-cli/src/init/modify_package_json.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* LICENSE file in the root directory of this source tree.
66
*/
77

8-
import {ProjectPackageJson} from './types';
8+
import type {ProjectPackageJson} from './types';
99

1010
const modifyPackageJson = ({
1111
projectPackageJson,

packages/jest-cli/src/init/questions.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* LICENSE file in the root directory of this source tree.
66
*/
77

8-
import {PromptObject} from 'prompts';
8+
import type {PromptObject} from 'prompts';
99

1010
const defaultQuestions: Array<PromptObject> = [
1111
{

packages/jest-cli/src/init/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* LICENSE file in the root directory of this source tree.
66
*/
77

8-
import {Config} from '@jest/types';
8+
import type {Config} from '@jest/types';
99

1010
export type ProjectPackageJson = {
1111
jest?: Partial<Config.InitialOptions>;

packages/jest-config/src/Defaults.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* LICENSE file in the root directory of this source tree.
66
*/
77

8-
import {Config} from '@jest/types';
8+
import type {Config} from '@jest/types';
99
import {replacePathSepForRegex} from 'jest-regex-util';
1010
import {NODE_MODULES} from './constants';
1111
import getCacheDirectory from './getCacheDirectory';

packages/jest-config/src/Descriptions.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* LICENSE file in the root directory of this source tree.
66
*/
77

8-
import {Config} from '@jest/types';
8+
import type {Config} from '@jest/types';
99

1010
const descriptions: {[key in keyof Config.InitialOptions]: string} = {
1111
automock: 'All imported modules in your tests should be mocked automatically',

packages/jest-config/src/ReporterValidationErrors.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* LICENSE file in the root directory of this source tree.
66
*/
77

8-
import {Config} from '@jest/types';
8+
import type {Config} from '@jest/types';
99
import {ValidationError} from 'jest-validate';
1010
import chalk = require('chalk');
1111
import getType = require('jest-get-type');

0 commit comments

Comments
 (0)