Skip to content

Fully merge iterable types into existing definitions#2431

Closed
jakebailey wants to merge 1 commit intomicrosoft:mainfrom
jakebailey:merge-iterable
Closed

Fully merge iterable types into existing definitions#2431
jakebailey wants to merge 1 commit intomicrosoft:mainfrom
jakebailey:merge-iterable

Conversation

@jakebailey
Copy link
Member

The code to do it seems nasty (largely just had copilot to it), but this does merge everything together instead of just tacking the types onto the end.

@github-actions
Copy link
Contributor

Thanks for the PR!

This section of the codebase is owned by @saschanaz - if they write a comment saying "LGTM" then it will be merged.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors how iterable types are emitted in the TypeScript DOM library generator. Previously, iterable types were appended as separate interface augmentations at the end of the generated files. Now, they are integrated directly into the main interface definitions.

Changes:

  • Refactored iterator emission logic to emit iterable methods inline within interface declarations
  • Added helper functions to determine and convert sequence/iterable types
  • Modified parameter type conversion to use Iterable<T> instead of T[] when appropriate
  • Updated extends clauses to include iterator base types (e.g., Set<FontFace>, ReadonlyMap<K, V>)

Reviewed changes

Copilot reviewed 1 out of 6 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/build/emitter.ts Core refactoring: Added helper functions for iterable type detection and conversion; modified interface emission to inline iterable members; updated parameter type conversion logic
baselines/webworker.generated.d.ts Generated baseline showing iterable methods merged into interface definitions instead of appended sections
baselines/sharedworker.generated.d.ts Generated baseline with same pattern of merged iterable definitions
baselines/serviceworker.generated.d.ts Generated baseline with same pattern of merged iterable definitions
baselines/audioworklet.generated.d.ts Generated baseline with same pattern of merged iterable definitions

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@jakebailey
Copy link
Member Author

Not as nasty as I claimed, I think; it's just sort of the same code shifted outward. I went through and everything seems to be there for all declarations that moved / were replaced.

@Bashamega
Copy link
Contributor

One question, if we are going to merge them, why do we still need the *iterable.ts?

@jakebailey
Copy link
Member Author

jakebailey commented Feb 25, 2026

The stubs exist because people could have written the name explicitly in tsconfig or reference directive. Otherwise <6.0 doesn't have this merge.

(This PR just moves the declarations up from the bottom, since my original change for this was just a hack to tack them on at the bottom.)

@Bashamega
Copy link
Contributor

Got it, thanks for the reply

@jakebailey
Copy link
Member Author

microsoft/TypeScript#63193 implies this will cause more breaks. Nevermind.

@jakebailey jakebailey closed this Feb 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants