// Backwards-compatible iterator interfaces, augmented with iterator helper methods by lib.esnext.iterator in TypeScript 5.6. // The IterableIterator interface does not contain these methods, which creates assignability issues in places where IteratorObjects // are expected (eg. DOM-compatible APIs) if lib.esnext.iterator is loaded. // Also ensures that iterators returned by the Node API, which inherit from Iterator.prototype, correctly expose the iterator helper methods // if lib.esnext.iterator is loaded. // TODO: remove once this package no longer supports TS 5.5, and replace NodeJS.BuiltinIteratorReturn with BuiltinIteratorReturn. // Placeholders for TS <5.6 interface IteratorObject {} interface AsyncIteratorObject {} declare namespace NodeJS { // Populate iterator methods for TS <5.6 interface Iterator extends globalThis.Iterator {} interface AsyncIterator extends globalThis.AsyncIterator {} // Polyfill for TS 5.6's instrinsic BuiltinIteratorReturn type, required for DOM-compatible iterators type BuiltinIteratorReturn = ReturnType extends globalThis.Iterator ? TReturn : any; }