1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 | import type { Config } from '@jest/types';
|
8 | import type { DuplicatesSet, HTypeValue, MockData, ModuleMapData, RawModuleMap } from './types';
|
9 | declare type ValueType<T> = T extends Map<string, infer V> ? V : never;
|
10 | export declare type SerializableModuleMap = {
|
11 | duplicates: ReadonlyArray<[string, [string, [string, [string, number]]]]>;
|
12 | map: ReadonlyArray<[string, ValueType<ModuleMapData>]>;
|
13 | mocks: ReadonlyArray<[string, ValueType<MockData>]>;
|
14 | rootDir: Config.Path;
|
15 | };
|
16 | export default class ModuleMap {
|
17 | static DuplicateHasteCandidatesError: typeof DuplicateHasteCandidatesError;
|
18 | private readonly _raw;
|
19 | private json;
|
20 | private static mapToArrayRecursive;
|
21 | private static mapFromArrayRecursive;
|
22 | constructor(raw: RawModuleMap);
|
23 | getModule(name: string, platform?: string | null, supportsNativePlatform?: boolean | null, type?: HTypeValue | null): Config.Path | null;
|
24 | getPackage(name: string, platform: string | null | undefined, _supportsNativePlatform: boolean | null): Config.Path | null;
|
25 | getMockModule(name: string): Config.Path | undefined;
|
26 | getRawModuleMap(): RawModuleMap;
|
27 | toJSON(): SerializableModuleMap;
|
28 | static fromJSON(serializableModuleMap: SerializableModuleMap): ModuleMap;
|
29 | /**
|
30 | * When looking up a module's data, we walk through each eligible platform for
|
31 | * the query. For each platform, we want to check if there are known
|
32 | * duplicates for that name+platform pair. The duplication logic normally
|
33 | * removes elements from the `map` object, but we want to check upfront to be
|
34 | * extra sure. If metadata exists both in the `duplicates` object and the
|
35 | * `map`, this would be a bug.
|
36 | */
|
37 | private _getModuleMetadata;
|
38 | private _assertNoDuplicates;
|
39 | static create(rootDir: Config.Path): ModuleMap;
|
40 | }
|
41 | declare class DuplicateHasteCandidatesError extends Error {
|
42 | hasteName: string;
|
43 | platform: string | null;
|
44 | supportsNativePlatform: boolean;
|
45 | duplicatesSet: DuplicatesSet;
|
46 | constructor(name: string, platform: string, supportsNativePlatform: boolean, duplicatesSet: DuplicatesSet);
|
47 | }
|
48 | export {};
|