A framework for building native applications using React
Align Flow lib defs for Node.js os with v24 (#55014)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/55014
This is an AI-assisted change to align the Flow definitions for the `os` module with the Node.js docs as at v24.
**New APIs:**
1. **`machine()`** - Returns machine type (added in v18.9.0, v16.18.0)
- Returns hardware name: `'x86_64'`, `'arm64'`, `'aarch64'`, etc.
- Different from `arch()` which returns the architecture Node.js was compiled for
- https://nodejs.org/api/os.html#osmachine
2. **`version()`** - Returns kernel version string (added in v13.11.0, v12.17.0)
- Example: `'Linux 5.15.0-1234-generic'`, `'Darwin Kernel Version 21.6.0'`
- https://nodejs.org/api/os.html#osversion
3. **`setPriority([pid,] priority)`** / **`getPriority([pid])`** - Process priority management
- Set/get scheduling priority for processes
- Priority constants available in `os.constants.priority`
- https://nodejs.org/api/os.html#ossetprioritypid-priority
- https://nodejs.org/api/os.html#osgetprioritypid
4. **`devNull` constant** - Path to null device (`'/dev/null'` on POSIX, `'\\\\.\\nul'` on Windows)
- https://nodejs.org/api/os.html#osdevnull
5. **`constants` object** - OS constants (signals, errno, priority, dlopen)
- `constants.signals` - Process signal constants
- `constants.errno` - Error number constants
- `constants.priority` - Process priority constants (PRIORITY_LOW, PRIORITY_HIGH, etc.) - Readonly
- `constants.dlopen` - Dynamic library loading constants
- https://nodejs.org/api/os.html#os-constants
**Type Safety Improvements:**
6. **`arch()` return type** - Now includes all 10 supported architectures:
- Added: `'loong64'` (LoongArch - newer Chinese CPU architecture)
- Complete list: `'arm'`, `'arm64'`, `'ia32'`, `'loong64'`, `'mips'`, `'mipsel'`, `'ppc64'`, `'riscv64'`, `'s390x'`, `'x64'`
- https://nodejs.org/api/os.html#osarch
7. **`platform()` return type** - Now union of 10 specific platforms instead of generic `string`:
- `'aix'`, `'android'`, `'darwin'`, `'freebsd'`, `'haiku'`, `'linux'`, `'openbsd'`, `'sunos'`, `'win32'`, `'cygwin'`
- https://nodejs.org/api/os.html#osplatform
8. **Output type definitions made exact** - Removed spread operators (outputs are mutable)
- `os$CPU` - Removed spread operators from main type and nested `times` object
- `os$NetIFAddr` - Added missing `scopeid?` and `cidr` properties, removed spread operator
- `os$UserInfo$*` - Types are mutable (not readonly) so consumers can modify returned values
- `networkInterfaces()` return type - Removed spread operator for exact type
9. **Input types use Readonly** - Following readonly rules
- `userInfo()` options: Changed to `Readonly<{encoding: 'buffer' | 'utf8'}>`
- Allows passing readonly types safely
**References:**
- Node.js os module docs: https://nodejs.org/api/os.html
Changelog: [Internal]
---
> Generated by [Confucius Code Assist (CCA)](https://www.internalfb.com/wiki/Confucius/Analect/Shared_Analects/Confucius_Code_Assist_(CCA)/)
[Confucius Session](https://www.internalfb.com/confucius?host=devvm45708.cln0.facebook.com&port=8086&tab=Chat&session_id=1a3aa26e-e5a9-11f0-8d47-71a4a90f0494&entry_name=Code+Assist), [Trace](https://www.internalfb.com/confucius?session_id=1a3aa26e-e5a9-11f0-8d47-71a4a90f0494&tab=Trace)
Reviewed By: vzaidman
Differential Revision: D89940756
fbshipit-source-id: 29a91c49716bc08eb2c94892e3648db9e40b06d4 R
Rob Hogan committed
8084fe62ed4ff49a881a14d8989b0cb616a5e40b
Parent: 83b21bb
Committed by meta-codesync[bot] <215208954+meta-codesync[bot]@users.noreply.github.com>
on 1/2/2026, 1:06:38 PM