Skip to content

Align Flow lib defs for Node.js path with v24#55006

Closed
robhogan wants to merge 1 commit into
mainfrom
export-D89932753
Closed

Align Flow lib defs for Node.js path with v24#55006
robhogan wants to merge 1 commit into
mainfrom
export-D89932753

Conversation

@robhogan

Copy link
Copy Markdown
Contributor

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)

  2. toNamespacedPath(path) - Windows namespace-prefixed path conversion

Type Safety Improvements:

  1. Replaced any types - Proper typed interfaces

    • Changed posix: anyposix: path$PlatformPath
    • Changed win32: anywin32: path$PlatformPath
    • Added path$PlatformPath type definition with all methods and properties
  2. 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)
  3. 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)
  4. 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:

Changelog: [Internal]

Generated by Confucius Code Assist (CCA)
Confucius Session, Trace

Differential Revision: D89932753

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-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Dec 31, 2025
@meta-codesync

meta-codesync Bot commented Dec 31, 2025

Copy link
Copy Markdown

@robhogan has exported this pull request. If you are a Meta employee, you can view the originating Diff in 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
@meta-codesync meta-codesync Bot closed this in 07d2255 Dec 31, 2025
@facebook-github-bot facebook-github-bot added the Merged This PR has been merged. label Dec 31, 2025
@meta-codesync

meta-codesync Bot commented Dec 31, 2025

Copy link
Copy Markdown

This pull request has been merged in 07d2255.

@react-native-bot

Copy link
Copy Markdown
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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. fb-exported Merged This PR has been merged. meta-exported p: Facebook Partner: Facebook Partner

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants