How TypeScript Solved Its Global Iterator Name Clash

Back
This is an AI-generated summary. for details.

In ES2025, JavaScript introduces a new global Iterator class with built-in helper methods like .map() and .filter(). This change creates a naming conflict in TypeScript because it already defines its own Iterator type interface for the iteration protocol.

To resolve the clash, TypeScript:

  • Introduces a global Iterator class whose instances are typed as a new IteratorObject.
  • Keeps the original Iterator interface unchanged for compatibility.
  • Ensures that built-in iterators now conform to IteratorObject, enabling use of the new helper methods without breaking old code.
Read the full article