UNPKG

2.03 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 { DuplicatesSet, HTypeValue, IModuleMap, RawModuleMap, SerializableModuleMap } from './types';
9export default class ModuleMap implements IModuleMap<SerializableModuleMap> {
10 static DuplicateHasteCandidatesError: typeof DuplicateHasteCandidatesError;
11 private readonly _raw;
12 private json;
13 private static mapToArrayRecursive;
14 private static mapFromArrayRecursive;
15 constructor(raw: RawModuleMap);
16 getModule(name: string, platform?: string | null, supportsNativePlatform?: boolean | null, type?: HTypeValue | null): Config.Path | null;
17 getPackage(name: string, platform: string | null | undefined, _supportsNativePlatform: boolean | null): Config.Path | null;
18 getMockModule(name: string): Config.Path | undefined;
19 getRawModuleMap(): RawModuleMap;
20 toJSON(): SerializableModuleMap;
21 static fromJSON(serializableModuleMap: SerializableModuleMap): ModuleMap;
22 /**
23 * When looking up a module's data, we walk through each eligible platform for
24 * the query. For each platform, we want to check if there are known
25 * duplicates for that name+platform pair. The duplication logic normally
26 * removes elements from the `map` object, but we want to check upfront to be
27 * extra sure. If metadata exists both in the `duplicates` object and the
28 * `map`, this would be a bug.
29 */
30 private _getModuleMetadata;
31 private _assertNoDuplicates;
32 static create(rootDir: Config.Path): ModuleMap;
33}
34declare class DuplicateHasteCandidatesError extends Error {
35 hasteName: string;
36 platform: string | null;
37 supportsNativePlatform: boolean;
38 duplicatesSet: DuplicatesSet;
39 constructor(name: string, platform: string, supportsNativePlatform: boolean, duplicatesSet: DuplicatesSet);
40}
41export {};