From 688060845275468b21be03efe46e2a7e5cd71afa Mon Sep 17 00:00:00 2001 From: Kenta Moriuchi Date: Sat, 25 Jan 2025 01:25:55 +0900 Subject: [PATCH] fix(types): `Deno.readDirSync`'s type returns an `IteratorObject` (#27805) --- cli/tsc/dts/lib.deno.ns.d.ts | 2 +- tests/unit/read_dir_test.ts | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/cli/tsc/dts/lib.deno.ns.d.ts b/cli/tsc/dts/lib.deno.ns.d.ts index e98f68ea38..7bfc3bb97b 100644 --- a/cli/tsc/dts/lib.deno.ns.d.ts +++ b/cli/tsc/dts/lib.deno.ns.d.ts @@ -3124,7 +3124,7 @@ declare namespace Deno { * @tags allow-read * @category File System */ - export function readDirSync(path: string | URL): Iterable; + export function readDirSync(path: string | URL): IteratorObject; /** Copies the contents and permissions of one file to another specified path, * by default creating a new file if needed, else overwriting. Fails if target diff --git a/tests/unit/read_dir_test.ts b/tests/unit/read_dir_test.ts index 9c5e6da79f..15dd59fcf0 100644 --- a/tests/unit/read_dir_test.ts +++ b/tests/unit/read_dir_test.ts @@ -25,6 +25,14 @@ Deno.test({ permissions: { read: true } }, function readDirSyncSuccess() { assertSameContent(files); }); +Deno.test( + { permissions: { read: true } }, + function readDirSyncResultHasIteratorHelperMethods() { + const iterator = Deno.readDirSync("tests/testdata"); + assertEquals(typeof iterator.map, "function"); + }, +); + Deno.test({ permissions: { read: true } }, function readDirSyncWithUrl() { const files = [ ...Deno.readDirSync(pathToAbsoluteFileUrl("tests/testdata")),