various workaround for typescript definitions
Forwarded: not-needed Last-Update: 2022-02-10 Gbp-Pq: Name fix-typescript.patch
This commit is contained in:
parent
5682c77255
commit
de0fc738c2
|
@ -6,4 +6,5 @@
|
|||
*/
|
||||
|
||||
// this is a separate file so it can be mocked in tests
|
||||
// @ts-ignore
|
||||
export {loadPartialConfig, loadPartialConfigAsync} from '@babel/core';
|
||||
|
|
|
@ -99,6 +99,7 @@ export const setMatchers = <State extends MatcherState = MatcherState>(
|
|||
configurable: true,
|
||||
enumerable: true,
|
||||
value: (...sample: [unknown, ...Array<unknown>]) =>
|
||||
// @ts-ignore
|
||||
new CustomMatcher(false, ...sample),
|
||||
writable: true,
|
||||
});
|
||||
|
@ -106,6 +107,7 @@ export const setMatchers = <State extends MatcherState = MatcherState>(
|
|||
configurable: true,
|
||||
enumerable: true,
|
||||
value: (...sample: [unknown, ...Array<unknown>]) =>
|
||||
// @ts-ignore
|
||||
new CustomMatcher(true, ...sample),
|
||||
writable: true,
|
||||
});
|
||||
|
|
|
@ -14,6 +14,7 @@ import {
|
|||
printExpected,
|
||||
printReceived,
|
||||
} from 'jest-matcher-utils';
|
||||
// @ts-ignore
|
||||
import {format as prettyFormat} from 'pretty-format';
|
||||
|
||||
interface AssertionErrorWithStack extends AssertionError {
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
|
||||
// Used as type
|
||||
import type {Circus} from '@jest/types';
|
||||
// @ts-ignore
|
||||
import expect = require('expect');
|
||||
|
||||
export const STATE_SYM = Symbol(
|
||||
|
|
|
@ -14,6 +14,7 @@ import StackUtils = require('stack-utils');
|
|||
import type {AssertionResult, Status} from '@jest/test-result';
|
||||
import type {Circus, Global} from '@jest/types';
|
||||
import {ErrorWithStack, convertDescriptorToString, formatTime} from 'jest-util';
|
||||
// @ts-ignore
|
||||
import {format as prettyFormat} from 'pretty-format';
|
||||
import {ROOT_DESCRIBE_BLOCK_NAME, getState} from './state';
|
||||
|
||||
|
|
|
@ -55,6 +55,7 @@ export const buildArgv = (maybeArgv?: Array<string>): Config.Argv => {
|
|||
|
||||
const rawArgv: Config.Argv | Array<string> =
|
||||
maybeArgv || process.argv.slice(2);
|
||||
// @ts-ignore
|
||||
const argv: Config.Argv = yargs(rawArgv)
|
||||
.usage(args.usage)
|
||||
.version(version)
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
|
||||
import chalk = require('chalk');
|
||||
import type {DeprecatedOptions} from 'jest-validate';
|
||||
// @ts-ignore
|
||||
import {format as prettyFormat} from 'pretty-format';
|
||||
|
||||
const format = (value: unknown) => prettyFormat(value, {min: true});
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
import type {Config} from '@jest/types';
|
||||
import {replacePathSepForRegex} from 'jest-regex-util';
|
||||
import {multipleValidOptions} from 'jest-validate';
|
||||
// @ts-ignore
|
||||
import {DEFAULT_OPTIONS as PRETTY_FORMAT_DEFAULTS} from 'pretty-format';
|
||||
import {NODE_MODULES} from './constants';
|
||||
|
||||
|
|
|
@ -35,6 +35,7 @@ export default async function readConfigFileAndSetRootDir(
|
|||
configObject = await loadTSConfigFile(configPath);
|
||||
} else if (isJSON) {
|
||||
const fileContent = fs.readFileSync(configPath, 'utf8');
|
||||
// @ts-ignore
|
||||
configObject = parseJson(stripJsonComments(fileContent), configPath);
|
||||
} else {
|
||||
configObject = await requireOrImportModule<any>(configPath);
|
||||
|
|
|
@ -267,6 +267,7 @@ class TestScheduler {
|
|||
|
||||
await testRunner.runTests(
|
||||
tests,
|
||||
// @ts-ignore
|
||||
watcher,
|
||||
undefined,
|
||||
undefined,
|
||||
|
@ -278,6 +279,7 @@ class TestScheduler {
|
|||
} else {
|
||||
await testRunner.runTests(
|
||||
tests,
|
||||
// @ts-ignore
|
||||
watcher,
|
||||
onTestFileStart,
|
||||
onResult,
|
||||
|
|
|
@ -11,7 +11,8 @@ type State = {
|
|||
interrupted: boolean;
|
||||
};
|
||||
|
||||
export default class TestWatcher extends emittery<{change: State}> {
|
||||
// @ts-ignore
|
||||
export default class TestWatcher extends emittery {
|
||||
state: State;
|
||||
private _isWatchMode: boolean;
|
||||
|
||||
|
@ -23,6 +24,7 @@ export default class TestWatcher extends emittery<{change: State}> {
|
|||
|
||||
async setState(state: State): Promise<void> {
|
||||
Object.assign(this.state, state);
|
||||
// @ts-ignore
|
||||
await this.emit('change', this.state);
|
||||
}
|
||||
|
||||
|
|
|
@ -40,7 +40,7 @@ function stackIsFromUser(stack: string) {
|
|||
|
||||
const alwaysActive = () => true;
|
||||
|
||||
// @ts-expect-error: doesn't exist in v10 typings
|
||||
// @ts-ignore
|
||||
const hasWeakRef = typeof WeakRef === 'function';
|
||||
|
||||
const asyncSleep = promisify(setTimeout);
|
||||
|
@ -97,13 +97,13 @@ export default function collectHandles(): HandleCollectionResult {
|
|||
// Timer that supports hasRef (Node v11+)
|
||||
if ('hasRef' in resource) {
|
||||
if (hasWeakRef) {
|
||||
// @ts-expect-error: doesn't exist in v10 typings
|
||||
// @ts-ignore
|
||||
const ref = new WeakRef(resource);
|
||||
isActive = () => {
|
||||
return ref.deref()?.hasRef() ?? false;
|
||||
};
|
||||
} else {
|
||||
// @ts-expect-error: doesn't exist in v10 typings
|
||||
// @ts-ignore
|
||||
isActive = resource.hasRef.bind(resource);
|
||||
}
|
||||
} else {
|
||||
|
|
|
@ -9,6 +9,7 @@ import * as util from 'util';
|
|||
import type {Test} from '@jest/test-result';
|
||||
import {createScriptTransformer} from '@jest/transform';
|
||||
import type {Config} from '@jest/types';
|
||||
// @ts-ignore
|
||||
import prettyFormat from 'pretty-format';
|
||||
|
||||
export default async function runGlobalHook({
|
||||
|
|
|
@ -8,9 +8,11 @@
|
|||
import chalk = require('chalk');
|
||||
import {getType} from 'jest-get-type';
|
||||
import {
|
||||
// @ts-ignore
|
||||
format as prettyFormat,
|
||||
plugins as prettyFormatPlugins,
|
||||
} from 'pretty-format';
|
||||
// @ts-ignore
|
||||
import type {PrettyFormatOptions} from 'pretty-format';
|
||||
import {DIFF_DELETE, DIFF_EQUAL, DIFF_INSERT, Diff} from './cleanupSemantic';
|
||||
import {NO_DIFF_MESSAGE, SIMILAR_MESSAGE} from './constants';
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
*/
|
||||
|
||||
import chalk = require('chalk');
|
||||
// @ts-ignore
|
||||
import type {CompareKeys} from 'pretty-format';
|
||||
import type {DiffOptions, DiffOptionsNormalized} from './types';
|
||||
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
// @ts-ignore
|
||||
import type {CompareKeys} from 'pretty-format';
|
||||
|
||||
export type DiffOptionsColor = (arg: string) => string; // subset of Chalk type
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
|
||||
import * as util from 'util';
|
||||
import type {Global} from '@jest/types';
|
||||
// @ts-ignore
|
||||
import {format as pretty} from 'pretty-format';
|
||||
import type {EachTests} from '../bind';
|
||||
import type {Templates} from './interpolation';
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
*/
|
||||
|
||||
import {isPrimitive} from 'jest-get-type';
|
||||
// @ts-ignore
|
||||
import {format as pretty} from 'pretty-format';
|
||||
|
||||
export type Template = Record<string, unknown>;
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
|
||||
import chalk = require('chalk');
|
||||
import type {Global} from '@jest/types';
|
||||
// @ts-ignore
|
||||
import {format as pretty} from 'pretty-format';
|
||||
|
||||
type TemplateData = Global.TemplateData;
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
|
||||
import type {Jest} from '@jest/environment';
|
||||
import type {Global} from '@jest/types';
|
||||
// @ts-ignore
|
||||
import importedExpect = require('expect');
|
||||
|
||||
export declare const jest: Jest;
|
||||
|
|
|
@ -60,6 +60,7 @@ export default class HasteFS {
|
|||
}
|
||||
|
||||
*getAbsoluteFileIterator(): Iterable<Config.Path> {
|
||||
// @ts-ignore
|
||||
for (const file of this.getFileIterator()) {
|
||||
yield fastPath.resolve(this._rootDir, file);
|
||||
}
|
||||
|
@ -70,6 +71,7 @@ export default class HasteFS {
|
|||
pattern = new RegExp(pattern);
|
||||
}
|
||||
const files = [];
|
||||
// @ts-ignore
|
||||
for (const file of this.getAbsoluteFileIterator()) {
|
||||
if (pattern.test(file)) {
|
||||
files.push(file);
|
||||
|
@ -85,6 +87,7 @@ export default class HasteFS {
|
|||
const files = new Set<string>();
|
||||
const matcher = globsToMatcher(globs);
|
||||
|
||||
// @ts-ignore
|
||||
for (const file of this.getAbsoluteFileIterator()) {
|
||||
const filePath = root ? fastPath.relative(root, file) : file;
|
||||
if (matcher(replacePathSepForGlob(filePath))) {
|
||||
|
|
|
@ -184,6 +184,7 @@ export default class ModuleMap implements IModuleMap<SerializableModuleMap> {
|
|||
const previousSet = relativePathSet;
|
||||
const duplicates = new Map();
|
||||
|
||||
// @ts-ignore
|
||||
for (const [relativePath, type] of previousSet) {
|
||||
const duplicatePath = fastPath.resolve(this._raw.rootDir, relativePath);
|
||||
duplicates.set(duplicatePath, type);
|
||||
|
|
|
@ -274,6 +274,7 @@ export = async function watchmanCrawl(options: CrawlerOptions): Promise<{
|
|||
throw clientError;
|
||||
}
|
||||
|
||||
// @ts-ignore
|
||||
for (const [watchRoot, response] of results) {
|
||||
const fsRoot = normalizePathSep(watchRoot);
|
||||
const relativeFsRoot = fastPath.relative(rootDir, fsRoot);
|
||||
|
|
|
@ -676,11 +676,13 @@ export default class HasteMap extends EventEmitter {
|
|||
filesToProcess = changedFiles;
|
||||
}
|
||||
|
||||
// @ts-ignore
|
||||
for (const [relativeFilePath, fileMetadata] of removedFiles) {
|
||||
this._recoverDuplicates(hasteMap, relativeFilePath, fileMetadata[H.ID]);
|
||||
}
|
||||
|
||||
const promises = [];
|
||||
// @ts-ignore
|
||||
for (const relativeFilePath of filesToProcess.keys()) {
|
||||
if (
|
||||
this._options.skipPackageJson &&
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
*/
|
||||
|
||||
import type {FailedAssertion} from '@jest/test-result';
|
||||
// @ts-ignore
|
||||
import {format as prettyFormat} from 'pretty-format';
|
||||
|
||||
function messageFormatter({error, message, passed}: Options) {
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
// @ts-ignore
|
||||
import {format as prettyFormat} from 'pretty-format';
|
||||
|
||||
export default function isError(
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
|
||||
import type {AssertionError} from 'assert';
|
||||
import type {Config} from '@jest/types';
|
||||
// @ts-ignore
|
||||
import expect = require('expect');
|
||||
import type CallTracker from './jasmine/CallTracker';
|
||||
import type Env from './jasmine/Env';
|
||||
|
|
|
@ -11,6 +11,7 @@ import {promisify} from 'util';
|
|||
import {setFlagsFromString} from 'v8';
|
||||
import {runInNewContext} from 'vm';
|
||||
import {isPrimitive} from 'jest-get-type';
|
||||
// @ts-ignore
|
||||
import {format as prettyFormat} from 'pretty-format';
|
||||
|
||||
const tick = promisify(setImmediate);
|
||||
|
|
|
@ -14,12 +14,14 @@ import {
|
|||
DIFF_INSERT,
|
||||
Diff,
|
||||
DiffOptions as ImportDiffOptions,
|
||||
// @ts-ignore
|
||||
diff as diffDefault,
|
||||
diffStringsRaw,
|
||||
diffStringsUnified,
|
||||
} from 'jest-diff';
|
||||
import {getType, isPrimitive} from 'jest-get-type';
|
||||
import {
|
||||
// @ts-ignore
|
||||
format as prettyFormat,
|
||||
plugins as prettyFormatPlugins,
|
||||
} from 'pretty-format';
|
||||
|
|
|
@ -14,6 +14,7 @@ import micromatch = require('micromatch');
|
|||
import slash = require('slash');
|
||||
import StackUtils = require('stack-utils');
|
||||
import type {Config, TestResult} from '@jest/types';
|
||||
// @ts-ignore
|
||||
import {format as prettyFormat} from 'pretty-format';
|
||||
import type {Frame} from './types';
|
||||
|
||||
|
|
|
@ -653,6 +653,7 @@ export class ModuleMocker {
|
|||
const mockImpl = mockConfig.specificMockImpls.length
|
||||
? mockConfig.specificMockImpls.shift()
|
||||
: mockConfig.mockImpl;
|
||||
// @ts-ignore
|
||||
return mockImpl && mockImpl.apply(this, arguments);
|
||||
}
|
||||
|
||||
|
@ -663,10 +664,12 @@ export class ModuleMocker {
|
|||
specificMockImpl = mockConfig.mockImpl;
|
||||
}
|
||||
if (specificMockImpl) {
|
||||
// @ts-ignore
|
||||
return specificMockImpl.apply(this, arguments);
|
||||
}
|
||||
// Otherwise use prototype implementation
|
||||
if (f._protoImpl) {
|
||||
// @ts-ignore
|
||||
return f._protoImpl.apply(this, arguments);
|
||||
}
|
||||
|
||||
|
|
|
@ -456,6 +456,7 @@ export default class CoverageReporter extends BaseReporter {
|
|||
const converter = v8toIstanbul(
|
||||
res.url,
|
||||
fileTransform?.wrapperLength ?? 0,
|
||||
// @ts-ignore
|
||||
fileTransform && sourcemapContent
|
||||
? {
|
||||
originalSource: fileTransform.originalCode,
|
||||
|
|
|
@ -11,6 +11,7 @@ import {sync as resolveSync} from 'resolve';
|
|||
import {
|
||||
Options as ResolveExportsOptions,
|
||||
resolve as resolveExports,
|
||||
// @ts-ignore
|
||||
} from 'resolve.exports';
|
||||
import type {Config} from '@jest/types';
|
||||
import {
|
||||
|
|
|
@ -49,6 +49,7 @@ export type {
|
|||
export default class TestRunner {
|
||||
private readonly _globalConfig: Config.GlobalConfig;
|
||||
private readonly _context: TestRunnerContext;
|
||||
// @ts-ignore
|
||||
private readonly eventEmitter = new Emittery<TestEvents>();
|
||||
readonly __PRIVATE_UNSTABLE_API_supportsEventEmitters__: boolean = true;
|
||||
|
||||
|
@ -224,7 +225,9 @@ export default class TestRunner {
|
|||
});
|
||||
|
||||
const onInterrupt = new Promise((_, reject) => {
|
||||
// @ts-ignore
|
||||
watcher.on('change', state => {
|
||||
// @ts-ignore
|
||||
if (state.interrupted) {
|
||||
reject(new CancelRun());
|
||||
}
|
||||
|
@ -272,6 +275,7 @@ export default class TestRunner {
|
|||
eventName: Name,
|
||||
listener: (eventData: TestEvents[Name]) => void | Promise<void>,
|
||||
): Emittery.UnsubscribeFn {
|
||||
// @ts-ignore
|
||||
return this.eventEmitter.on(eventName, listener);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
// @ts-ignore
|
||||
import Emittery = require('emittery');
|
||||
import type {JestEnvironment} from '@jest/environment';
|
||||
import type {
|
||||
|
@ -54,7 +55,7 @@ export type TestRunnerSerializedContext = {
|
|||
|
||||
// TODO: Should live in `@jest/core` or `jest-watcher`
|
||||
type WatcherState = {interrupted: boolean};
|
||||
export interface TestWatcher extends Emittery<{change: WatcherState}> {
|
||||
export interface TestWatcher extends Emittery {
|
||||
state: WatcherState;
|
||||
setState(state: WatcherState): void;
|
||||
isInterrupted(): boolean;
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
// @ts-ignore
|
||||
import * as nativeModule from 'module';
|
||||
import * as path from 'path';
|
||||
import {URL, fileURLToPath, pathToFileURL} from 'url';
|
||||
|
|
|
@ -34,6 +34,7 @@ import {
|
|||
getLabelPrinter,
|
||||
matcherHint,
|
||||
} from 'jest-matcher-utils';
|
||||
// @ts-ignore
|
||||
import {format as prettyFormat} from 'pretty-format';
|
||||
import {
|
||||
aBackground2,
|
||||
|
|
|
@ -12,6 +12,7 @@ import naturalCompare = require('natural-compare');
|
|||
import type {Config} from '@jest/types';
|
||||
import {
|
||||
OptionsReceived as PrettyFormatOptions,
|
||||
// @ts-ignore
|
||||
format as prettyFormat,
|
||||
} from 'pretty-format';
|
||||
import {getSerializers} from './plugins';
|
||||
|
|
|
@ -10,6 +10,7 @@ import type {CoverageMap, CoverageMapData} from 'istanbul-lib-coverage';
|
|||
import type {ConsoleBuffer} from '@jest/console';
|
||||
import type {Config, TestResult, TransformTypes} from '@jest/types';
|
||||
import type {FS as HasteFS, ModuleMap} from 'jest-haste-map';
|
||||
// @ts-ignore
|
||||
import type Resolver from 'jest-resolve';
|
||||
|
||||
export interface RuntimeTransformResult extends TransformTypes.TransformResult {
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
|
||||
import chalk = require('chalk');
|
||||
import leven from 'leven';
|
||||
// @ts-ignore
|
||||
import {format as prettyFormat} from 'pretty-format';
|
||||
|
||||
const BULLET: string = chalk.bold('\u25cf');
|
||||
|
|
|
@ -61,7 +61,7 @@ export default class ExperimentalWorker implements WorkerInterface {
|
|||
initialize(): void {
|
||||
this._worker = new Worker(path.resolve(__dirname, './threadChild.js'), {
|
||||
eval: false,
|
||||
// @ts-expect-error: added in newer versions
|
||||
// @ts-ignore
|
||||
resourceLimits: this._options.resourceLimits,
|
||||
stderr: true,
|
||||
stdout: true,
|
||||
|
|
Loading…
Reference in New Issue