Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR fixes microsoft/TypeScript#62075. and is a result of the comment left on the PR over here, which I closed. Thanks for the advice on that 🙏 . I re-read your comment and figured out a path forward. I also dropped
UIEventfrom this PR.Recap
As a recap, this handles this bug report here. The issue is that
HTMLElement.onerror(and other elementonerrorhandlers) uses the incorrect interfaceOnErrorEventHandler, which has the signature:This causes a type error when assigning a Event-based handler:
It should be that
window.onerrorusesOnErrorEventHandlerand elements uses theEventobject.Changes
GlobalEventHandlers.onerrorto use anevent-basedhandler instead ofOnErrorEventHandler. I did this by updatingevents.kdlto useEventinstead ofErrorEvent.window.onerrorto keep usingOnErrorEventHandlersinceWindowis the only place where this handler signature is expected. The change is inoverridingTypes.jsonc.onerrordifferently. This was happening in the global scope "polluter". I fixed this by tracking already emitted members inemitAllMembers.isCovariantEventHandlerto not skip properties that have an explicit overrideType. This was need to handle Window'sonerroroverride.Before/After
Before:
After:
Testing
I added the
onerror.tstest file and updated theeventlistener.tstest file.Other Thoughts
This has been a crazy and fun bug to hunt down. I think I nailed it this time 😂