Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

feat: fix fs.promises.glob return type to match Node.js API#1162

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
Copilot wants to merge2 commits intomaster
base:master
Choose a base branch
Loading
fromcopilot/fix-1161

Conversation

Copy link
Contributor

CopilotAI commentedAug 14, 2025
edited
Loading

Thefs.promises.glob method in memfs was incorrectly returningPromise<string[]> instead of the Node.js standardAsyncIterableIterator<string>. This made it incompatible with the native Node.js API and prevented users from using the standardfor await...of iteration pattern.

What was wrong

// Before: Incorrect return typefs.promises.glob:(pattern: string,options?:IGlobOptions)=>Promise<string[]>// Usage required awaiting the entire result setconstfiles=awaitfs.promises.glob('*.js');files.forEach(file=>console.log(file));

What's fixed

// After: Correct return type with proper overloadsfs.promises.glob:{(pattern:string|readonlystring[]):AsyncIterableIterator<string>;(pattern:string|readonlystring[],options:IGlobOptions&{withFileTypes:true}):AsyncIterableIterator<IDirent>;(pattern:string|readonlystring[],options:IGlobOptions&{withFileTypes?:false}):AsyncIterableIterator<string>;(pattern:string|readonlystring[],options?:IGlobOptions):AsyncIterableIterator<IDirent|string>;}// Usage now matches Node.js exactlyforawait(constfileoffs.promises.glob('*.js')){console.log(file);}// Supports withFileTypes optionforawait(constdirentoffs.promises.glob('*.js',{withFileTypes:true})){console.log(dirent.name,dirent.isFile());}// Supports multiple patternsforawait(constfileoffs.promises.glob(['*.js','*.ts'])){console.log(file);}

Implementation

  • CreatedGlobAsyncIterator: A custom AsyncIterator implementation that yields glob results incrementally
  • Added proper method overloads: Supporting all Node.js glob API variants includingwithFileTypes and multiple patterns
  • Maintained backward compatibility: Existing functionality works unchanged, just accessed via iteration
  • Enhanced test coverage: Added tests forwithFileTypes option and multiple pattern support

The fix ensures memfs now perfectly matches the Node.jsfs.promises.glob API, enabling seamless migration between real and in-memory file systems.

Fixes#1161.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn moreCopilot coding agent tips in the docs.

OlofFredriksson, daiscog, and ext reacted with thumbs up emoji
Co-authored-by: streamich <9773803+streamich@users.noreply.github.com>
CopilotAI changed the title[WIP] Bug: fs.promises.glob incorrect return typingfeat: fix fs.promises.glob return type to match Node.js APIAug 14, 2025
CopilotAI requested a review fromstreamichAugust 14, 2025 17:52
Copilot finished work on behalf ofstreamichAugust 14, 2025 17:52
@streamichstreamich marked this pull request as ready for reviewAugust 15, 2025 16:22
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@streamichstreamichAwaiting requested review from streamich

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Bug: fs.promises.glob incorrect return typing

2 participants

@streamich

[8]ページ先頭

©2009-2025 Movatter.jp