Commit 8084fe6
Align Flow lib defs for Node.js os with v24 (#55014)
Summary:
Pull Request resolved: #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: 29a91c49716bc08eb2c94892e3648db9e40b06d41 parent 83b21bb commit 8084fe6
1 file changed
Lines changed: 53 additions & 16 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2682 | 2682 | | |
2683 | 2683 | | |
2684 | 2684 | | |
2685 | | - | |
2686 | 2685 | | |
2687 | | - | |
2688 | 2686 | | |
2689 | 2687 | | |
2690 | 2688 | | |
| |||
2693 | 2691 | | |
2694 | 2692 | | |
2695 | 2693 | | |
2696 | | - | |
| 2694 | + | |
| 2695 | + | |
2697 | 2696 | | |
2698 | 2697 | | |
2699 | 2698 | | |
| |||
2702 | 2701 | | |
2703 | 2702 | | |
2704 | 2703 | | |
2705 | | - | |
2706 | 2704 | | |
2707 | 2705 | | |
2708 | 2706 | | |
| |||
2711 | 2709 | | |
2712 | 2710 | | |
2713 | 2711 | | |
2714 | | - | |
2715 | 2712 | | |
2716 | 2713 | | |
2717 | 2714 | | |
2718 | | - | |
| 2715 | + | |
| 2716 | + | |
| 2717 | + | |
| 2718 | + | |
| 2719 | + | |
| 2720 | + | |
| 2721 | + | |
| 2722 | + | |
| 2723 | + | |
| 2724 | + | |
| 2725 | + | |
2719 | 2726 | | |
2720 | 2727 | | |
2721 | 2728 | | |
2722 | 2729 | | |
| 2730 | + | |
2723 | 2731 | | |
2724 | 2732 | | |
2725 | 2733 | | |
| 2734 | + | |
2726 | 2735 | | |
2727 | 2736 | | |
2728 | | - | |
2729 | 2737 | | |
2730 | | - | |
| 2738 | + | |
| 2739 | + | |
| 2740 | + | |
| 2741 | + | |
| 2742 | + | |
| 2743 | + | |
| 2744 | + | |
| 2745 | + | |
| 2746 | + | |
| 2747 | + | |
| 2748 | + | |
2731 | 2749 | | |
| 2750 | + | |
| 2751 | + | |
2732 | 2752 | | |
2733 | 2753 | | |
2734 | 2754 | | |
2735 | 2755 | | |
2736 | | - | |
2737 | | - | |
2738 | | - | |
2739 | | - | |
2740 | | - | |
2741 | | - | |
2742 | | - | |
2743 | | - | |
| 2756 | + | |
| 2757 | + | |
| 2758 | + | |
| 2759 | + | |
| 2760 | + | |
| 2761 | + | |
| 2762 | + | |
| 2763 | + | |
| 2764 | + | |
| 2765 | + | |
| 2766 | + | |
2744 | 2767 | | |
| 2768 | + | |
| 2769 | + | |
| 2770 | + | |
| 2771 | + | |
| 2772 | + | |
| 2773 | + | |
| 2774 | + | |
| 2775 | + | |
| 2776 | + | |
| 2777 | + | |
| 2778 | + | |
| 2779 | + | |
| 2780 | + | |
| 2781 | + | |
2745 | 2782 | | |
2746 | 2783 | | |
2747 | 2784 | | |
| |||
0 commit comments