Commit 07d2255
Align Flow lib defs for Node.js path with v24 (#55006)
Summary:
Pull Request resolved: #55006
This is an AI-assisted change to align the Flow definitions for the `path` module with the Node.js docs as at v24.
**New APIs:**
1. **`matchesGlob(path, pattern)`** - Glob pattern matching (added in Node.js v22.5.0)
- Returns `boolean` indicating if path matches the glob pattern
- Supports standard glob syntax: `*`, `?`, `[...]`, `**`, etc.
- Example: `path.matchesGlob('/foo/bar', '/foo/*')` returns `true`
- https://nodejs.org/api/path.html#pathmatchesglobpath-pattern
2. **`toNamespacedPath(path)`** - Windows namespace-prefixed path conversion
- On Windows: converts path to namespace-prefixed path (e.g., `\\?\C:\path`)
- On POSIX: returns path unchanged
- Enables access to paths longer than 260 characters on Windows
- https://nodejs.org/api/path.html#pathtonamespacedpathpath
**Type Safety Improvements:**
3. **Replaced `any` types** - Proper typed interfaces
- Changed `posix: any` → `posix: path$PlatformPath`
- Changed `win32: any` → `win32: path$PlatformPath`
- Added `path$PlatformPath` type definition with all methods and properties
4. **Modern Readonly syntax for inputs** - Following readonly rules
- `format()` input: Changed to `Readonly<{root?, dir?, base?, ext?, name?}>`
- Allows passing readonly types safely (inputs should be readonly)
5. **Made `parse()` return type exact** - Removed spread operator
- Return type is now exact: `{root: string, dir: string, base: string, ext: string, name: string}`
- Previously had `...` spread operator allowing extra properties
- Note: Return type is NOT readonly (outputs are mutable so consumers can modify)
6. **PlatformPath includes parse return as readonly** - Consistency
- Within `path$PlatformPath` type, the parse method returns `Readonly<{...}>`
- This is for the type definition itself, not the actual module export
**References:**
- Node.js path module docs: https://nodejs.org/api/path.html
- Modern Flow syntax: exact-by-default, `Readonly<T>` for input parameters
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: D89932753
fbshipit-source-id: 9ae777b0be2fdfee8ef4a71e9d1f9fd1cd3952151 parent 50f310d commit 07d2255
1 file changed
Lines changed: 59 additions & 23 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
814 | 814 | | |
815 | 815 | | |
816 | 816 | | |
817 | | - | |
| 817 | + | |
818 | 818 | | |
819 | 819 | | |
820 | 820 | | |
| |||
1701 | 1701 | | |
1702 | 1702 | | |
1703 | 1703 | | |
1704 | | - | |
| 1704 | + | |
1705 | 1705 | | |
1706 | 1706 | | |
1707 | 1707 | | |
| |||
2593 | 2593 | | |
2594 | 2594 | | |
2595 | 2595 | | |
| 2596 | + | |
| 2597 | + | |
| 2598 | + | |
| 2599 | + | |
| 2600 | + | |
| 2601 | + | |
| 2602 | + | |
| 2603 | + | |
| 2604 | + | |
| 2605 | + | |
| 2606 | + | |
| 2607 | + | |
| 2608 | + | |
| 2609 | + | |
| 2610 | + | |
| 2611 | + | |
| 2612 | + | |
| 2613 | + | |
| 2614 | + | |
| 2615 | + | |
| 2616 | + | |
| 2617 | + | |
| 2618 | + | |
| 2619 | + | |
| 2620 | + | |
| 2621 | + | |
| 2622 | + | |
| 2623 | + | |
| 2624 | + | |
| 2625 | + | |
| 2626 | + | |
| 2627 | + | |
| 2628 | + | |
| 2629 | + | |
2596 | 2630 | | |
2597 | 2631 | | |
2598 | 2632 | | |
2599 | 2633 | | |
| 2634 | + | |
2600 | 2635 | | |
2601 | 2636 | | |
2602 | 2637 | | |
| |||
2610 | 2645 | | |
2611 | 2646 | | |
2612 | 2647 | | |
2613 | | - | |
2614 | 2648 | | |
2615 | | - | |
2616 | | - | |
2617 | | - | |
2618 | | - | |
2619 | | - | |
2620 | | - | |
2621 | | - | |
2622 | | - | |
2623 | | - | |
2624 | | - | |
| 2649 | + | |
| 2650 | + | |
| 2651 | + | |
| 2652 | + | |
| 2653 | + | |
| 2654 | + | |
| 2655 | + | |
| 2656 | + | |
| 2657 | + | |
| 2658 | + | |
| 2659 | + | |
| 2660 | + | |
2625 | 2661 | | |
2626 | 2662 | | |
2627 | 2663 | | |
| |||
2867 | 2903 | | |
2868 | 2904 | | |
2869 | 2905 | | |
2870 | | - | |
| 2906 | + | |
2871 | 2907 | | |
2872 | 2908 | | |
2873 | 2909 | | |
| |||
3379 | 3415 | | |
3380 | 3416 | | |
3381 | 3417 | | |
3382 | | - | |
| 3418 | + | |
3383 | 3419 | | |
3384 | 3420 | | |
3385 | 3421 | | |
3386 | 3422 | | |
3387 | | - | |
3388 | | - | |
| 3423 | + | |
| 3424 | + | |
3389 | 3425 | | |
3390 | 3426 | | |
3391 | 3427 | | |
3392 | 3428 | | |
3393 | | - | |
3394 | | - | |
| 3429 | + | |
| 3430 | + | |
3395 | 3431 | | |
3396 | 3432 | | |
3397 | 3433 | | |
3398 | 3434 | | |
3399 | | - | |
3400 | | - | |
| 3435 | + | |
| 3436 | + | |
3401 | 3437 | | |
3402 | 3438 | | |
3403 | 3439 | | |
3404 | 3440 | | |
3405 | | - | |
| 3441 | + | |
3406 | 3442 | | |
3407 | 3443 | | |
3408 | 3444 | | |
| |||
3613 | 3649 | | |
3614 | 3650 | | |
3615 | 3651 | | |
3616 | | - | |
| 3652 | + | |
3617 | 3653 | | |
3618 | 3654 | | |
3619 | 3655 | | |
| |||
0 commit comments