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

Extend Iterator and AsyncIterator with Symbol.dispose. #59264

Closed
wants to merge 1 commit into from

Conversation

jsonnull
Copy link

Fixes #59263

@typescript-bot typescript-bot added the For Uncommitted Bug PR for untriaged, rejected, closed or missing bug label Jul 13, 2024
@jsonnull
Copy link
Author

@microsoft-github-policy-service agree

@Josh-Cena
Copy link
Contributor

Iterator and AsyncIterator aren't what they mean in JS yet. #58222

@jsonnull
Copy link
Author

jsonnull commented Jul 13, 2024

Iterator and AsyncIterator aren't what they mean in JS yet. #58222

I think I know what you mean, I suppose I assumed that using ESNext lib opts you into the assumption of a compliant runtime.

Edited to add:

I'm not sure how this would be any different from some other ESNext feature requiring runtime support. Either the runtime has it or one polyfills it, but that shouldn't change the signatures of the types. The way I'm seeing it, the line of logic suggesting that Iterator doesn't get the Symbol.dispose definition would also preclude a DisposableStack definition from existing in esnext.disposable lib, yet it does.

@Josh-Cena
Copy link
Contributor

Josh-Cena commented Jul 13, 2024

No; the problem is more awkward than any other ESNext lib type. Perhaps #54481 summarizes it better?

In essence, Iterator in the lib def actually means the iterator protocol, and the built-in Iterator prototype is actually IterableIterator by convention, but there's simply nothing that corresponds to what would be the Iterator value-space object. You can take a look at https://github.com/microsoft/TypeScript/pull/58222/files#diff-34a90d6d878aa68ba4a76cff928f6697d65b8faae714fcbf56a9d8606e94119e for what the (possible) solution to the situation would be like.

@jsonnull jsonnull marked this pull request as draft July 15, 2024 12:53
@jsonnull
Copy link
Author

I'll take a look at revisiting this when some of the iterator changes required have moved forward.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
For Uncommitted Bug PR for untriaged, rejected, closed or missing bug
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Iterator and AsyncIterator missing Symbol.dispose method in esnext.disposable
4 participants