-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmetroRequire.d.ts
49 lines (45 loc) · 1.89 KB
/
metroRequire.d.ts
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
// Based on https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/webpack-env/index.d.ts
// Adds support for the runtime `require.context` method.
// https://github.com/facebook/metro/pull/822/
declare namespace __MetroModuleApi {
interface RequireContext {
/** Return the keys that can be resolved. */
keys(): string[];
(id: string): any;
<T>(id: string): T;
/** **Unimplemented:** Return the module identifier for a user request. */
resolve(id: string): string;
/** **Unimplemented:** Readable identifier for the context module. */
id: string;
}
interface RequireFunction {
/**
* Returns the exports from a dependency. The call is sync. No request to the server is fired. The compiler ensures that the dependency is available.
*/
(path: string): any;
<T>(path: string): T;
/**
* **Experimental:** Import all modules in a given directory. This module dynamically updates when the files in a directory are added or removed.
*
* **Enabling:** This feature can be enabled by setting the `transformer.unstable_allowRequireContext` property to `true` in your Metro configuration.
*
* @param path File path pointing to the directory to require.
* @param recursive Should search for files recursively. Optional, default `true` when `require.context` is used.
* @param filter Filename filter pattern for use in `require.context`. Optional, default `.*` (any file) when `require.context` is used.
* @param mode Mode for resolving dynamic dependencies. Defaults to `sync`.
*/
context(
path: string,
recursive?: boolean,
filter?: RegExp,
mode?: 'sync' | 'eager' | 'weak' | 'lazy' | 'lazy-once',
): RequireContext;
}
}
/**
* Declare process variable
*/
declare namespace NodeJS {
interface Require extends __MetroModuleApi.RequireFunction {}
}
declare const process: NodeJS.Process;