-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Iterator Helpers Typing #59908
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
Comments
How are you going to handle the new The methods of this class -- if introduced as a TypeScript This could be an uncommon occurrence, and it might be acceptable to rename the Have you given this any consideration? |
See a clear demonstration of the problem here: https://github.com/nikolaybotev/DefinitelyTyped/pull/1/files |
Isn't this just a rehash of #54481, in which it was decided that |
The downside with the approach taken in #58222 is that by maintaining backwards compatibility, new typing information is omitted / incorrect and can result in both working code failing type validation and failing code passing type validation.
Have you considered this?
Was it a conscious decision to pay this price to maintain backwards compatibility? Is this going to be mentioned in the release notes for TS6, which is where I assume this lands? |
Nevermind, I see that both of the above examples are handled correctly with the new type definitions... |
Looks like there is some serious TypeScript magic involved to make this work :-) glad it does. |
Thank you @Josh-Cena for the prompt response here. I was able to catch up on the work done to type Iterator Helpers and understand the solution to the problem of the divergence between the Iterator type and the Iterator value and how TypeScript's modules /namespaces, augmentation and class+interface merging allow the abstract nature of the javascript Iterator class to be properly expressed in a backwards-compatible manner. I also happily observed that the generic type signatures of Iterator and Iterable have been improved by adding the TReturn and TNext type arguments to the Iterable interface for example. This is a very welcome change! Now, TNext, and TReturn relate to some very obscure and not commonly used capabilities, but as supported features of the JavaScript runtime, I believe it is important that they are used in a manner that exposes as much as that niche JavaScript iterator/gnerator functionality to the typescript world. To that end, I have opened #59926 and done some background work on empirically determining Iterator Helpers behavior, and opened the first PR #59927 that updates the |
⚙ Compilation target
ESNext
⚙ Library
lib.esnext.d.ts
Missing / Incorrect Definition
global Iterator class
Sample Code
See also all the validation tests (working since Node.js 22.0.0) at https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Iterator#iterator_helpers
However, the following code should (ideally) continue working:
Documentation Link
The text was updated successfully, but these errors were encountered: