mirror of https://github.com/facebook/jest.git
chore: use consistent type imports (#14662)
This commit is contained in:
parent
79a4ff4985
commit
5ce83ac4bc
|
@ -46,6 +46,11 @@ module.exports = {
|
|||
rules: {
|
||||
'@typescript-eslint/array-type': ['error', {default: 'generic'}],
|
||||
'@typescript-eslint/ban-types': 'error',
|
||||
'@typescript-eslint/consistent-type-imports': [
|
||||
'error',
|
||||
{fixStyle: 'inline-type-imports', disallowTypeAnnotations: false},
|
||||
],
|
||||
'@typescript-eslint/no-import-type-side-effects': 'error',
|
||||
'@typescript-eslint/no-inferrable-types': 'error',
|
||||
'@typescript-eslint/no-unused-vars': [
|
||||
'error',
|
||||
|
@ -278,6 +283,16 @@ module.exports = {
|
|||
'no-restricted-imports': 'off',
|
||||
},
|
||||
},
|
||||
{
|
||||
files: ['examples/angular/**/*'],
|
||||
rules: {
|
||||
// Angular DI for some reason doesn't work with type imports
|
||||
'@typescript-eslint/consistent-type-imports': [
|
||||
'error',
|
||||
{prefer: 'no-type-imports', disallowTypeAnnotations: false},
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
files: 'packages/**/*.ts',
|
||||
rules: {
|
||||
|
@ -416,6 +431,7 @@ module.exports = {
|
|||
'handle-callback-err': 'off',
|
||||
'id-length': 'off',
|
||||
'id-match': 'off',
|
||||
'import/no-duplicates': 'error',
|
||||
'import/no-extraneous-dependencies': [
|
||||
'error',
|
||||
{
|
||||
|
|
|
@ -736,7 +736,7 @@ export function setDateNow(now: number): jest.Spied<typeof Date.now> {
|
|||
```
|
||||
|
||||
```ts
|
||||
import {afterEach, expect, jest, test} from '@jest/globals';
|
||||
import {afterEach, expect, type jest, test} from '@jest/globals';
|
||||
import {setDateNow} from './__utils__/setDateNow';
|
||||
|
||||
let spiedDateNow: jest.Spied<typeof Date.now> | undefined = undefined;
|
||||
|
|
|
@ -9,9 +9,9 @@ import * as path from 'path';
|
|||
import * as util from 'util';
|
||||
import dedent from 'dedent';
|
||||
import {
|
||||
ExecaSyncError,
|
||||
SyncOptions as ExecaSyncOptions,
|
||||
ExecaSyncReturnValue,
|
||||
type ExecaSyncError,
|
||||
type SyncOptions as ExecaSyncOptions,
|
||||
type ExecaSyncReturnValue,
|
||||
sync as spawnSync,
|
||||
} from 'execa';
|
||||
import * as fs from 'graceful-fs';
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
import runJest, {RunJestResult} from '../runJest';
|
||||
import runJest, {type RunJestResult} from '../runJest';
|
||||
|
||||
const getLog = (result: RunJestResult) => result.stdout.split('\n')[1].trim();
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
import * as path from 'path';
|
||||
import {skipSuiteOnJasmine} from '@jest/test-utils';
|
||||
import {extractSummary} from '../Utils';
|
||||
import runJest, {RunJestResult} from '../runJest';
|
||||
import runJest, {type RunJestResult} from '../runJest';
|
||||
|
||||
skipSuiteOnJasmine();
|
||||
|
||||
|
|
|
@ -7,8 +7,8 @@
|
|||
|
||||
import {resolve} from 'path';
|
||||
import run, {
|
||||
RunJestJsonResult,
|
||||
RunJestResult,
|
||||
type RunJestJsonResult,
|
||||
type RunJestResult,
|
||||
json as runWithJson,
|
||||
} from '../runJest';
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
import {tmpdir} from 'os';
|
||||
import * as path from 'path';
|
||||
import {
|
||||
PackageJson,
|
||||
type PackageJson,
|
||||
cleanup,
|
||||
createEmptyPackage,
|
||||
runYarnInstall,
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
*
|
||||
*/
|
||||
|
||||
/* eslint-disable no-duplicate-imports */
|
||||
/* eslint-disable no-duplicate-imports, import/no-duplicates */
|
||||
import {jest} from '@jest/globals';
|
||||
import {jest as aliasedJest} from '@jest/globals';
|
||||
import * as JestGlobals from '@jest/globals';
|
||||
|
|
|
@ -18,9 +18,11 @@ import staticImportedStatefulFromCjs from '../fromCjs.mjs';
|
|||
import {double} from '../index';
|
||||
import defaultFromCjs, {half, namedFunction} from '../namedExport.cjs';
|
||||
import {bag} from '../namespaceExport.js';
|
||||
/* eslint-disable import/no-duplicates */
|
||||
import staticImportedStateful from '../stateful.mjs';
|
||||
import staticImportedStatefulWithQuery from '../stateful.mjs?query=1';
|
||||
import staticImportedStatefulWithAnotherQuery from '../stateful.mjs?query=2';
|
||||
/* eslint-enable */
|
||||
|
||||
test('should have correct import.meta', () => {
|
||||
expect(typeof require).toBe('undefined');
|
||||
|
|
|
@ -6,7 +6,11 @@
|
|||
*/
|
||||
|
||||
import pLimit from 'p-limit';
|
||||
import {Test, TestResult, createEmptyTestResult} from '@jest/test-result';
|
||||
import {
|
||||
type Test,
|
||||
type TestResult,
|
||||
createEmptyTestResult,
|
||||
} from '@jest/test-result';
|
||||
import type {Config} from '@jest/types';
|
||||
import type {
|
||||
OnTestFailure,
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
import {SnapshotResolver} from 'jest-snapshot';
|
||||
import type {SnapshotResolver} from 'jest-snapshot';
|
||||
|
||||
const snapshotResolver: SnapshotResolver = {
|
||||
resolveSnapshotPath: (testPath, snapshotExtension) =>
|
||||
|
|
|
@ -4,10 +4,10 @@
|
|||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
import {JestEnvironment} from '@jest/environment';
|
||||
import {TestResult, createEmptyTestResult} from '@jest/test-result';
|
||||
import {Config} from '@jest/types';
|
||||
import Runtime from 'jest-runtime';
|
||||
import type {JestEnvironment} from '@jest/environment';
|
||||
import {type TestResult, createEmptyTestResult} from '@jest/test-result';
|
||||
import type {Config} from '@jest/types';
|
||||
import type Runtime from 'jest-runtime';
|
||||
|
||||
export default async function testRunner(
|
||||
globalConfig: Config.GlobalConfig,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import Memory from './Memory';
|
||||
import type Memory from './Memory';
|
||||
import sub from './sub';
|
||||
import sum from './sum';
|
||||
|
||||
|
|
|
@ -8,8 +8,8 @@
|
|||
import {createHash} from 'crypto';
|
||||
import * as path from 'path';
|
||||
import {
|
||||
PartialConfig,
|
||||
TransformOptions,
|
||||
type PartialConfig,
|
||||
type TransformOptions,
|
||||
transformSync as babelTransform,
|
||||
transformAsync as babelTransformAsync,
|
||||
} from '@babel/core';
|
||||
|
|
|
@ -10,17 +10,17 @@ import type {PluginObj} from '@babel/core';
|
|||
import {statement} from '@babel/template';
|
||||
import type {NodePath} from '@babel/traverse';
|
||||
import {
|
||||
BlockStatement,
|
||||
CallExpression,
|
||||
Expression,
|
||||
Identifier,
|
||||
ImportDeclaration,
|
||||
MemberExpression,
|
||||
Node,
|
||||
Program,
|
||||
Super,
|
||||
VariableDeclaration,
|
||||
VariableDeclarator,
|
||||
type BlockStatement,
|
||||
type CallExpression,
|
||||
type Expression,
|
||||
type Identifier,
|
||||
type ImportDeclaration,
|
||||
type MemberExpression,
|
||||
type Node,
|
||||
type Program,
|
||||
type Super,
|
||||
type VariableDeclaration,
|
||||
type VariableDeclarator,
|
||||
callExpression,
|
||||
emptyStatement,
|
||||
isIdentifier,
|
||||
|
|
|
@ -8,12 +8,12 @@
|
|||
import {expectAssignable, expectError, expectType} from 'tsd-lite';
|
||||
import type {EqualsFunction} from '@jest/expect-utils';
|
||||
import {
|
||||
MatcherContext,
|
||||
MatcherFunction,
|
||||
MatcherFunctionWithContext,
|
||||
Matchers,
|
||||
Tester,
|
||||
TesterContext,
|
||||
type MatcherContext,
|
||||
type MatcherFunction,
|
||||
type MatcherFunctionWithContext,
|
||||
type Matchers,
|
||||
type Tester,
|
||||
type TesterContext,
|
||||
expect,
|
||||
} from 'expect';
|
||||
import type * as jestMatcherUtils from 'jest-matcher-utils';
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
*
|
||||
*/
|
||||
|
||||
import {Tester, equals} from '@jest/expect-utils';
|
||||
import {type Tester, equals} from '@jest/expect-utils';
|
||||
import jestExpect from '../';
|
||||
|
||||
// Test test file demonstrates and tests the capability of recursive custom
|
||||
|
|
|
@ -23,7 +23,7 @@ import {getType, isPrimitive} from 'jest-get-type';
|
|||
import {
|
||||
DIM_COLOR,
|
||||
EXPECTED_COLOR,
|
||||
MatcherHintOptions,
|
||||
type MatcherHintOptions,
|
||||
RECEIVED_COLOR,
|
||||
SUGGEST_TO_CONTAIN_EQUAL,
|
||||
ensureExpectedIsNonNegativeInteger,
|
||||
|
|
|
@ -10,7 +10,7 @@ import {getType, isPrimitive} from 'jest-get-type';
|
|||
import {
|
||||
DIM_COLOR,
|
||||
EXPECTED_COLOR,
|
||||
MatcherHintOptions,
|
||||
type MatcherHintOptions,
|
||||
RECEIVED_COLOR,
|
||||
diff,
|
||||
ensureExpectedIsNonNegativeInteger,
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
import {isError} from '@jest/expect-utils';
|
||||
import {
|
||||
EXPECTED_COLOR,
|
||||
MatcherHintOptions,
|
||||
type MatcherHintOptions,
|
||||
RECEIVED_COLOR,
|
||||
matcherErrorMessage,
|
||||
matcherHint,
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
import type {EqualsFunction, Tester} from '@jest/expect-utils';
|
||||
import type * as jestMatcherUtils from 'jest-matcher-utils';
|
||||
import {INTERNAL_MATCHER_FLAG} from './jestMatchersObject';
|
||||
import type {INTERNAL_MATCHER_FLAG} from './jestMatchersObject';
|
||||
|
||||
export type SyncExpectationResult = {
|
||||
pass: boolean;
|
||||
|
|
|
@ -9,7 +9,7 @@ import {AssertionError} from 'assert';
|
|||
import chalk = require('chalk');
|
||||
import type {Circus} from '@jest/types';
|
||||
import {
|
||||
DiffOptions,
|
||||
type DiffOptions,
|
||||
diff,
|
||||
printExpected,
|
||||
printReceived,
|
||||
|
|
|
@ -7,12 +7,12 @@
|
|||
|
||||
import type * as Process from 'process';
|
||||
import type {JestEnvironment} from '@jest/environment';
|
||||
import {JestExpect, jestExpect} from '@jest/expect';
|
||||
import {type JestExpect, jestExpect} from '@jest/expect';
|
||||
import {
|
||||
AssertionResult,
|
||||
Status,
|
||||
TestFileEvent,
|
||||
TestResult,
|
||||
type AssertionResult,
|
||||
type Status,
|
||||
type TestFileEvent,
|
||||
type TestResult,
|
||||
createEmptyTestResult,
|
||||
} from '@jest/test-result';
|
||||
import type {Circus, Config, Global} from '@jest/types';
|
||||
|
|
|
@ -10,7 +10,10 @@ import pLimit = require('p-limit');
|
|||
import {jestExpect} from '@jest/expect';
|
||||
import type {Circus, Global} from '@jest/types';
|
||||
import {invariant} from 'jest-util';
|
||||
import shuffleArray, {RandomNumberGenerator, rngBuilder} from './shuffleArray';
|
||||
import shuffleArray, {
|
||||
type RandomNumberGenerator,
|
||||
rngBuilder,
|
||||
} from './shuffleArray';
|
||||
import {dispatch, getState} from './state';
|
||||
import {RETRY_TIMES} from './types';
|
||||
import {
|
||||
|
|
|
@ -13,7 +13,7 @@ import type {Config} from '@jest/types';
|
|||
import {escapeStrForRegex} from 'jest-regex-util';
|
||||
import Defaults from '../Defaults';
|
||||
import {DEFAULT_JS_PATTERN} from '../constants';
|
||||
import normalize, {AllOptions} from '../normalize';
|
||||
import normalize, {type AllOptions} from '../normalize';
|
||||
|
||||
const DEFAULT_CSS_PATTERN = '\\.(css)$';
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
import {AssertionError, strict as assert} from 'assert';
|
||||
import {Console} from 'console';
|
||||
import {InspectOptions, format, formatWithOptions, inspect} from 'util';
|
||||
import {type InspectOptions, format, formatWithOptions, inspect} from 'util';
|
||||
import chalk = require('chalk');
|
||||
import {ErrorWithStack, formatTime, invariant} from 'jest-util';
|
||||
import type {
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
import {AssertionError, strict as assert} from 'assert';
|
||||
import {Console} from 'console';
|
||||
import type {WriteStream} from 'tty';
|
||||
import {InspectOptions, format, formatWithOptions, inspect} from 'util';
|
||||
import {type InspectOptions, format, formatWithOptions, inspect} from 'util';
|
||||
import chalk = require('chalk');
|
||||
import {clearLine, formatTime} from 'jest-util';
|
||||
import type {LogCounters, LogMessage, LogTimers, LogType} from './types';
|
||||
|
|
|
@ -8,8 +8,8 @@
|
|||
import chalk = require('chalk');
|
||||
import type {Config} from '@jest/types';
|
||||
import {
|
||||
StackTraceConfig,
|
||||
StackTraceOptions,
|
||||
type StackTraceConfig,
|
||||
type StackTraceOptions,
|
||||
formatStackTrace,
|
||||
} from 'jest-message-util';
|
||||
import type {ConsoleBuffer} from './types';
|
||||
|
|
|
@ -7,8 +7,8 @@
|
|||
|
||||
import {
|
||||
PatternPrompt,
|
||||
Prompt,
|
||||
ScrollOptions,
|
||||
type Prompt,
|
||||
type ScrollOptions,
|
||||
printPatternCaret,
|
||||
printRestoredPatternCaret,
|
||||
} from 'jest-watcher';
|
||||
|
|
|
@ -7,8 +7,8 @@
|
|||
|
||||
import {
|
||||
PatternPrompt,
|
||||
Prompt,
|
||||
ScrollOptions,
|
||||
type Prompt,
|
||||
type ScrollOptions,
|
||||
printPatternCaret,
|
||||
printRestoredPatternCaret,
|
||||
} from 'jest-watcher';
|
||||
|
|
|
@ -12,20 +12,20 @@ import {
|
|||
CoverageReporter,
|
||||
DefaultReporter,
|
||||
GitHubActionsReporter,
|
||||
BaseReporter as JestReporter,
|
||||
type BaseReporter as JestReporter,
|
||||
NotifyReporter,
|
||||
Reporter,
|
||||
ReporterContext,
|
||||
type Reporter,
|
||||
type ReporterContext,
|
||||
SummaryReporter,
|
||||
SummaryReporterOptions,
|
||||
type SummaryReporterOptions,
|
||||
VerboseReporter,
|
||||
} from '@jest/reporters';
|
||||
import {
|
||||
AggregatedResult,
|
||||
SerializableError,
|
||||
Test,
|
||||
TestContext,
|
||||
TestResult,
|
||||
type AggregatedResult,
|
||||
type SerializableError,
|
||||
type Test,
|
||||
type TestContext,
|
||||
type TestResult,
|
||||
addResult,
|
||||
buildFailureTestResult,
|
||||
makeEmptyAggregatedTestResult,
|
||||
|
|
|
@ -7,7 +7,10 @@
|
|||
|
||||
import chalk = require('chalk');
|
||||
import type {Config} from '@jest/types';
|
||||
import {ChangedFilesPromise, getChangedFilesForRoots} from 'jest-changed-files';
|
||||
import {
|
||||
type ChangedFilesPromise,
|
||||
getChangedFilesForRoots,
|
||||
} from 'jest-changed-files';
|
||||
import {formatExecError} from 'jest-message-util';
|
||||
|
||||
export default function getChangedFilesPromise(
|
||||
|
|
|
@ -9,9 +9,9 @@ import type {AggregatedResult, AssertionLocation} from '@jest/test-result';
|
|||
import type {Config} from '@jest/types';
|
||||
import {
|
||||
BaseWatchPlugin,
|
||||
JestHookSubscriber,
|
||||
UpdateConfigCallback,
|
||||
UsageData,
|
||||
type JestHookSubscriber,
|
||||
type UpdateConfigCallback,
|
||||
type UsageData,
|
||||
} from 'jest-watcher';
|
||||
import FailedTestsInteractiveMode from '../FailedTestsInteractiveMode';
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
*/
|
||||
|
||||
import type {ReadStream, WriteStream} from 'tty';
|
||||
import {BaseWatchPlugin, UsageData} from 'jest-watcher';
|
||||
import {BaseWatchPlugin, type UsageData} from 'jest-watcher';
|
||||
|
||||
class QuitPlugin extends BaseWatchPlugin {
|
||||
isInternal: true;
|
||||
|
|
|
@ -10,8 +10,8 @@ import type {Config} from '@jest/types';
|
|||
import {
|
||||
BaseWatchPlugin,
|
||||
Prompt,
|
||||
UpdateConfigCallback,
|
||||
UsageData,
|
||||
type UpdateConfigCallback,
|
||||
type UsageData,
|
||||
} from 'jest-watcher';
|
||||
import TestNamePatternPrompt from '../TestNamePatternPrompt';
|
||||
import activeFilters from '../lib/activeFiltersMessage';
|
||||
|
|
|
@ -10,8 +10,8 @@ import type {Config} from '@jest/types';
|
|||
import {
|
||||
BaseWatchPlugin,
|
||||
Prompt,
|
||||
UpdateConfigCallback,
|
||||
UsageData,
|
||||
type UpdateConfigCallback,
|
||||
type UsageData,
|
||||
} from 'jest-watcher';
|
||||
import TestPathPatternPrompt from '../TestPathPatternPrompt';
|
||||
import activeFilters from '../lib/activeFiltersMessage';
|
||||
|
|
|
@ -9,9 +9,9 @@ import type {ReadStream, WriteStream} from 'tty';
|
|||
import type {Config} from '@jest/types';
|
||||
import {
|
||||
BaseWatchPlugin,
|
||||
JestHookSubscriber,
|
||||
UpdateConfigCallback,
|
||||
UsageData,
|
||||
type JestHookSubscriber,
|
||||
type UpdateConfigCallback,
|
||||
type UsageData,
|
||||
} from 'jest-watcher';
|
||||
|
||||
class UpdateSnapshotsPlugin extends BaseWatchPlugin {
|
||||
|
|
|
@ -9,7 +9,11 @@
|
|||
|
||||
import type {AggregatedResult, AssertionLocation} from '@jest/test-result';
|
||||
import type {Config} from '@jest/types';
|
||||
import {BaseWatchPlugin, JestHookSubscriber, UsageData} from 'jest-watcher';
|
||||
import {
|
||||
BaseWatchPlugin,
|
||||
type JestHookSubscriber,
|
||||
type UsageData,
|
||||
} from 'jest-watcher';
|
||||
import SnapshotInteractiveMode from '../SnapshotInteractiveMode';
|
||||
|
||||
class UpdateSnapshotInteractivePlugin extends BaseWatchPlugin {
|
||||
|
|
|
@ -13,10 +13,10 @@ import exit = require('exit');
|
|||
import * as fs from 'graceful-fs';
|
||||
import {CustomConsole} from '@jest/console';
|
||||
import {
|
||||
AggregatedResult,
|
||||
Test,
|
||||
TestContext,
|
||||
TestResultsProcessor,
|
||||
type AggregatedResult,
|
||||
type Test,
|
||||
type TestContext,
|
||||
type TestResultsProcessor,
|
||||
formatTestResults,
|
||||
makeEmptyAggregatedTestResult,
|
||||
} from '@jest/test-result';
|
||||
|
@ -25,11 +25,13 @@ import type {Config} from '@jest/types';
|
|||
import type {ChangedFiles, ChangedFilesPromise} from 'jest-changed-files';
|
||||
import Resolver from 'jest-resolve';
|
||||
import {requireOrImportModule, tryRealpath} from 'jest-util';
|
||||
import {JestHook, JestHookEmitter, TestWatcher} from 'jest-watcher';
|
||||
import {JestHook, type JestHookEmitter, type TestWatcher} from 'jest-watcher';
|
||||
import type FailedTestsCache from './FailedTestsCache';
|
||||
import SearchSource from './SearchSource';
|
||||
import {TestSchedulerContext, createTestScheduler} from './TestScheduler';
|
||||
import collectNodeHandles, {HandleCollectionResult} from './collectHandles';
|
||||
import {type TestSchedulerContext, createTestScheduler} from './TestScheduler';
|
||||
import collectNodeHandles, {
|
||||
type HandleCollectionResult,
|
||||
} from './collectHandles';
|
||||
import getNoTestsFoundMessage from './getNoTestsFoundMessage';
|
||||
import runGlobalHook from './runGlobalHook';
|
||||
import type {Filter, TestRunData} from './types';
|
||||
|
|
|
@ -24,12 +24,12 @@ import {
|
|||
} from 'jest-util';
|
||||
import {ValidationError} from 'jest-validate';
|
||||
import {
|
||||
AllowedConfigOptions,
|
||||
type AllowedConfigOptions,
|
||||
JestHook,
|
||||
KEYS,
|
||||
TestWatcher,
|
||||
WatchPlugin,
|
||||
WatchPluginClass,
|
||||
type WatchPlugin,
|
||||
type WatchPluginClass,
|
||||
} from 'jest-watcher';
|
||||
import FailedTestsCache from './FailedTestsCache';
|
||||
import SearchSource from './SearchSource';
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
import chalk = require('chalk');
|
||||
import {getType} from 'jest-get-type';
|
||||
import {
|
||||
PrettyFormatOptions,
|
||||
type PrettyFormatOptions,
|
||||
format as prettyFormat,
|
||||
plugins as prettyFormatPlugins,
|
||||
} from 'pretty-format';
|
||||
|
|
|
@ -5,7 +5,12 @@
|
|||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
import {DIFF_DELETE, DIFF_EQUAL, DIFF_INSERT, Diff} from './cleanupSemantic';
|
||||
import {
|
||||
DIFF_DELETE,
|
||||
DIFF_EQUAL,
|
||||
DIFF_INSERT,
|
||||
type Diff,
|
||||
} from './cleanupSemantic';
|
||||
import type {DiffOptionsColor, DiffOptionsNormalized} from './types';
|
||||
|
||||
const formatTrailingSpaces = (
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
import {DIFF_EQUAL, Diff, cleanupSemantic} from './cleanupSemantic';
|
||||
import {DIFF_EQUAL, type Diff, cleanupSemantic} from './cleanupSemantic';
|
||||
import {diffLinesUnified, printDiffLines} from './diffLines';
|
||||
import diffStrings from './diffStrings';
|
||||
import getAlignedDiffs from './getAlignedDiffs';
|
||||
|
|
|
@ -10,7 +10,7 @@ import * as util from 'util';
|
|||
import type {Global} from '@jest/types';
|
||||
import {format as pretty} from 'pretty-format';
|
||||
import type {EachTests} from '../bind';
|
||||
import {Templates, interpolateVariables} from './interpolation';
|
||||
import {type Templates, interpolateVariables} from './interpolation';
|
||||
|
||||
const SUPPORTED_PLACEHOLDERS = /%[sdifjoOp#]/g;
|
||||
const PRETTY_PLACEHOLDER = '%p';
|
||||
|
|
|
@ -9,9 +9,9 @@
|
|||
import type {Global} from '@jest/types';
|
||||
import type {EachTests} from '../bind';
|
||||
import {
|
||||
Headings,
|
||||
Template,
|
||||
Templates,
|
||||
type Headings,
|
||||
type Template,
|
||||
type Templates,
|
||||
interpolateVariables,
|
||||
} from './interpolation';
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
import {Context, createContext, runInContext} from 'vm';
|
||||
import {type Context, createContext, runInContext} from 'vm';
|
||||
import type {
|
||||
EnvironmentContext,
|
||||
JestEnvironment,
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
/* eslint-disable local/prefer-spread-eventually */
|
||||
|
||||
import {promisify} from 'util';
|
||||
import {StackTraceConfig, formatStackTrace} from 'jest-message-util';
|
||||
import {type StackTraceConfig, formatStackTrace} from 'jest-message-util';
|
||||
import type {
|
||||
FunctionLike,
|
||||
Mock,
|
||||
|
|
|
@ -6,10 +6,10 @@
|
|||
*/
|
||||
|
||||
import {
|
||||
FakeTimerWithContext,
|
||||
FakeMethod as FakeableAPI,
|
||||
InstalledClock,
|
||||
FakeTimerInstallOpts as SinonFakeTimersConfig,
|
||||
type FakeTimerWithContext,
|
||||
type FakeMethod as FakeableAPI,
|
||||
type InstalledClock,
|
||||
type FakeTimerInstallOpts as SinonFakeTimersConfig,
|
||||
withGlobal,
|
||||
} from '@sinonjs/fake-timers';
|
||||
import type {Config} from '@jest/types';
|
||||
|
|
|
@ -10,11 +10,11 @@ import {EventEmitter} from 'events';
|
|||
import {tmpdir} from 'os';
|
||||
import * as path from 'path';
|
||||
import {deserialize, serialize} from 'v8';
|
||||
import {Stats, readFileSync, writeFileSync} from 'graceful-fs';
|
||||
import {type Stats, readFileSync, writeFileSync} from 'graceful-fs';
|
||||
import type {Config} from '@jest/types';
|
||||
import {escapePathForRegex} from 'jest-regex-util';
|
||||
import {invariant, requireOrImportModule} from 'jest-util';
|
||||
import {JestWorkerFarm, Worker} from 'jest-worker';
|
||||
import {type JestWorkerFarm, Worker} from 'jest-worker';
|
||||
import HasteFS from './HasteFS';
|
||||
import HasteModuleMap from './ModuleMap';
|
||||
import H from './constants';
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
import {EventEmitter} from 'events';
|
||||
import * as path from 'path';
|
||||
import anymatch, {Matcher} from 'anymatch';
|
||||
import anymatch, {type Matcher} from 'anymatch';
|
||||
import * as fs from 'graceful-fs';
|
||||
import micromatch = require('micromatch');
|
||||
// @ts-expect-error no types
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
*
|
||||
*/
|
||||
|
||||
import Suite, {Attributes} from '../jasmine/Suite';
|
||||
import Suite, {type Attributes} from '../jasmine/Suite';
|
||||
|
||||
describe('Suite', () => {
|
||||
let suite: Suite;
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
*
|
||||
*/
|
||||
|
||||
import queueRunner, {Options, QueueableFn} from '../queueRunner';
|
||||
import queueRunner, {type Options, type QueueableFn} from '../queueRunner';
|
||||
|
||||
describe('queueRunner', () => {
|
||||
it('runs every function in the queue.', async () => {
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
import chalk = require('chalk');
|
||||
import {
|
||||
DiffOptions,
|
||||
type DiffOptions,
|
||||
diff,
|
||||
printExpected,
|
||||
printReceived,
|
||||
|
|
|
@ -36,10 +36,10 @@ import {ErrorWithStack, convertDescriptorToString, isPromise} from 'jest-util';
|
|||
import assertionErrorMessage from '../assertionErrorMessage';
|
||||
import isError from '../isError';
|
||||
import queueRunner, {
|
||||
Options as QueueRunnerOptions,
|
||||
QueueableFn,
|
||||
type Options as QueueRunnerOptions,
|
||||
type QueueableFn,
|
||||
} from '../queueRunner';
|
||||
import treeProcessor, {TreeNode} from '../treeProcessor';
|
||||
import treeProcessor, {type TreeNode} from '../treeProcessor';
|
||||
import type {
|
||||
AssertionErrorWithStack,
|
||||
Jasmine,
|
||||
|
|
|
@ -37,7 +37,7 @@ import {convertDescriptorToString} from 'jest-util';
|
|||
import ExpectationFailed from '../ExpectationFailed';
|
||||
import assertionErrorMessage from '../assertionErrorMessage';
|
||||
import expectationResultFactory, {
|
||||
Options as ExpectationResultFactoryOptions,
|
||||
type Options as ExpectationResultFactoryOptions,
|
||||
} from '../expectationResultFactory';
|
||||
import type {QueueableFn, default as queueRunner} from '../queueRunner';
|
||||
import type {AssertionErrorWithStack} from '../types';
|
||||
|
|
|
@ -31,7 +31,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|||
/* eslint-disable sort-keys, local/prefer-rest-params-eventually */
|
||||
|
||||
import type {Spy} from '../types';
|
||||
import CallTracker, {Context} from './CallTracker';
|
||||
import CallTracker, {type Context} from './CallTracker';
|
||||
import SpyStrategy from './SpyStrategy';
|
||||
|
||||
interface Fn extends Record<string, unknown> {
|
||||
|
|
|
@ -6,8 +6,8 @@
|
|||
*/
|
||||
|
||||
import {
|
||||
AssertionResult,
|
||||
TestResult,
|
||||
type AssertionResult,
|
||||
type TestResult,
|
||||
createEmptyTestResult,
|
||||
} from '@jest/test-result';
|
||||
import type {Config} from '@jest/types';
|
||||
|
|
|
@ -10,7 +10,7 @@ import chalk = require('chalk');
|
|||
import {alignedAnsiStyleSerializer} from '@jest/test-utils';
|
||||
import {format as prettyFormat} from 'pretty-format';
|
||||
import {
|
||||
MatcherHintOptions,
|
||||
type MatcherHintOptions,
|
||||
diff,
|
||||
ensureNoExpected,
|
||||
ensureNumbers,
|
||||
|
|
|
@ -12,8 +12,8 @@ import {
|
|||
DIFF_DELETE,
|
||||
DIFF_EQUAL,
|
||||
DIFF_INSERT,
|
||||
Diff,
|
||||
DiffOptions as ImportDiffOptions,
|
||||
type Diff,
|
||||
type DiffOptions as ImportDiffOptions,
|
||||
diff as diffDefault,
|
||||
diffStringsRaw,
|
||||
diffStringsUnified,
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
*/
|
||||
|
||||
import {expectType} from 'tsd-lite';
|
||||
import {MockMetadata, Mocked, ModuleMocker} from 'jest-mock';
|
||||
import {type MockMetadata, type Mocked, ModuleMocker} from 'jest-mock';
|
||||
|
||||
class ExampleClass {
|
||||
memberA: Array<number>;
|
||||
|
|
|
@ -14,12 +14,12 @@ import {
|
|||
expectType,
|
||||
} from 'tsd-lite';
|
||||
import {
|
||||
Mock,
|
||||
Replaced,
|
||||
SpiedClass,
|
||||
SpiedFunction,
|
||||
SpiedGetter,
|
||||
SpiedSetter,
|
||||
type Mock,
|
||||
type Replaced,
|
||||
type SpiedClass,
|
||||
type SpiedFunction,
|
||||
type SpiedGetter,
|
||||
type SpiedSetter,
|
||||
fn,
|
||||
replaceProperty,
|
||||
spyOn,
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
/* eslint-disable local/ban-types-eventually, local/prefer-rest-params-eventually */
|
||||
|
||||
import * as util from 'util';
|
||||
import {Context, createContext, runInContext, runInNewContext} from 'vm';
|
||||
import {type Context, createContext, runInContext, runInNewContext} from 'vm';
|
||||
import {ModuleMocker, fn, mocked, spyOn} from '../';
|
||||
|
||||
describe('moduleMocker', () => {
|
||||
|
|
|
@ -7,11 +7,11 @@
|
|||
|
||||
import {expectError, expectType} from 'tsd-lite';
|
||||
import {
|
||||
AggregatedResult,
|
||||
Config,
|
||||
SnapshotSummary,
|
||||
SummaryOptions,
|
||||
TestResult,
|
||||
type AggregatedResult,
|
||||
type Config,
|
||||
type SnapshotSummary,
|
||||
type SummaryOptions,
|
||||
type TestResult,
|
||||
utils,
|
||||
} from '@jest/reporters';
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@ import type {
|
|||
} from '@jest/test-result';
|
||||
import type {Config} from '@jest/types';
|
||||
import {clearLine, isInteractive} from 'jest-util';
|
||||
import {JestWorkerFarm, Worker} from 'jest-worker';
|
||||
import {type JestWorkerFarm, Worker} from 'jest-worker';
|
||||
import BaseReporter from './BaseReporter';
|
||||
import getWatermarks from './getWatermarks';
|
||||
import type {ReporterContext} from './types';
|
||||
|
|
|
@ -9,7 +9,7 @@ import exit = require('exit');
|
|||
import * as fs from 'graceful-fs';
|
||||
import type {Config} from '@jest/types';
|
||||
import generateEmptyCoverage, {
|
||||
CoverageWorkerResult,
|
||||
type CoverageWorkerResult,
|
||||
} from './generateEmptyCoverage';
|
||||
import type {ReporterContext} from './types';
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
import type {V8Coverage} from 'collect-v8-coverage';
|
||||
import * as fs from 'graceful-fs';
|
||||
import {FileCoverage, createFileCoverage} from 'istanbul-lib-coverage';
|
||||
import {type FileCoverage, createFileCoverage} from 'istanbul-lib-coverage';
|
||||
import {readInitialCoverage} from 'istanbul-lib-instrument';
|
||||
import {createScriptTransformer, shouldInstrument} from '@jest/transform';
|
||||
import type {Config} from '@jest/types';
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
import * as path from 'path';
|
||||
import type {IHasteFS} from 'jest-haste-map';
|
||||
import type {ResolveModuleConfig, default as Resolver} from 'jest-resolve';
|
||||
import {SnapshotResolver, isSnapshotPath} from 'jest-snapshot';
|
||||
import {type SnapshotResolver, isSnapshotPath} from 'jest-snapshot';
|
||||
|
||||
export type ResolvedModule = {
|
||||
file: string;
|
||||
|
|
|
@ -9,10 +9,10 @@
|
|||
import * as path from 'path';
|
||||
import * as fs from 'graceful-fs';
|
||||
import {sync as resolveSync} from 'resolve';
|
||||
import {IModuleMap, ModuleMap} from 'jest-haste-map';
|
||||
import {type IModuleMap, ModuleMap} from 'jest-haste-map';
|
||||
import userResolver from '../__mocks__/userResolver';
|
||||
import userResolverAsync from '../__mocks__/userResolverAsync';
|
||||
import defaultResolver, {PackageFilter} from '../defaultResolver';
|
||||
import defaultResolver, {type PackageFilter} from '../defaultResolver';
|
||||
import nodeModulesPaths from '../nodeModulesPaths';
|
||||
import Resolver from '../resolver';
|
||||
import type {ResolverConfig} from '../types';
|
||||
|
|
|
@ -7,7 +7,10 @@
|
|||
|
||||
import {dirname, isAbsolute, resolve as pathResolve} from 'path';
|
||||
import pnpResolver from 'jest-pnp-resolver';
|
||||
import {SyncOpts as UpstreamResolveOptions, sync as resolveSync} from 'resolve';
|
||||
import {
|
||||
type SyncOpts as UpstreamResolveOptions,
|
||||
sync as resolveSync,
|
||||
} from 'resolve';
|
||||
import * as resolve from 'resolve.exports';
|
||||
import {
|
||||
findClosestPackageJson,
|
||||
|
|
|
@ -14,9 +14,9 @@ import type {IModuleMap} from 'jest-haste-map';
|
|||
import {tryRealpath} from 'jest-util';
|
||||
import ModuleNotFoundError from './ModuleNotFoundError';
|
||||
import defaultResolver, {
|
||||
AsyncResolver,
|
||||
Resolver as ResolverInterface,
|
||||
SyncResolver,
|
||||
type AsyncResolver,
|
||||
type Resolver as ResolverInterface,
|
||||
type SyncResolver,
|
||||
} from './defaultResolver';
|
||||
import {clearFsCache} from './fileWalkers';
|
||||
import isBuiltinModule from './isBuiltinModule';
|
||||
|
|
|
@ -8,19 +8,19 @@
|
|||
import {expectType} from 'tsd-lite';
|
||||
import {
|
||||
CallbackTestRunner,
|
||||
CallbackTestRunnerInterface,
|
||||
Config,
|
||||
type CallbackTestRunnerInterface,
|
||||
type Config,
|
||||
EmittingTestRunner,
|
||||
EmittingTestRunnerInterface,
|
||||
OnTestFailure,
|
||||
OnTestStart,
|
||||
OnTestSuccess,
|
||||
Test,
|
||||
TestEvents,
|
||||
TestRunnerContext,
|
||||
TestRunnerOptions,
|
||||
TestWatcher,
|
||||
UnsubscribeFn,
|
||||
type EmittingTestRunnerInterface,
|
||||
type OnTestFailure,
|
||||
type OnTestStart,
|
||||
type OnTestSuccess,
|
||||
type Test,
|
||||
type TestEvents,
|
||||
type TestRunnerContext,
|
||||
type TestRunnerOptions,
|
||||
type TestWatcher,
|
||||
type UnsubscribeFn,
|
||||
} from 'jest-runner';
|
||||
|
||||
const globalConfig = {} as Config.GlobalConfig;
|
||||
|
|
|
@ -16,10 +16,18 @@ import type {
|
|||
} from '@jest/test-result';
|
||||
import {deepCyclicCopy} from 'jest-util';
|
||||
import type {TestWatcher} from 'jest-watcher';
|
||||
import {JestWorkerFarm, PromiseWithCustomMessage, Worker} from 'jest-worker';
|
||||
import {
|
||||
type JestWorkerFarm,
|
||||
type PromiseWithCustomMessage,
|
||||
Worker,
|
||||
} from 'jest-worker';
|
||||
import runTest from './runTest';
|
||||
import type {SerializableResolver} from './testWorker';
|
||||
import {EmittingTestRunner, TestRunnerOptions, UnsubscribeFn} from './types';
|
||||
import {
|
||||
EmittingTestRunner,
|
||||
type TestRunnerOptions,
|
||||
type UnsubscribeFn,
|
||||
} from './types';
|
||||
|
||||
export type {Test, TestEvents} from '@jest/test-result';
|
||||
export type {Config} from '@jest/types';
|
||||
|
|
|
@ -12,8 +12,8 @@ import sourcemapSupport = require('source-map-support');
|
|||
import {
|
||||
BufferedConsole,
|
||||
CustomConsole,
|
||||
LogMessage,
|
||||
LogType,
|
||||
type LogMessage,
|
||||
type LogType,
|
||||
NullConsole,
|
||||
getConsoleOutput,
|
||||
} from '@jest/console';
|
||||
|
@ -24,6 +24,7 @@ import type {Config} from '@jest/types';
|
|||
import * as docblock from 'jest-docblock';
|
||||
import LeakDetector from 'jest-leak-detector';
|
||||
import {formatExecError} from 'jest-message-util';
|
||||
// eslint-disable-next-line @typescript-eslint/consistent-type-imports
|
||||
import Resolver, {resolveTestEnvironment} from 'jest-resolve';
|
||||
import type RuntimeClass from 'jest-runtime';
|
||||
import {ErrorWithStack, interopRequireDefault, setGlobal} from 'jest-util';
|
||||
|
|
|
@ -13,7 +13,7 @@ import type {
|
|||
TestResult,
|
||||
} from '@jest/test-result';
|
||||
import type {Config} from '@jest/types';
|
||||
import HasteMap, {SerializableModuleMap} from 'jest-haste-map';
|
||||
import HasteMap, {type SerializableModuleMap} from 'jest-haste-map';
|
||||
import {separateMessageFromStack} from 'jest-message-util';
|
||||
import type Resolver from 'jest-resolve';
|
||||
import Runtime from 'jest-runtime';
|
||||
|
|
|
@ -14,12 +14,12 @@ import {
|
|||
SourceTextModule,
|
||||
// @ts-expect-error: experimental, not added to the types
|
||||
SyntheticModule,
|
||||
Context as VMContext,
|
||||
type Context as VMContext,
|
||||
// @ts-expect-error: experimental, not added to the types
|
||||
Module as VMModule,
|
||||
type Module as VMModule,
|
||||
} from 'vm';
|
||||
import {parse as parseCjs} from 'cjs-module-lexer';
|
||||
import {CoverageInstrumenter, V8Coverage} from 'collect-v8-coverage';
|
||||
import {CoverageInstrumenter, type V8Coverage} from 'collect-v8-coverage';
|
||||
import * as fs from 'graceful-fs';
|
||||
import slash = require('slash');
|
||||
import stripBOM = require('strip-bom');
|
||||
|
@ -39,19 +39,19 @@ import type {
|
|||
V8CoverageResult,
|
||||
} from '@jest/test-result';
|
||||
import {
|
||||
CallerTransformOptions,
|
||||
ScriptTransformer,
|
||||
ShouldInstrumentOptions,
|
||||
TransformationOptions,
|
||||
type CallerTransformOptions,
|
||||
type ScriptTransformer,
|
||||
type ShouldInstrumentOptions,
|
||||
type TransformationOptions,
|
||||
handlePotentialSyntaxError,
|
||||
shouldInstrument,
|
||||
} from '@jest/transform';
|
||||
import type {Config, Global} from '@jest/types';
|
||||
import HasteMap, {IHasteMap, IModuleMap} from 'jest-haste-map';
|
||||
import HasteMap, {type IHasteMap, type IModuleMap} from 'jest-haste-map';
|
||||
import {formatStackTrace, separateMessageFromStack} from 'jest-message-util';
|
||||
import type {MockMetadata, ModuleMocker} from 'jest-mock';
|
||||
import {escapePathForRegex} from 'jest-regex-util';
|
||||
import Resolver, {ResolveModuleConfig} from 'jest-resolve';
|
||||
import Resolver, {type ResolveModuleConfig} from 'jest-resolve';
|
||||
import {EXTENSION as SnapshotExtension} from 'jest-snapshot';
|
||||
import {
|
||||
createDirectory,
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
import {Static, Type} from '@sinclair/typebox';
|
||||
import {type Static, Type} from '@sinclair/typebox';
|
||||
|
||||
const RawSnapshotFormat = Type.Partial(
|
||||
Type.Object({
|
||||
|
|
|
@ -8,8 +8,8 @@
|
|||
import {expectError, expectType} from 'tsd-lite';
|
||||
import type {ExpectationResult} from 'expect';
|
||||
import {
|
||||
Context,
|
||||
SnapshotState,
|
||||
type Context,
|
||||
type SnapshotState,
|
||||
toMatchInlineSnapshot,
|
||||
toMatchSnapshot,
|
||||
toThrowErrorMatchingInlineSnapshot,
|
||||
|
|
|
@ -7,7 +7,10 @@
|
|||
|
||||
import * as path from 'path';
|
||||
import {makeProjectConfig} from '@jest/test-utils';
|
||||
import {SnapshotResolver, buildSnapshotResolver} from '../SnapshotResolver';
|
||||
import {
|
||||
type SnapshotResolver,
|
||||
buildSnapshotResolver,
|
||||
} from '../SnapshotResolver';
|
||||
|
||||
describe('defaults', () => {
|
||||
let snapshotResolver: SnapshotResolver;
|
||||
|
|
|
@ -11,7 +11,7 @@ import chalk = require('chalk');
|
|||
import type {SyncExpectationResult} from 'expect';
|
||||
import format from 'pretty-format';
|
||||
import {
|
||||
Context,
|
||||
type Context,
|
||||
toMatchInlineSnapshot,
|
||||
toMatchSnapshot,
|
||||
toThrowErrorMatchingInlineSnapshot,
|
||||
|
|
|
@ -12,14 +12,14 @@ import type {MatcherFunctionWithContext} from 'expect';
|
|||
import {
|
||||
BOLD_WEIGHT,
|
||||
EXPECTED_COLOR,
|
||||
MatcherHintOptions,
|
||||
type MatcherHintOptions,
|
||||
RECEIVED_COLOR,
|
||||
matcherErrorMessage,
|
||||
matcherHint,
|
||||
printWithType,
|
||||
stringify,
|
||||
} from 'jest-matcher-utils';
|
||||
import {EXTENSION, SnapshotResolver} from './SnapshotResolver';
|
||||
import {EXTENSION, type SnapshotResolver} from './SnapshotResolver';
|
||||
import {
|
||||
PROPERTIES_ARG,
|
||||
SNAPSHOT_ARG,
|
||||
|
|
|
@ -6,8 +6,8 @@
|
|||
*/
|
||||
|
||||
import {
|
||||
Plugin as PrettyFormatPlugin,
|
||||
Plugins as PrettyFormatPlugins,
|
||||
type Plugin as PrettyFormatPlugin,
|
||||
type Plugins as PrettyFormatPlugins,
|
||||
plugins as prettyFormatPlugins,
|
||||
} from 'pretty-format';
|
||||
import jestMockSerializer from './mockSerializer';
|
||||
|
|
|
@ -11,8 +11,8 @@ import {
|
|||
DIFF_DELETE,
|
||||
DIFF_EQUAL,
|
||||
DIFF_INSERT,
|
||||
Diff,
|
||||
DiffOptionsColor,
|
||||
type Diff,
|
||||
type DiffOptionsColor,
|
||||
diffLinesUnified,
|
||||
diffLinesUnified2,
|
||||
diffStringsRaw,
|
||||
|
@ -23,7 +23,7 @@ import {
|
|||
BOLD_WEIGHT,
|
||||
EXPECTED_COLOR,
|
||||
INVERTED_COLOR,
|
||||
MatcherHintOptions,
|
||||
type MatcherHintOptions,
|
||||
RECEIVED_COLOR,
|
||||
getLabelPrinter,
|
||||
matcherHint,
|
||||
|
|
|
@ -19,7 +19,7 @@ import * as fs from 'graceful-fs';
|
|||
import naturalCompare = require('natural-compare');
|
||||
import type {Config} from '@jest/types';
|
||||
import {
|
||||
OptionsReceived as PrettyFormatOptions,
|
||||
type OptionsReceived as PrettyFormatOptions,
|
||||
format as prettyFormat,
|
||||
} from 'pretty-format';
|
||||
import {getSerializers} from './plugins';
|
||||
|
|
|
@ -20,7 +20,7 @@ Another use-case for `@types/jest` is a typed Jest config as those types are not
|
|||
|
||||
```ts
|
||||
// jest.config.ts
|
||||
import {Config} from '@jest/types';
|
||||
import type {Config} from '@jest/types';
|
||||
|
||||
const config: Config.InitialOptions = {
|
||||
// some typed config
|
||||
|
|
|
@ -8,17 +8,17 @@
|
|||
import FifoQueue from './FifoQueue';
|
||||
import {
|
||||
CHILD_MESSAGE_CALL,
|
||||
ChildMessage,
|
||||
OnCustomMessage,
|
||||
OnEnd,
|
||||
OnStart,
|
||||
PromiseWithCustomMessage,
|
||||
QueueChildMessage,
|
||||
TaskQueue,
|
||||
WorkerCallback,
|
||||
WorkerFarmOptions,
|
||||
WorkerInterface,
|
||||
WorkerSchedulingPolicy,
|
||||
type ChildMessage,
|
||||
type OnCustomMessage,
|
||||
type OnEnd,
|
||||
type OnStart,
|
||||
type PromiseWithCustomMessage,
|
||||
type QueueChildMessage,
|
||||
type TaskQueue,
|
||||
type WorkerCallback,
|
||||
type WorkerFarmOptions,
|
||||
type WorkerInterface,
|
||||
type WorkerSchedulingPolicy,
|
||||
} from './types';
|
||||
|
||||
export default class Farm {
|
||||
|
|
|
@ -8,8 +8,8 @@
|
|||
import FifoQueue from '../FifoQueue';
|
||||
import {
|
||||
CHILD_MESSAGE_CALL,
|
||||
ChildMessageCall,
|
||||
QueueChildMessage,
|
||||
type ChildMessageCall,
|
||||
type QueueChildMessage,
|
||||
} from '../types';
|
||||
|
||||
it('returns the shared tasks in FIFO ordering', () => {
|
||||
|
|
|
@ -8,8 +8,8 @@
|
|||
import PriorityQueue from '../PriorityQueue';
|
||||
import {
|
||||
CHILD_MESSAGE_CALL,
|
||||
ChildMessageCall,
|
||||
QueueChildMessage,
|
||||
type ChildMessageCall,
|
||||
type QueueChildMessage,
|
||||
} from '../types';
|
||||
|
||||
it('returns the tasks in order', () => {
|
||||
|
|
|
@ -9,7 +9,7 @@ import {tmpdir} from 'os';
|
|||
import {join} from 'path';
|
||||
import {writeFileSync} from 'graceful-fs';
|
||||
import LeakDetector from 'jest-leak-detector';
|
||||
import {JestWorkerFarm, Worker} from '../../build';
|
||||
import {type JestWorkerFarm, Worker} from '../../build';
|
||||
|
||||
describe('WorkerThreads leaks', () => {
|
||||
let workerFile: string;
|
||||
|
|
|
@ -9,10 +9,10 @@ import mergeStream = require('merge-stream');
|
|||
import {
|
||||
CHILD_MESSAGE_CALL_SETUP,
|
||||
CHILD_MESSAGE_END,
|
||||
PoolExitResult,
|
||||
WorkerInterface,
|
||||
WorkerOptions,
|
||||
WorkerPoolOptions,
|
||||
type PoolExitResult,
|
||||
type WorkerInterface,
|
||||
type WorkerOptions,
|
||||
type WorkerPoolOptions,
|
||||
WorkerStates,
|
||||
} from '../types';
|
||||
|
||||
|
|
|
@ -7,9 +7,9 @@
|
|||
|
||||
import {
|
||||
CHILD_MESSAGE_END,
|
||||
WorkerInterface,
|
||||
WorkerOptions,
|
||||
WorkerPoolOptions,
|
||||
type WorkerInterface,
|
||||
type WorkerOptions,
|
||||
type WorkerPoolOptions,
|
||||
} from '../../types';
|
||||
import BaseWorkerPool from '../BaseWorkerPool';
|
||||
|
||||
|
|
|
@ -5,25 +5,25 @@
|
|||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
import {ChildProcess, ForkOptions, fork} from 'child_process';
|
||||
import {type ChildProcess, type ForkOptions, fork} from 'child_process';
|
||||
import {totalmem} from 'os';
|
||||
import mergeStream = require('merge-stream');
|
||||
import {stdout as stdoutSupportsColor} from 'supports-color';
|
||||
import {
|
||||
CHILD_MESSAGE_INITIALIZE,
|
||||
CHILD_MESSAGE_MEM_USAGE,
|
||||
ChildMessage,
|
||||
OnCustomMessage,
|
||||
OnEnd,
|
||||
OnStart,
|
||||
type ChildMessage,
|
||||
type OnCustomMessage,
|
||||
type OnEnd,
|
||||
type OnStart,
|
||||
PARENT_MESSAGE_CLIENT_ERROR,
|
||||
PARENT_MESSAGE_CUSTOM,
|
||||
PARENT_MESSAGE_MEM_USAGE,
|
||||
PARENT_MESSAGE_OK,
|
||||
PARENT_MESSAGE_SETUP_ERROR,
|
||||
ParentMessage,
|
||||
WorkerInterface,
|
||||
WorkerOptions,
|
||||
type ParentMessage,
|
||||
type WorkerInterface,
|
||||
type WorkerOptions,
|
||||
WorkerStates,
|
||||
} from '../types';
|
||||
import WorkerAbstract from './WorkerAbstract';
|
||||
|
|
|
@ -11,18 +11,18 @@ import mergeStream = require('merge-stream');
|
|||
import {
|
||||
CHILD_MESSAGE_INITIALIZE,
|
||||
CHILD_MESSAGE_MEM_USAGE,
|
||||
ChildMessage,
|
||||
OnCustomMessage,
|
||||
OnEnd,
|
||||
OnStart,
|
||||
type ChildMessage,
|
||||
type OnCustomMessage,
|
||||
type OnEnd,
|
||||
type OnStart,
|
||||
PARENT_MESSAGE_CLIENT_ERROR,
|
||||
PARENT_MESSAGE_CUSTOM,
|
||||
PARENT_MESSAGE_MEM_USAGE,
|
||||
PARENT_MESSAGE_OK,
|
||||
PARENT_MESSAGE_SETUP_ERROR,
|
||||
ParentMessage,
|
||||
WorkerInterface,
|
||||
WorkerOptions,
|
||||
type ParentMessage,
|
||||
type WorkerInterface,
|
||||
type WorkerOptions,
|
||||
WorkerStates,
|
||||
} from '../types';
|
||||
import WorkerAbstract from './WorkerAbstract';
|
||||
|
|
|
@ -8,8 +8,8 @@
|
|||
import {EventEmitter, PassThrough} from 'stream';
|
||||
import {
|
||||
WorkerEvents,
|
||||
WorkerInterface,
|
||||
WorkerOptions,
|
||||
type WorkerInterface,
|
||||
type WorkerOptions,
|
||||
WorkerStates,
|
||||
} from '../types';
|
||||
|
||||
|
|
|
@ -13,13 +13,13 @@ import {
|
|||
CHILD_MESSAGE_CALL,
|
||||
CHILD_MESSAGE_INITIALIZE,
|
||||
CHILD_MESSAGE_MEM_USAGE,
|
||||
ChildMessage,
|
||||
ChildMessageCall,
|
||||
type ChildMessage,
|
||||
type ChildMessageCall,
|
||||
PARENT_MESSAGE_CLIENT_ERROR,
|
||||
PARENT_MESSAGE_CUSTOM,
|
||||
PARENT_MESSAGE_MEM_USAGE,
|
||||
PARENT_MESSAGE_OK,
|
||||
WorkerOptions,
|
||||
type WorkerOptions,
|
||||
} from '../../types';
|
||||
|
||||
jest.useFakeTimers();
|
||||
|
|
|
@ -11,11 +11,11 @@ import getStream = require('get-stream');
|
|||
import {
|
||||
CHILD_MESSAGE_CALL,
|
||||
CHILD_MESSAGE_INITIALIZE,
|
||||
ChildMessageCall,
|
||||
type ChildMessageCall,
|
||||
PARENT_MESSAGE_CLIENT_ERROR,
|
||||
PARENT_MESSAGE_CUSTOM,
|
||||
PARENT_MESSAGE_OK,
|
||||
WorkerOptions,
|
||||
type WorkerOptions,
|
||||
} from '../../types';
|
||||
|
||||
let Worker: typeof import('../NodeThreadsWorker').default;
|
||||
|
|
|
@ -11,7 +11,7 @@ import {transformFileAsync} from '@babel/core';
|
|||
import {
|
||||
CHILD_MESSAGE_CALL,
|
||||
WorkerEvents,
|
||||
WorkerOptions,
|
||||
type WorkerOptions,
|
||||
WorkerStates,
|
||||
} from '../../types';
|
||||
import ChildProcessWorker, {SIGKILL_DELAY} from '../ChildProcessWorker';
|
||||
|
|
|
@ -12,14 +12,14 @@ import {
|
|||
CHILD_MESSAGE_END,
|
||||
CHILD_MESSAGE_INITIALIZE,
|
||||
CHILD_MESSAGE_MEM_USAGE,
|
||||
ChildMessageCall,
|
||||
ChildMessageInitialize,
|
||||
type ChildMessageCall,
|
||||
type ChildMessageInitialize,
|
||||
PARENT_MESSAGE_CLIENT_ERROR,
|
||||
PARENT_MESSAGE_ERROR,
|
||||
type PARENT_MESSAGE_ERROR,
|
||||
PARENT_MESSAGE_MEM_USAGE,
|
||||
PARENT_MESSAGE_OK,
|
||||
PARENT_MESSAGE_SETUP_ERROR,
|
||||
ParentMessageMemUsage,
|
||||
type ParentMessageMemUsage,
|
||||
} from '../types';
|
||||
|
||||
type UnknownFunction = (...args: Array<unknown>) => unknown | Promise<unknown>;
|
||||
|
|
|
@ -13,14 +13,14 @@ import {
|
|||
CHILD_MESSAGE_END,
|
||||
CHILD_MESSAGE_INITIALIZE,
|
||||
CHILD_MESSAGE_MEM_USAGE,
|
||||
ChildMessageCall,
|
||||
ChildMessageInitialize,
|
||||
type ChildMessageCall,
|
||||
type ChildMessageInitialize,
|
||||
PARENT_MESSAGE_CLIENT_ERROR,
|
||||
PARENT_MESSAGE_ERROR,
|
||||
type PARENT_MESSAGE_ERROR,
|
||||
PARENT_MESSAGE_MEM_USAGE,
|
||||
PARENT_MESSAGE_OK,
|
||||
PARENT_MESSAGE_SETUP_ERROR,
|
||||
ParentMessageMemUsage,
|
||||
type ParentMessageMemUsage,
|
||||
} from '../types';
|
||||
|
||||
type UnknownFunction = (...args: Array<unknown>) => unknown | Promise<unknown>;
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
/* eslint-disable local/prefer-rest-params-eventually */
|
||||
|
||||
import prettyFormat, {PrettyFormatOptions} from '../';
|
||||
import prettyFormat, {type PrettyFormatOptions} from '../';
|
||||
|
||||
function returnArguments(..._args: Array<unknown>) {
|
||||
return arguments;
|
||||
|
|
|
@ -736,7 +736,7 @@ export function setDateNow(now: number): jest.Spied<typeof Date.now> {
|
|||
```
|
||||
|
||||
```ts
|
||||
import {afterEach, expect, jest, test} from '@jest/globals';
|
||||
import {afterEach, expect, type jest, test} from '@jest/globals';
|
||||
import {setDateNow} from './__utils__/setDateNow';
|
||||
|
||||
let spiedDateNow: jest.Spied<typeof Date.now> | undefined = undefined;
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue