Skip to content
New issue

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

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

BREAKING(fs): remove Deno.FsWatcher.prototype.return() #25445

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions cli/tsc/dts/lib.deno.ns.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3870,14 +3870,6 @@ declare namespace Deno {
readonly rid: number;
/** Stops watching the file system and closes the watcher resource. */
close(): void;
/**
* Stops watching the file system and closes the watcher resource.
*
* @deprecated This will be removed in Deno 2.0. See the
* {@link https://docs.deno.com/runtime/manual/advanced/migrate_deprecations | Deno 1.x to 2.x Migration Guide}
* for migration instructions.
*/
return?(value?: any): Promise<IteratorResult<FsEvent>>;
[Symbol.asyncIterator](): AsyncIterableIterator<FsEvent>;
}

Expand Down
9 changes: 0 additions & 9 deletions runtime/js/40_fs_events.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ const {
const {
ArrayIsArray,
ObjectPrototypeIsPrototypeOf,
PromiseResolve,
SymbolAsyncIterator,
ObjectDefineProperty,
} = primordials;
Expand Down Expand Up @@ -65,14 +64,6 @@ class FsWatcher {
}
}

// TODO(kt3k): This is deprecated. Will be removed in v2.0.
// See https://github.com/denoland/deno/issues/10577 for details
return(value) {
internals.warnOnDeprecatedApi("Deno.FsWatcher.return()", new Error().stack);
core.close(this.#rid);
return PromiseResolve({ value, done: true });
}

close() {
core.close(this.#rid);
}
Expand Down
24 changes: 2 additions & 22 deletions tests/unit/fs_events_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ Deno.test(
{ permissions: { read: true, write: true } },
async function watchFsBasic() {
const testDir = await makeTempDir();
const iter = Deno.watchFs(testDir);
using iter = Deno.watchFs(testDir);

// Asynchronously capture two fs events.
const eventsPromise = getTwoEvents(iter);
Expand All @@ -74,7 +74,7 @@ Deno.test(
{ permissions: { read: true, write: true } },
async function watchFsRename() {
const testDir = await makeTempDir();
const watcher = Deno.watchFs(testDir);
using watcher = Deno.watchFs(testDir);
async function waitForRename() {
for await (const event of watcher) {
if (event.kind === "rename") {
Expand All @@ -90,26 +90,6 @@ Deno.test(
},
);

// TODO(kt3k): This test is for the backward compatibility of `.return` method.
// This should be removed at 2.0
Deno.test(
{ permissions: { read: true, write: true } },
async function watchFsReturn() {
const testDir = await makeTempDir();
const iter = Deno.watchFs(testDir);

// Asynchronously loop events.
const eventsPromise = getTwoEvents(iter);

// Close the watcher.
await iter.return!();

// Expect zero events.
const events = await eventsPromise;
assertEquals(events, []);
},
);

Deno.test(
{ permissions: { read: true, write: true } },
async function watchFsClose() {
Expand Down