-
Notifications
You must be signed in to change notification settings - Fork 12.5k
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
Iterable and AsyncIterable interfaces should have full type arguments #32682
Comments
(Removed totally wrong assumption based on version from template. Sorry) |
I investigated this in #30790 (comment) and determined that supplying defaults resulted in additional complexity and some compatibility issues. We intend to leave |
I'd read it but couldn't read that Iterable has the same issues as IterableIterator. Does Iterable really have the same issues? And replacing Iterable with Generator may be good with return types but would be bad with argument types. Generator makes unnecessary constraints for them. These constraints make type errors with function calls. Also with return types Iterable makes good conservative interfaces. It is a good thing that tolerant for input and conservative for output. |
According to the note from the ecmascript spec 25.1.1.2, all well-formed iterators should be prepared for
|
That rule applies to Iterator interface (firstly). So it is not an issue of Iterable interface. |
Yeah I was trying to collect my thoughts earlier when I posted that but I got distracted by baseball ⚾️ ⚾️ ⚾️ . I think the note is relevant because @rbuckton states in the linked comment:
It seems like what he’s trying to make strict is the possibility that I dunno if any of this makes sense. I’ve been trying to upgrade some async iterator stuff to 3.6.2 and I’m having issues with assignability everywhere. I think a good middle ground is that type IterableIterator<T, TReturn extends undefined = undefined, TNext extends undefined = undefined> = Iterable<T> & Iterator<T, TReturn, TNext>; I want to get a better sense of the compatibility issues caused by |
@brainkim if |
I've generally been against adding type arguments to |
I guess what I wanted is for TNext and TReturn to be a union ( These days, I think forcing people to reason about the potential for TReturn/TNext types being |
I haven't seen any important downstream impacts of not having these parameters so let's call this good enough for now until there's more concrete feedback to drive potential changes here. |
Adding optional type arguments wouldn't affect compatibility. @rbuckton Right?
TypeScript Version: 3.4.0-dev.201xxxxx
Search Terms:
Code
Expected behavior:
Actual behavior:
Playground Link:
Related Issues:
The text was updated successfully, but these errors were encountered: