index.d.ts 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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. */
  7. import { Config } from '@jest/types';
  8. import { ModuleMap } from 'jest-haste-map';
  9. import { ResolverConfig } from './types';
  10. declare type FindNodeModuleConfig = {
  11. basedir: Config.Path;
  12. browser?: boolean;
  13. extensions?: Array<string>;
  14. moduleDirectory?: Array<string>;
  15. paths?: Array<Config.Path>;
  16. resolver?: Config.Path | null;
  17. rootDir?: Config.Path;
  18. };
  19. declare type BooleanObject = Record<string, boolean>;
  20. declare namespace Resolver {
  21. type ResolveModuleConfig = {
  22. skipNodeResolution?: boolean;
  23. paths?: Array<Config.Path>;
  24. };
  25. }
  26. declare class Resolver {
  27. private readonly _options;
  28. private readonly _moduleMap;
  29. private readonly _moduleIDCache;
  30. private readonly _moduleNameCache;
  31. private readonly _modulePathCache;
  32. private readonly _supportsNativePlatform;
  33. constructor(moduleMap: ModuleMap, options: ResolverConfig);
  34. static clearDefaultResolverCache(): void;
  35. static findNodeModule(path: Config.Path, options: FindNodeModuleConfig): Config.Path | null;
  36. resolveModuleFromDirIfExists(dirname: Config.Path, moduleName: string, options?: Resolver.ResolveModuleConfig): Config.Path | null;
  37. resolveModule(from: Config.Path, moduleName: string, options?: Resolver.ResolveModuleConfig): Config.Path;
  38. isCoreModule(moduleName: string): boolean;
  39. getModule(name: string): Config.Path | null;
  40. getModulePath(from: Config.Path, moduleName: string): string;
  41. getPackage(name: string): Config.Path | null;
  42. getMockModule(from: Config.Path, name: string): Config.Path | null;
  43. getModulePaths(from: Config.Path): Array<Config.Path>;
  44. getModuleID(virtualMocks: BooleanObject, from: Config.Path, _moduleName?: string): string;
  45. private _getModuleType;
  46. private _getAbsolutePath;
  47. private _getMockPath;
  48. private _getVirtualMockPath;
  49. private _isModuleResolved;
  50. resolveStubModuleName(from: Config.Path, moduleName: string): Config.Path | null;
  51. }
  52. export = Resolver;
  53. //# sourceMappingURL=index.d.ts.map