Skip to content

Track upstream: build crashes with "Unknown DOM type: SpeechGrammar" on BCD ≥ 8.1.8 #33

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

With @mdn/browser-compat-data 8.1.8, npm run build crashes:

Error: Unknown DOM type: SpeechGrammar
    at convertDomTypeToTsTypeSimple (src/build/emitter.ts)
    ...
    at emitMethod (src/build/emitter.ts)

This first broke the 2026-11-07 weekly update.

BCD 8.1.8 records unflagged Firefox 160 support for the Web Speech API:

  • SpeechGrammarList is unprefixed in Chrome 139+ and Firefox 160+. It meets the two-engine rule and is kept.
  • SpeechGrammar: Chrome only exposes the interface object as webkitSpeechGrammar, so only one engine has it unprefixed. It's dropped.

SpeechGrammarList.item() still returns SpeechGrammar. The emitter doesn't filter return types that point at removed interfaces, so it throws.

Fork fix (#32)

  • src/build/bcd/keep-alive.ts: adds SpeechGrammar: [] to forceKeepAlive. This is the only upstream-facing change, written the way upstream would likely write it.
  • Fork-only, stays even after upstream fixes it: src/build/bcd/baseline.ts adds fullLibOnlyKeepAlive, which src/build/bcd.ts checks so Baseline cuts ignore the entry. Cuts don't need it, because applyReferenceClosure resurrects referenced interfaces. Forcing it into the cuts would emit an empty, non-Baseline SpeechGrammar with a constructor in every package.

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

Not fixed yet. Upstream is still on BCD 8.0.4 and has no SpeechGrammar entry in keep-alive.ts. It should hit the same crash as soon as it updates to BCD ≥ 8.1.8.

Another possible fix: the BCD data may be wrong. If Chrome actually exposes SpeechGrammar unprefixed, a corrected BCD entry would remove the need for any keep-alive. That's unverified, so check it before filing with mdn/browser-compat-data.

How to check

  • Does upstream src/build/bcd/keep-alive.ts contain SpeechGrammar? Or does upstream filter or keep it some other way (for example, a BCD fix, or emitter handling for return types that point at removed interfaces)?
  • Or: on upstream main with the latest BCD, does npm run build succeed without our entry?

When upstream fixes it

  • Upstream adds the same forceKeepAlive entry: take upstream's version of keep-alive.ts when merging, so the file matches upstream again. Keep fullLibOnlyKeepAlive in baseline.ts.
  • Upstream fixes it another way, or BCD fixes the data: remove our keep-alive.ts entry and the "SpeechGrammar" item in fullLibOnlyKeepAlive. Then rebuild and confirm that baselines/ and every Baseline cut (npm run baseline-years) don't change unexpectedly.

Close this issue once the fork's keep-alive.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 a different way. Upstream updated to BCD 8.1.8 in 988acab (microsoft#2602) and handled SpeechGrammar with a new KDL patch rather than a forceKeepAlive entry:

    // inputfiles/patches/speech.kdl
    // Blink has it in a different name webkitSpeechGrammar as of 2026-11
    interface SpeechGrammar exposed=Window

    Upstream src/build/bcd/keep-alive.ts still has no SpeechGrammar entry. Upstream's baselines/dom.generated.d.ts now emits SpeechGrammar with declare var SpeechGrammar: { new(): SpeechGrammar }.

    Next steps (from "When upstream fixes it")

    Upstream fixed it another way, so on the next upstream merge:

    • remove our SpeechGrammar: [] entry from keep-alive.ts and the "SpeechGrammar" item from fullLibOnlyKeepAlive in baseline.ts;
    • rebuild and confirm that baselines/ and every Baseline cut (npm run baseline-years) don't change unexpectedly.

    Caveat to check: speech.kdl is a patch, and patches are also applied to Baseline cuts. It might bring back the empty, non-Baseline SpeechGrammar with a constructor that fullLibOnlyKeepAlive was added to avoid. If the cuts do change that way, the fork may need its own handling for cuts.


    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