Skip to content

Conversation

@streamich
Copy link
Owner

No description provided.

Copilot AI review requested due to automatic review settings January 15, 2026 12:03
@streamich streamich changed the title Dir.{disposable,asyncDisposable and Dirent.parentPath Dir.{disposable,asyncDisposable} and Dirent.parentPath Jan 15, 2026
@streamich streamich changed the title Dir.{disposable,asyncDisposable} and Dirent.parentPath Dir.{dispose,asyncDispose} and Dirent.parentPath Jan 15, 2026
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds support for the Dir.disposable and Dir.asyncDisposable Symbol methods, and implements the Dirent.parentPath property as specified in Node.js. The Dirent.path property is deprecated in favor of parentPath.

Changes:

  • Added Symbol.dispose and Symbol.asyncDispose methods to the Dir class
  • Added parentPath property to IDirent interface and implementations
  • Deprecated the path property in favor of parentPath

Reviewed changes

Copilot reviewed 11 out of 12 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
tsconfig.json Updated exclude pattern to match nested test directories
src/node/types/misc.ts Added Disposable/AsyncDisposable interfaces to IDir, added parentPath property to IDirent
src/node/Dirent.ts Reordered properties to make parentPath primary, deprecated path property
src/node/Dir.ts Implemented Symbol.dispose and Symbol.asyncDispose methods
src/core/Link.ts Fixed getParentPath to return root separator for empty parent
src/node/tests/Dirent.test.ts Added comprehensive tests for parentPath property
src/node/tests/Dir.test.ts Added tests for disposable symbols
src/node/tests/promises.test.ts Added tests for promises.opendir
src/node/tests/volume/readdirSync.test.ts Updated tests to use parentPath and fixed property order
src/fsa-to-node/FsaNodeDirent.ts Added parentPath to constructor and deprecated path property
src/fsa-to-node/FsaNodeFs.ts Updated to pass parentPath to FsaNodeDirent, replaced hardcoded '/' with constant
src/fsa-to-node/tests/FsaNodeDirent.test.ts Added comprehensive tests for FsaNodeDirent.parentPath

files: T;
type: T;
}

Copy link

Copilot AI Jan 15, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Disposable and AsyncDisposable types are being used without import statements. These are built-in TypeScript types available in ES2022/ES2024, but the tsconfig.json specifies target "es2020" and lib ["ES2020", "dom"]. This may cause type errors if these types are not available in the TypeScript standard library for ES2020. Consider adding an explicit import or updating the lib to include ES2022/ES2024 disposables support, or defining these interfaces locally.

Suggested change
declare global {
interface SymbolConstructor {
readonly dispose: symbol;
readonly asyncDispose: symbol;
}
}
interface Disposable {
[Symbol.dispose](): void;
}
interface AsyncDisposable {
[Symbol.asyncDispose](): PromiseLike<void> | void;
}

Copilot uses AI. Check for mistakes.
const all = vol.readdirSync('/x', { withFileTypes: true });
const mapped = all.map(dirent => {
return { ...dirent };
return { ...(dirent as any) };
Copy link

Copilot AI Jan 15, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using as any bypasses TypeScript's type safety. Consider creating a proper type for the expected shape of the spread object instead of using type assertion. This pattern appears multiple times in the test file and reduces the value of type checking.

Copilot uses AI. Check for mistakes.
});

describe('disposable', () => {
it('should be closed for disposable', done => {
Copy link

Copilot AI Jan 15, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test name "should be closed for disposable" is unclear. Consider renaming to "should close directory when Symbol.dispose is called" to better describe what is being tested.

Copilot uses AI. Check for mistakes.
});
});

it('should be closed for async disposable', done => {
Copy link

Copilot AI Jan 15, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test name "should be closed for async disposable" is unclear. Consider renaming to "should close directory when Symbol.asyncDispose is called" to better describe what is being tested.

Suggested change
it('should be closed for async disposable', done => {
it('should close directory when Symbol.asyncDispose is called', done => {

Copilot uses AI. Check for mistakes.
Comment on lines +569 to +571
it('Reject when directory is a file', () => {
return expect(promises.opendir('/foo/bar')).rejects.toThrow(/ENOTDIR/);
});
Copy link

Copilot AI Jan 15, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test naming inconsistency: This test uses title case ("Reject when...") while the previous test uses sentence case ("Open an existing directory"). Consider using consistent naming convention, preferably lowercase for the first word to match Jest conventions (e.g., "rejects when directory is a file").

Copilot uses AI. Check for mistakes.
@streamich streamich merged commit 425a953 into master Jan 15, 2026
14 checks passed
@streamich streamich deleted the disposable-and-parent-path branch January 15, 2026 12:14
@github-actions
Copy link

🎉 This PR is included in version 4.52.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants