From c75c8d56c08bbec8c40cc397da139e74f84d6148 Mon Sep 17 00:00:00 2001 From: LeSingh1 Date: Fri, 29 May 2026 16:38:06 -0700 Subject: [PATCH 1/2] fix(fs): return Generator from walkSync and expandGlobSync walkSync and expandGlobSync are generator functions, so at runtime they already have iterator helpers (map, filter, take, drop, toArray, ...). Their declared return type IterableIterator hides those helpers from TypeScript, forcing callers to wrap with Array.from() or write a manual loop just to use them. Narrow the return type to Generator. Generator extends IterableIterator so existing callers stay assignment-compatible, but the helpers become visible: walkSync(".").map((e) => e.name).toArray() // now type-checks Async versions (walk, expandGlob) keep AsyncIterableIterator because the async iterator helpers aren't in the TypeScript lib that Deno currently ships, so claiming them would mislead callers. Fixes #7099 --- fs/expand_glob.ts | 4 ++-- fs/walk.ts | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/fs/expand_glob.ts b/fs/expand_glob.ts index 59c3b5a78f0e..8c6452b012fa 100644 --- a/fs/expand_glob.ts +++ b/fs/expand_glob.ts @@ -428,7 +428,7 @@ export async function* expandGlob( export function* expandGlobSync( glob: string | URL, options?: ExpandGlobOptions, -): IterableIterator { +): Generator { let { root, exclude = [], @@ -473,7 +473,7 @@ export function* expandGlobSync( function* advanceMatch( walkInfo: WalkEntry, globSegment: string, - ): IterableIterator { + ): Generator { if (!walkInfo.isDirectory) { return; } else if (globSegment === "..") { diff --git a/fs/walk.ts b/fs/walk.ts index 600e301cfa3f..825a780d17e3 100644 --- a/fs/walk.ts +++ b/fs/walk.ts @@ -878,7 +878,7 @@ export async function* walk( export function* walkSync( root: string | URL, options?: WalkOptions, -): IterableIterator { +): Generator { let { maxDepth = Infinity, includeFiles = true, From a6756d065c07ee3066f45a0dde59287a5fa1c36a Mon Sep 17 00:00:00 2001 From: LeSingh1 Date: Fri, 29 May 2026 17:13:04 -0700 Subject: [PATCH 2/2] fix: pin Generator type params for Deno v1.x yield* delegation Deno v1.x's TypeScript lib infers Generator's default TNext as unknown, which conflicts with the inner walkSync's yield* delegation expecting undefined (TS2766). Pin TReturn=void and TNext=undefined to match what the generators actually produce. --- fs/expand_glob.ts | 4 ++-- fs/walk.ts | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/fs/expand_glob.ts b/fs/expand_glob.ts index 8c6452b012fa..a2130b40b16c 100644 --- a/fs/expand_glob.ts +++ b/fs/expand_glob.ts @@ -428,7 +428,7 @@ export async function* expandGlob( export function* expandGlobSync( glob: string | URL, options?: ExpandGlobOptions, -): Generator { +): Generator { let { root, exclude = [], @@ -473,7 +473,7 @@ export function* expandGlobSync( function* advanceMatch( walkInfo: WalkEntry, globSegment: string, - ): Generator { + ): Generator { if (!walkInfo.isDirectory) { return; } else if (globSegment === "..") { diff --git a/fs/walk.ts b/fs/walk.ts index 825a780d17e3..ca587aa12c66 100644 --- a/fs/walk.ts +++ b/fs/walk.ts @@ -878,7 +878,7 @@ export async function* walk( export function* walkSync( root: string | URL, options?: WalkOptions, -): Generator { +): Generator { let { maxDepth = Infinity, includeFiles = true,