Skip to content

Fix HTMLElement error event typings - #64345

Draft
Ryan Cavanaugh (RyanCavanaugh) with Copilot wants to merge 2 commits into
mainfrom
copilot/fix-htmlelement-onerror-definitions
Draft

Ryan Cavanaugh (RyanCavanaugh) with Copilot wants to merge 2 commits into
mainfrom
copilot/fix-htmlelement-onerror-definitions

Conversation

Copilot AI commented Sep 19, 2026

Copy link
Copy Markdown
Contributor

HTMLElement inherited Window-only error typings, so strict handlers for element load errors were rejected. Window.onerror remains special, but element error handlers should receive a single event object.

  • DOM typings

    • Change shared GlobalEventHandlers.onerror to a single-argument UIEvent handler.
    • Use common Event for the shared "error" event map entry.
    • Narrow "error" to UIEvent on element/document event maps.
    • Redeclare Window-specific "error": ErrorEvent and onerror: OnErrorEventHandler.
  • Regression coverage

    • Add compiler coverage for valid HTMLElement handlers and preserved Window behavior.
declare const el: HTMLElement;

el.onerror = (event: Event) => {};
el.addEventListener("error", (event: UIEvent) => {});

declare const win: Window;

win.onerror = (event, source, lineno, colno, error) => {};
win.addEventListener("error", (event: ErrorEvent) => {});

@typescript-automation typescript-automation Bot added For Milestone Bug PRs that fix a bug with a specific milestone labels Sep 19, 2026
@typescript-automation typescript-automation Bot added For Uncommitted Bug PR for untriaged, rejected, closed or missing bug and removed For Milestone Bug PRs that fix a bug with a specific milestone labels Sep 19, 2026
Co-authored-by: RyanCavanaugh <6685088+RyanCavanaugh@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix HTMLElement inherits onerror and addListener definitions Fix HTMLElement error event typings Sep 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

For Uncommitted Bug PR for untriaged, rejected, closed or missing bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

HTMLElement inherits onerror and addListener("error" definitions that are unique to Window

2 participants