-
Notifications
You must be signed in to change notification settings - Fork 439
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore: override OnErrorEventHandlerNonNull #1950
base: main
Are you sure you want to change the base?
Conversation
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. |
This would break window.onerror as it does receive a string. We should probably limit this string use case to window and not expose it to other interfaces. Perhaps we can modify GlobalEventHandlers.onerror with the general |
Okay |
Hello @saschanaz |
Hmm. Maybe we should first make some unit tests in https://github.com/microsoft/TypeScript-DOM-lib-generator/tree/main/unittests/files, something like: // onerror.ts
// this should not show error
window.onerror = (message: string, source: string, lineno: number, colno: number, error: any) => {};
// this also should not show error
declare var img: HTMLImageElement;
img.onerror = (event: Event) => {}; The goal here would be to make both pass. |
I have found some issues that i will fix |
inputfiles/addedTypes.jsonc
Outdated
}, | ||
"onerror": { | ||
"name": "onerror", | ||
"overrideType": "(event: Event) => void" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would only solve HTMLImageElement, maybe it should go to HTMLElement to solve it for other HTML elements.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And the CI fails: Error: generated/dom.generated.d.ts(11577,11): error TS2430: Interface 'HTMLImageElement' incorrectly extends interface 'HTMLElement'.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello @saschanaz,
I have applied the changes to all elements.
I was facing a build error due to the lack of documentation on the JSON format. However, replacing GlobalEventHandlers
with Omit<GlobalEventHandlers, 'onerror'>
solves the issue.
Maybe we could start documenting the format to help others in the future?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Omit sounds ok, but maybe you didn't push your change?
Documentations sounds nice. I wonder we can have a local schema file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe just adding some comments to existing type declarations would be okay.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello @saschanaz
My question is how to override the type?
I have tried to add it to the overriding types but it didn't work.
Hello @saschanaz |
fixes #1821