Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 29 additions & 2 deletions packages/react-native/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,11 +161,38 @@ export * from './public/ReactNativeTypes';
import type {ErrorUtils} from '../Libraries/vendor/core/ErrorUtils';

declare global {
interface NodeRequire {
interface ReactNativeRequire {
(id: string): any;
/**
* Instructs Metro to generate a virtual module in the dependency graph,
* with dependencies on every file in the file map that matches the context params.
* This can be used to perform dynamic imports from files on disk at build time.
* @note Metro parses for `require.context()` calls in the code while building.
* @see https://github.com/facebook/metro/pull/822
* @see https://webpack.js.org/guides/dependency-management/#requirecontext
*/
context?(
directory: string,
useSubdirectories?: boolean,
regExp?: RegExp,
mode?: 'sync' | 'lazy',
): MetroRequireContext;
}

/**
* Returned from `require.context` provided by Metro.
* @see https://github.com/facebook/metro/pull/822
* @see https://webpack.js.org/guides/dependency-management/#requirecontext
*/
interface MetroRequireContext {
(id: string): any;
/**
* @return an array of all possible requests that the context module can handle.
*/
keys(): string[];
}

var require: NodeRequire;
var require: ReactNativeRequire;

/**
* Console polyfill
Expand Down