UNPKG

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