Flow: Add node: aliases to Node.js libdefs (#57600)

Summary:
Pull Request resolved: https://github.com/react/react-native/pull/57600

X-link: https://github.com/react/metro/pull/1783

Add `node:` aliases for every bare Node.js builtin declared by RN/Metro’s Flow libdefs. The aliases re-export the existing module types, so prefixed and unprefixed imports have the same definitions.

Changelog: [Internal]

Reviewed By: huntie

Differential Revision: D112732329

fbshipit-source-id: f38a6db58b6b3fbcbe566627ff368a2f329c9651
This commit is contained in:
Rob Hogan
2026-07-19 16:23:55 -07:00
committed by meta-codesync[bot]
parent 9f3108d61f
commit e64027865e
2 changed files with 135 additions and 49 deletions
+135
View File
@@ -753,6 +753,46 @@ declare module 'cluster' {
declare module.exports: Cluster;
}
declare module 'console' {
declare function assert(value: any, ...message: any): void;
declare function dir(
obj: Object,
options: {
showHidden: boolean,
depth: number,
colors: boolean,
...
},
): void;
declare function error(...data: any): void;
declare function info(...data: any): void;
declare function log(...data: any): void;
declare function time(label: any): void;
declare function timeEnd(label: any): void;
declare function trace(first: any, ...rest: any): void;
declare function warn(...data: any): void;
declare class Console {
constructor(stdout: stream$Writable, stdin?: stream$Writable): void;
assert(value: any, ...message: any): void;
dir(
obj: Object,
options: {
showHidden: boolean,
depth: number,
colors: boolean,
...
},
): void;
error(...data: any): void;
info(...data: any): void;
log(...data: any): void;
time(label: any): void;
timeEnd(label: any): void;
trace(first: any, ...rest: any): void;
warn(...data: any): void;
}
}
type crypto$createCredentialsDetails = any; // TODO
declare class crypto$Cipher extends stream$Duplex {
@@ -5874,6 +5914,11 @@ declare module 'node:assert/strict' {
declare module.exports: $Exports<'assert'>['strict'];
}
declare module 'node:buffer' {
export type * from 'buffer';
declare module.exports: $Exports<'buffer'>;
}
declare module 'node:child_process' {
export type * from 'child_process';
declare module.exports: $Exports<'child_process'>;
@@ -5884,16 +5929,31 @@ declare module 'node:cluster' {
declare module.exports: $Exports<'cluster'>;
}
declare module 'node:console' {
export type * from 'console';
declare module.exports: $Exports<'console'>;
}
declare module 'node:crypto' {
export type * from 'crypto';
declare module.exports: $Exports<'crypto'>;
}
declare module 'node:dgram' {
export type * from 'dgram';
declare module.exports: $Exports<'dgram'>;
}
declare module 'node:dns' {
export type * from 'dns';
declare module.exports: $Exports<'dns'>;
}
declare module 'node:domain' {
export type * from 'domain';
declare module.exports: $Exports<'domain'>;
}
declare module 'node:events' {
export type * from 'events';
declare module.exports: $Exports<'events'>;
@@ -5909,6 +5969,31 @@ declare module 'node:fs/promises' {
declare module.exports: $Exports<'fs'>['promises'];
}
declare module 'node:http' {
export type * from 'http';
declare module.exports: $Exports<'http'>;
}
declare module 'node:https' {
export type * from 'https';
declare module.exports: $Exports<'https'>;
}
declare module 'node:inspector' {
export type * from 'inspector';
declare module.exports: $Exports<'inspector'>;
}
declare module 'node:module' {
export type * from 'module';
declare module.exports: $Exports<'module'>;
}
declare module 'node:net' {
export type * from 'net';
declare module.exports: $Exports<'net'>;
}
declare module 'node:os' {
export type * from 'os';
declare module.exports: $Exports<'os'>;
@@ -5929,6 +6014,36 @@ declare module 'node:process' {
declare module.exports: $Exports<'process'>;
}
declare module 'node:punycode' {
export type * from 'punycode';
declare module.exports: $Exports<'punycode'>;
}
declare module 'node:querystring' {
export type * from 'querystring';
declare module.exports: $Exports<'querystring'>;
}
declare module 'node:readline' {
export type * from 'readline';
declare module.exports: $Exports<'readline'>;
}
declare module 'node:repl' {
export type * from 'repl';
declare module.exports: $Exports<'repl'>;
}
declare module 'node:stream' {
export type * from 'stream';
declare module.exports: $Exports<'stream'>;
}
declare module 'node:string_decoder' {
export type * from 'string_decoder';
declare module.exports: $Exports<'string_decoder'>;
}
declare module 'node:timers' {
export type * from 'timers';
declare module.exports: $Exports<'timers'>;
@@ -5939,6 +6054,16 @@ declare module 'node:timers/promises' {
declare module.exports: $Exports<'timers/promises'>;
}
declare module 'node:tls' {
export type * from 'tls';
declare module.exports: $Exports<'tls'>;
}
declare module 'node:tty' {
export type * from 'tty';
declare module.exports: $Exports<'tty'>;
}
declare module 'node:url' {
declare module.exports: $Exports<'url'>;
}
@@ -5953,7 +6078,17 @@ declare module 'node:v8' {
declare module.exports: $Exports<'v8'>;
}
declare module 'node:vm' {
export type * from 'vm';
declare module.exports: $Exports<'vm'>;
}
declare module 'node:worker_threads' {
export type * from 'worker_threads';
declare module.exports: $Exports<'worker_threads'>;
}
declare module 'node:zlib' {
export type * from 'zlib';
declare module.exports: $Exports<'zlib'>;
}
-49
View File
@@ -1,49 +0,0 @@
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow strict
* @format
*/
declare module 'console' {
declare function assert(value: any, ...message: any): void;
declare function dir(
obj: Object,
options: {
showHidden: boolean,
depth: number,
colors: boolean,
...
},
): void;
declare function error(...data: any): void;
declare function info(...data: any): void;
declare function log(...data: any): void;
declare function time(label: any): void;
declare function timeEnd(label: any): void;
declare function trace(first: any, ...rest: any): void;
declare function warn(...data: any): void;
declare class Console {
constructor(stdout: stream$Writable, stdin?: stream$Writable): void;
assert(value: any, ...message: any): void;
dir(
obj: Object,
options: {
showHidden: boolean,
depth: number,
colors: boolean,
...
},
): void;
error(...data: any): void;
info(...data: any): void;
log(...data: any): void;
time(label: any): void;
timeEnd(label: any): void;
trace(first: any, ...rest: any): void;
warn(...data: any): void;
}
}