Skip to content

Incorrect Definition for Window.onError #28638

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

Closed
danjohnso opened this issue Nov 21, 2018 · 1 comment
Closed

Incorrect Definition for Window.onError #28638

danjohnso opened this issue Nov 21, 2018 · 1 comment
Assignees
Labels
Bug A bug in TypeScript Domain: lib.d.ts The issue relates to the different libraries shipped with TypeScript Help Wanted You can do this
Milestone

Comments

@danjohnso
Copy link

Search Terms:
window.onerror

The interface is incorrect for window.onerror. If there is a thrown error like:
throw "This is an error";

Then the type of error is string. The spec for this interface is that error can be any, not just a nullable error. I think the interface should be changed to match spec, or at least allow a string type error:

interface ErrorEventHandler {
    (event: Event | string, source?: string, fileno?: number, columnNumber?: number, error?: Error | string): void;
}

Expected behavior:
https://html.spec.whatwg.org/multipage/webappapis.html#errorevent
interface ErrorEvent : Event {
readonly attribute DOMString message;
readonly attribute USVString filename;
readonly attribute unsigned long lineno;
readonly attribute unsigned long colno;
readonly attribute any error;
};

Actual behavior:
interface ErrorEventHandler {
(event: Event | string, source?: string, fileno?: number, columnNumber?: number, error?: Error): void;
}

Related Issues:
#2838

@weswigham
Copy link
Member

PRs welcomed. You can find more information about contributing lib.d.ts fixes at https://github.com/Microsoft/TypeScript/blob/master/CONTRIBUTING.md#contributing-libdts-fixes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in TypeScript Domain: lib.d.ts The issue relates to the different libraries shipped with TypeScript Help Wanted You can do this
Projects
None yet
Development

No branches or pull requests

4 participants