fix: add disposable methods for TypeScript 5.2 compatibility#82
Conversation
This makes the polyfill compatible with TypeScript 5.2+. Background: TypeScript 5.2 added `[Symbol.dispose]` to iterator types as part of the "Explicit Resource Management" proposal (https://github.com/tc39/proposal-explicit-resource-management). This property was missing in the polyfills iterators, making them incompatible with e.g. current JSDOM and TypeScript. This removes the explicit `IterableIterator` return type annotations from the `entries()`, `keys()` and `values()` generator functions in favor of the `Generator` type.
|
Hi, @klappradla. Thanks for working on this. This does fix the build, but we still need to implement I strongly encourage you to migrate away from using this library (and Jest, if you can). |
|
Alright, so what makes those generators disposable is Node.js itself. No action needed on our end, only adjust the tests to assert on disposable objects in Node.js v24 and higher, where they were added. |
Released: v5.0.0 🎉This has been released in v5.0.0. Get these changes by running the following command: Predictable release automation by Release. |
Yes, that was my understanding as well! Sorry, could have written that in the PR description. Thanks for the updates and the quick response 🙏
Sad but good to know, thanks also for that! |
Hi 👋
First off, thanks for you work on this 🙇 It's making my life a lot easier 💜
I recently ran into a problem when updating
JSDOMin my project, where the return type wasn't compatible any more:This PR fixes this and makes makes the polyfill compatible with TypeScript 5.2+ 🎉
Background
TypeScript 5.2 added
[Symbol.dispose]to iterator types as part of the Explicit Resource Management proposal.This property was missing in the polyfills iterators, making them incompatible with e.g. current JSDOM and TypeScript.
Change
This removes the explicit
IterableIteratorreturn type annotations from theentries(),keys()andvalues()generator functions in favor of theGeneratortype.