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 committed 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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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

0 comments on commit 4a59daa

Please sign in to comment.