index.d.ts
2.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
/**
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
import type { Config } from '@jest/types';
import type { ModuleMap } from 'jest-haste-map';
import type { ResolverConfig } from './types';
import ModuleNotFoundError from './ModuleNotFoundError';
import shouldLoadAsEsm from './shouldLoadAsEsm';
declare type FindNodeModuleConfig = {
basedir: Config.Path;
browser?: boolean;
extensions?: Array<string>;
moduleDirectory?: Array<string>;
paths?: Array<Config.Path>;
resolver?: Config.Path | null;
rootDir?: Config.Path;
throwIfNotFound?: boolean;
};
declare type BooleanObject = Record<string, boolean>;
declare namespace Resolver {
type ResolveModuleConfig = {
skipNodeResolution?: boolean;
paths?: Array<Config.Path>;
};
type ResolverType = Resolver;
}
declare class Resolver {
private readonly _options;
private readonly _moduleMap;
private readonly _moduleIDCache;
private readonly _moduleNameCache;
private readonly _modulePathCache;
private readonly _supportsNativePlatform;
constructor(moduleMap: ModuleMap, options: ResolverConfig);
static ModuleNotFoundError: typeof ModuleNotFoundError;
static tryCastModuleNotFoundError(error: unknown): ModuleNotFoundError | null;
static clearDefaultResolverCache(): void;
static findNodeModule(path: Config.Path, options: FindNodeModuleConfig): Config.Path | null;
static unstable_shouldLoadAsEsm: typeof shouldLoadAsEsm;
resolveModuleFromDirIfExists(dirname: Config.Path, moduleName: string, options?: Resolver.ResolveModuleConfig): Config.Path | null;
resolveModule(from: Config.Path, moduleName: string, options?: Resolver.ResolveModuleConfig): Config.Path;
private _isAliasModule;
isCoreModule(moduleName: string): boolean;
getModule(name: string): Config.Path | null;
getModulePath(from: Config.Path, moduleName: string): Config.Path;
getPackage(name: string): Config.Path | null;
getMockModule(from: Config.Path, name: string): Config.Path | null;
getModulePaths(from: Config.Path): Array<Config.Path>;
getModuleID(virtualMocks: BooleanObject, from: Config.Path, _moduleName?: string): string;
private _getModuleType;
private _getAbsolutePath;
private _getMockPath;
private _getVirtualMockPath;
private _isModuleResolved;
resolveStubModuleName(from: Config.Path, moduleName: string): Config.Path | null;
}
export = Resolver;