Commit c75c8d5
committed
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<WalkEntry> 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<WalkEntry>. 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 #70991 parent cdf74a8 commit c75c8d5
2 files changed
Lines changed: 3 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
428 | 428 | | |
429 | 429 | | |
430 | 430 | | |
431 | | - | |
| 431 | + | |
432 | 432 | | |
433 | 433 | | |
434 | 434 | | |
| |||
473 | 473 | | |
474 | 474 | | |
475 | 475 | | |
476 | | - | |
| 476 | + | |
477 | 477 | | |
478 | 478 | | |
479 | 479 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
878 | 878 | | |
879 | 879 | | |
880 | 880 | | |
881 | | - | |
| 881 | + | |
882 | 882 | | |
883 | 883 | | |
884 | 884 | | |
| |||
0 commit comments