Align Flow lib defs for Node.js path with v24#55006
Closed
robhogan wants to merge 1 commit into
Closed
Conversation
Summary:
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)
Differential Revision: D89932753
meta-codesync Bot
pushed a commit
to react/metro
that referenced
this pull request
Dec 31, 2025
Summary: X-link: react/react-native#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: 9ae777b0be2fdfee8ef4a71e9d1f9fd1cd395215
|
This pull request has been merged in 07d2255. |
Collaborator
|
This pull request was successfully merged by @robhogan in 07d2255 When will my fix make it into a release? | How to file a pick request? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary:
This is an AI-assisted change to align the Flow definitions for the
pathmodule with the Node.js docs as at v24.New APIs:
matchesGlob(path, pattern)- Glob pattern matching (added in Node.js v22.5.0)booleanindicating if path matches the glob pattern*,?,[...],**, etc.path.matchesGlob('/foo/bar', '/foo/*')returnstruetoNamespacedPath(path)- Windows namespace-prefixed path conversion\\?\C:\path)Type Safety Improvements:
Replaced
anytypes - Proper typed interfacesposix: any→posix: path$PlatformPathwin32: any→win32: path$PlatformPathpath$PlatformPathtype definition with all methods and propertiesModern Readonly syntax for inputs - Following readonly rules
format()input: Changed toReadonly<{root?, dir?, base?, ext?, name?}>Made
parse()return type exact - Removed spread operator{root: string, dir: string, base: string, ext: string, name: string}...spread operator allowing extra propertiesPlatformPath includes parse return as readonly - Consistency
path$PlatformPathtype, the parse method returnsReadonly<{...}>References:
Readonly<T>for input parametersChangelog: [Internal]
Differential Revision: D89932753