Skip to content

fix type definitions - #42

Open
ethanresnick wants to merge 1 commit into
rsms:masterfrom
ethanresnick:patch-1
Open

fix type definitions#42
ethanresnick wants to merge 1 commit into
rsms:masterfrom
ethanresnick:patch-1

Conversation

@ethanresnick

@ethanresnick ethanresnick commented Sep 10, 2023

Copy link
Copy Markdown

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