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

The return type of TreeMap should be Iterator<MapEntry<K, V>> #69

Open
cnyarx opened this issue Mar 9, 2020 · 2 comments
Open

The return type of TreeMap should be Iterator<MapEntry<K, V>> #69

cnyarx opened this issue Mar 9, 2020 · 2 comments

Comments

@cnyarx
Copy link

cnyarx commented Mar 9, 2020

In TreeMap's [Symbol.iterator]:
public [Symbol.iterator] ():Iterator<K> { return this.entrySet[Symbol.iterator](); }

The type of this.entrySet is a function, not an object of ImmutableEntrySetForTreeMap. So I think it should be defined like this:

public [Symbol.iterator]():Iterator<MapEntry<K, V>> { return this.entrySet()[Symbol.iterator](); }

Or there will get a ts(7053) error

@larrydiamond
Copy link
Owner

I'll take a look - thanks for reaching out!

@larrydiamond
Copy link
Owner

Ahhh! I just saw the confusion - I was typing up a response and I see how I confused you!

This is a really good question and perhaps I should change the type name there.

In TestTreeMap.spec.ts I see what I did - it was bad type naming in that method on my part and I apologize.

You're 100% right - it should be MapEntry<K,V> and not simply K.

On line 982 in my test that's exactly what I did.
let tsi:Iterator<MapEntry<PetStoreProduct,ValueClass>> = entrysetSymbol.iterator;

so the K that you get back from this method is really a MapEntry<K,V> and this is absolutely my bad.

I will patch the npm module to make this better.

Thank you very much for reaching out and letting me know about this!
Larry Diamond

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