Skip to content

Track upstream: async_sequence parameters are emitted as invalid never<any> (e.g. ReadableStream.from) #34

Done

Description

@uhyo

This tracks a fix the fork carries in upstream-owned code, so we can drop it once microsoft/TypeScript-DOM-lib-generator fixes the same problem.

Problem

Upstream added async_sequence support (whatwg/streams#1372) in src/build/emitter.ts. convertBaseType() returns "never" for an async_sequence type, with the comment "Use 'never' to signal omission in type generation". But nothing actually omits the members that use it. The emitter goes on to print the type with its subtype, which produces a declaration that doesn't parse:

from(asyncIterable: never<any>): ReadableStream<any>;

We hit this when merging upstream into the fork with BCD 8 (merge commit 2931264). BCD 8 keeps ReadableStream.from, the method whose only overload takes an async_sequence.

Fork fix (merged in 2931264)

src/build/emitter.ts drops the method overloads whose parameters use async_sequence. If no overload is left, it drops the whole method (typeUsesAsyncSequence, signatureUsesAsyncSequence, isOmittedForAsyncSequence, and the extra .filter(...) calls in emitMethod / emitMethods). The build logs Skipping generation for from since it uses async_sequence type for each skipped method.

This fix isn't specific to Baseline. It's a plain upstream bug fix and could be sent upstream as is.

Upstream status (checked 2026-11-07, upstream main @ 51e2d51)

Not fixed yet. Upstream's emitter.ts still returns "never" without omitting anything. Upstream's output doesn't show the bug yet because it's on BCD 8.0.4, which doesn't keep ReadableStream.from. It should show up when upstream updates BCD.

How to check

  • Does upstream src/build/emitter.ts omit members that use async_sequence, or emit them properly (for example as AsyncIterable<T> in the asynciterable variant)?
  • Or: on upstream main with the latest BCD, does the generated output have never< anywhere, and does ReadableStream.from come out valid?

When upstream fixes it

  • Take upstream's emitter.ts changes when merging, and remove our async_sequence filtering so it doesn't run twice or conflict.
  • If upstream emits ReadableStream.from instead of omitting it, the generated types change. Check baselines/ and every Baseline cut (npm run baseline-years), and expect a package republish.

Close this issue once the fork's async_sequence handling in emitter.ts matches upstream again.

Activity

  1. uhyo commented on Nov 30, 2026

    @uhyo
    OwnerAuthor

    Upstream status (checked 2026-11-30, upstream main @ f7effdf)

    Fixed upstream. In 2511236 (microsoft#2557, "Bump mdn BCD to 8.0.5"), upstream replaced the "never" placeholder with real emission. convertBaseType() now returns ["AsyncIterable", "Iterable"] when includeIterable is set and ["Iterable"] otherwise. emitAsyncIterator now emits the methods that take async_sequence arguments in the asynciterable variant (hasAsyncSequenceArgument / filterMethodsBySignature). Later emitter commits (a3f7c80, ddef56e, f95b644, f7effdf) don't touch this.

    Upstream's baselines/dom.generated.d.ts now contains:

    from(asyncIterable: AsyncIterable<any> | Iterable<any>): ReadableStream;

    and no never<.

    Next steps (from "When upstream fixes it")

    • Take upstream's emitter.ts changes when merging, and remove our async_sequence filtering (typeUsesAsyncSequence, signatureUsesAsyncSequence, isOmittedForAsyncSequence, and the extra .filter(...) calls) so it doesn't run twice or conflict.
    • Upstream emits ReadableStream.from instead of omitting it, so the generated types will change. Check baselines/ and every Baseline cut (npm run baseline-years), and expect a package republish.

    Generated by Claude Code

  2. uhyo commented on Dec 1, 2026

    @uhyo
    OwnerAuthor

    Resolved by #40, which merged upstream main @ f7effdf into baseline-filter and dropped the fork's version of this fix in favour of upstream's. Closing.


    Generated by Claude Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions