Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

readDirSync's type definition should return an IteratorObject #27625

Open
nicolo-ribaudo opened this issue Jan 10, 2025 · 1 comment
Open

readDirSync's type definition should return an IteratorObject #27625

nicolo-ribaudo opened this issue Jan 10, 2025 · 1 comment

Comments

@nicolo-ribaudo
Copy link

nicolo-ribaudo commented Jan 10, 2025

Version: Deno 2.1.5

I noticed that Deno.readDirSync() returns an ArrayIterator object (I was typing Deno.readDirSync("some-dir") in a jupyter notebook and it logs Object [Array Iterator] {}). I wanted to see the list of folders, to I added .toArray() at the end of it and got a type checking error: .toArray() (and all iterator helpers) are not available on Iterable<...>.

Given that readDirSync does return an iterator, could its type definition be updated?

EDIT: Probably there are many functions on the Deno namespace, both sync and async, that should be updated :)

@nicolo-ribaudo nicolo-ribaudo changed the title readDirSync should return an IterableIterator readDirSync should return an IteratorObject Jan 10, 2025
@nicolo-ribaudo nicolo-ribaudo changed the title readDirSync should return an IteratorObject readDirSync should return an IteratorObject Jan 10, 2025
@nicolo-ribaudo nicolo-ribaudo changed the title readDirSync should return an IteratorObject readDirSync's type definition should return an IteratorObject Jan 10, 2025
@petamoriken
Copy link
Contributor

petamoriken commented Jan 11, 2025

Deno is not yet TypeScript 5.7, so we will have to wait for that.
#26950

My bad, IteratorObject was introduced in TypeScript 5.6.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants