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

fix type definitions #42

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

ethanresnick
Copy link

@ethanresnick ethanresnick commented Sep 10, 2023

entries() was typed as returning an iterator, but it actually returns an iterable. (If it returned an iterator, you could call map.entries().next(), but that's a runtime error.)

Meanwhile, keys() and values() do return iterators, which makes their types correct but their behavior a bit inconsistent with entries(). I'm not sure if that inconsistency is an issue, so I stuck to just fixing the types in this PR.

If the goal is to match the behavior of the built-in Map class, probably entries() really should return an iterator. To do that (in a sane way), though, woul be a breaking change.

`entries()` was typed as returning an iterator, but it actually returns an iterable. (If it returned an iterator, you could call `map.entries().next()`, but that's a runtime error.)

Meanwhile, `keys()` and `values()` do return iterators, which makes their types correct but their behavior a bit inconsistent with `entries()`. I'm not sure if that inconsistency is an issue, but addressing it would require a breaking change, so I stuck to just fixing the types in this PR.
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

Successfully merging this pull request may close these issues.

1 participant