Skip to content

Commit

Permalink
chore: use import type (#9693)
Browse files Browse the repository at this point in the history
  • Loading branch information
SimenB authored Mar 23, 2020
1 parent 244f7dc commit 4a59daa
Show file tree
Hide file tree
Showing 220 changed files with 430 additions and 419 deletions.
3 changes: 1 addition & 2 deletions TestUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
* LICENSE file in the root directory of this source tree.
*/

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

const DEFAULT_GLOBAL_CONFIG: Config.GlobalConfig = {
bail: 0,
Expand Down
2 changes: 1 addition & 1 deletion e2e/Utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import * as fs from 'fs';
import * as path from 'path';
import {Config} from '@jest/types';
import type {Config} from '@jest/types';

// eslint-disable-next-line import/named
import {ExecaReturnValue, sync as spawnSync} from 'execa';
Expand Down
2 changes: 1 addition & 1 deletion e2e/babel-plugin-jest-hoist/entry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
* LICENSE file in the root directory of this source tree.
*/

import {Color} from './types';
import type {Color} from './types';

export const color: Color = 'red';
2 changes: 1 addition & 1 deletion e2e/runJest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import * as path from 'path';
import * as fs from 'fs';
import {Writable} from 'stream';
import execa = require('execa');
import {FormattedTestResults} from '@jest/test-result';
import type {FormattedTestResults} from '@jest/test-result';
import stripAnsi = require('strip-ansi');
import {normalizeIcons} from './Utils';

Expand Down
4 changes: 2 additions & 2 deletions packages/babel-jest/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
import {createHash} from 'crypto';
import * as fs from 'fs';
import * as path from 'path';
import {Transformer} from '@jest/transform';
import {Config} from '@jest/types';
import type {Transformer} from '@jest/transform';
import type {Config} from '@jest/types';
import {
PartialConfig,
TransformOptions,
Expand Down
7 changes: 2 additions & 5 deletions packages/babel-plugin-jest-hoist/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,8 @@
*
*/

// Only used for types
/* eslint-disable import/no-extraneous-dependencies */
import {NodePath, Visitor} from '@babel/traverse';
import {Identifier} from '@babel/types';
/* eslint-enable */
import type {NodePath, Visitor} from '@babel/traverse';
import type {Identifier} from '@babel/types';

// We allow `jest`, `expect`, `require`, all default Node.js globals and all
// ES2015 built-ins to be used inside of a `jest.mock` factory.
Expand Down
2 changes: 1 addition & 1 deletion packages/expect/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*/

import * as matcherUtils from 'jest-matcher-utils';
import {
import type {
AsyncExpectationResult,
Expect,
ExpectationResult,
Expand Down
2 changes: 1 addition & 1 deletion packages/expect/src/jasmineUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

/* eslint-disable */

import {Tester} from './types';
import type {Tester} from './types';

// Extracted out of jasmine 2.5.2
export function equals(
Expand Down
2 changes: 1 addition & 1 deletion packages/expect/src/jestMatchersObject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*/

import {AsymmetricMatcher} from './asymmetricMatchers';
import {Expect, MatchersObject, SyncExpectationResult} from './types';
import type {Expect, MatchersObject, SyncExpectationResult} from './types';

// Global matchers object holds the list of available matchers and
// the state, that can hold matcher specific values that change over time.
Expand Down
2 changes: 1 addition & 1 deletion packages/expect/src/matchers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import {
printWithType,
stringify,
} from 'jest-matcher-utils';
import {MatcherState, MatchersObject} from './types';
import type {MatcherState, MatchersObject} from './types';
import {
printCloseTo,
printExpectedConstructorName,
Expand Down
6 changes: 5 additions & 1 deletion packages/expect/src/spyMatchers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,11 @@ import {
printWithType,
stringify,
} from 'jest-matcher-utils';
import {MatcherState, MatchersObject, SyncExpectationResult} from './types';
import type {
MatcherState,
MatchersObject,
SyncExpectationResult,
} from './types';
import {equals} from './jasmineUtils';
import {iterableEquality} from './utils';

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 @@ -26,7 +26,7 @@ import {
printReceivedStringContainExpectedResult,
printReceivedStringContainExpectedSubstring,
} from './print';
import {
import type {
ExpectationResult,
MatcherState,
MatchersObject,
Expand Down
4 changes: 2 additions & 2 deletions packages/expect/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
* LICENSE file in the root directory of this source tree.
*
*/
import {Config} from '@jest/types';
import * as jestMatcherUtils from 'jest-matcher-utils';
import type {Config} from '@jest/types';
import type * as jestMatcherUtils from 'jest-matcher-utils';
import {INTERNAL_MATCHER_FLAG} from './jestMatchersObject';

export type SyncExpectationResult = {
Expand Down
4 changes: 2 additions & 2 deletions packages/jest-changed-files/src/git.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@

import * as path from 'path';
import execa = require('execa');
import {Config} from '@jest/types';
import type {Config} from '@jest/types';

import {SCMAdapter} from './types';
import type {SCMAdapter} from './types';

const findChangedFilesUsingCommand = async (
args: Array<string>,
Expand Down
4 changes: 2 additions & 2 deletions packages/jest-changed-files/src/hg.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@

import * as path from 'path';
import execa = require('execa');
import {Config} from '@jest/types';
import type {Config} from '@jest/types';

import {SCMAdapter} from './types';
import type {SCMAdapter} from './types';

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

Expand Down
6 changes: 3 additions & 3 deletions packages/jest-changed-files/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@
*/

import throat from 'throat';
import {Config} from '@jest/types';
import type {Config} from '@jest/types';

import {ChangedFilesPromise, Options, Repos, SCMAdapter} from './types';
import type {ChangedFilesPromise, Options, Repos, SCMAdapter} from './types';
import git from './git';
import hg from './hg';

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

export {ChangedFiles, ChangedFilesPromise} from './types';
export type {ChangedFiles, ChangedFilesPromise} from './types';

function notEmpty<T>(value: T | null | undefined): value is T {
return value != null;
Expand Down
2 changes: 1 addition & 1 deletion packages/jest-changed-files/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 {Config} from '@jest/types';
import type {Config} from '@jest/types';

export type Options = {
lastCommit?: boolean;
Expand Down
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 {Global} from '@jest/types';
import type {Global} from '@jest/types';

let circusIt: Global.It;
let circusTest: Global.It;
Expand Down
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 {Global} from '@jest/types';
import type {Global} from '@jest/types';

let circusIt: Global.It;

Expand Down
2 changes: 1 addition & 1 deletion packages/jest-circus/src/eventHandler.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 {Circus} from '@jest/types';
import type {Circus} from '@jest/types';
import {TEST_TIMEOUT_SYMBOL} from './types';

import {
Expand Down
2 changes: 1 addition & 1 deletion packages/jest-circus/src/formatNodeAssertErrors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/

import {AssertionError} from 'assert';
import {Circus} from '@jest/types';
import type {Circus} from '@jest/types';
import {
DiffOptions,
diff,
Expand Down
2 changes: 1 addition & 1 deletion packages/jest-circus/src/globalErrorHandlers.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 {Circus} from '@jest/types';
import type {Circus} from '@jest/types';
import {dispatch} from './state';

const uncaught: NodeJS.UncaughtExceptionListener &
Expand Down
2 changes: 1 addition & 1 deletion packages/jest-circus/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import chalk = require('chalk');
import {bind as bindEach} from 'jest-each';
import {formatExecError} from 'jest-message-util';
import {ErrorWithStack, isPromise} from 'jest-util';
import {Circus, Global} from '@jest/types';
import type {Circus, Global} from '@jest/types';
import {dispatch} from './state';

type THook = (fn: Circus.HookFn, timeout?: number) => void;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
*/

import * as path from 'path';
import {Config} from '@jest/types';
import {JestEnvironment} from '@jest/environment';
import {TestResult} from '@jest/test-result';
import type {Config} from '@jest/types';
import type {JestEnvironment} from '@jest/environment';
import type {TestResult} from '@jest/test-result';
import Runtime = require('jest-runtime');
import {SnapshotStateType} from 'jest-snapshot';
import type {SnapshotStateType} from 'jest-snapshot';

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
* LICENSE file in the root directory of this source tree.
*/

import {Circus, Config, Global} from '@jest/types';
import {JestEnvironment} from '@jest/environment';
import type {Circus, Config, Global} from '@jest/types';
import type {JestEnvironment} from '@jest/environment';
import {
AssertionResult,
Status,
Expand Down
2 changes: 1 addition & 1 deletion packages/jest-circus/src/run.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 {Circus} from '@jest/types';
import type {Circus} from '@jest/types';
import {RETRY_TIMES} from './types';

import {dispatch, getState} from './state';
Expand Down
2 changes: 1 addition & 1 deletion packages/jest-circus/src/state.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 {Circus} from '@jest/types';
import type {Circus} from '@jest/types';
import {STATE_SYM} from './types';

import {makeDescribe} from './utils';
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 @@ -9,7 +9,7 @@
// eslint-disable-next-line @typescript-eslint/no-unused-vars
import expect = require('expect');
// eslint-disable-next-line @typescript-eslint/no-unused-vars
import {Circus} from '@jest/types';
import type {Circus} from '@jest/types';

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 @@ -5,7 +5,7 @@
* LICENSE file in the root directory of this source tree.
*/

import {Circus} from '@jest/types';
import type {Circus} from '@jest/types';
import {convertDescriptorToString} from 'jest-util';
import isGeneratorFn from 'is-generator-fn';
import co from 'co';
Expand Down
2 changes: 1 addition & 1 deletion packages/jest-cli/src/__tests__/cli/args.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*
*/

import {Config} from '@jest/types';
import type {Config} from '@jest/types';
import {constants} from 'jest-config';
import {check} from '../../cli/args';
import {buildArgv} from '../../cli';
Expand Down
2 changes: 1 addition & 1 deletion packages/jest-cli/src/cli/args.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 {Config} from '@jest/types';
import type {Config} from '@jest/types';
import {constants, isJSONString} from 'jest-config';
import isCI = require('is-ci');

Expand Down
4 changes: 2 additions & 2 deletions packages/jest-cli/src/cli/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
*/

import * as path from 'path';
import {Config} from '@jest/types';
import {AggregatedResult} from '@jest/test-result';
import type {Config} from '@jest/types';
import type {AggregatedResult} from '@jest/test-result';
import {clearLine} from 'jest-util';
import {validateCLIOptions} from 'jest-validate';
import {deprecationEntries} from 'jest-config';
Expand Down
2 changes: 1 addition & 1 deletion packages/jest-cli/src/init/generate_config_file.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 {Config} from '@jest/types';
import type {Config} from '@jest/types';
import {defaults, descriptions} from 'jest-config';

const stringifyOption = (
Expand Down
2 changes: 1 addition & 1 deletion packages/jest-cli/src/init/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import defaultQuestions, {testScriptQuestion} from './questions';
import {MalformedPackageJsonError, NotFoundPackageJsonError} from './errors';
import generateConfigFile from './generate_config_file';
import modifyPackageJson from './modify_package_json';
import {ProjectPackageJson} from './types';
import type {ProjectPackageJson} from './types';

const {
JEST_CONFIG_BASE_NAME,
Expand Down
2 changes: 1 addition & 1 deletion packages/jest-cli/src/init/modify_package_json.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 {ProjectPackageJson} from './types';
import type {ProjectPackageJson} from './types';

const modifyPackageJson = ({
projectPackageJson,
Expand Down
2 changes: 1 addition & 1 deletion packages/jest-cli/src/init/questions.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 {PromptObject} from 'prompts';
import type {PromptObject} from 'prompts';

const defaultQuestions: Array<PromptObject> = [
{
Expand Down
2 changes: 1 addition & 1 deletion packages/jest-cli/src/init/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 {Config} from '@jest/types';
import type {Config} from '@jest/types';

export type ProjectPackageJson = {
jest?: Partial<Config.InitialOptions>;
Expand Down
2 changes: 1 addition & 1 deletion packages/jest-config/src/Defaults.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 {Config} from '@jest/types';
import type {Config} from '@jest/types';
import {replacePathSepForRegex} from 'jest-regex-util';
import {NODE_MODULES} from './constants';
import getCacheDirectory from './getCacheDirectory';
Expand Down
2 changes: 1 addition & 1 deletion packages/jest-config/src/Descriptions.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 {Config} from '@jest/types';
import type {Config} from '@jest/types';

const descriptions: {[key in keyof Config.InitialOptions]: string} = {
automock: 'All imported modules in your tests should be mocked automatically',
Expand Down
2 changes: 1 addition & 1 deletion packages/jest-config/src/ReporterValidationErrors.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 {Config} from '@jest/types';
import type {Config} from '@jest/types';
import {ValidationError} from 'jest-validate';
import chalk = require('chalk');
import getType = require('jest-get-type');
Expand Down
Loading

0 comments on commit 4a59daa

Please sign in to comment.