-
Notifications
You must be signed in to change notification settings - Fork 12.6k
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
Event types do not exist in the Window interface #19758
Comments
Just FYI, a simpler workaround is to write declare global {
interface Window {
MouseEvent: typeof MouseEvent;
}
} |
If you'd like, I can submit a PR for this |
To model the spec/runtime behavior correctly, We have chosen a while back to not expose these types on Window. We have added ones thought to the interface, but i am afraid there is not really a clear pattern/principal here. See #18756 for related discussion. I think we should revisit the original issue of making I have created #19816 to track general issue. |
Thanks for the follow-up. I'll leave this up to your team's discretion and see about adding the workaround to @types/jsdom |
Automatically closing this issue for housekeeping purposes. The issue labels indicate that it is unactionable at the moment or has already been addressed. |
TypeScript Version: 2.7.0-dev.201xxxxx
Code
Expected behavior:
TypeScript compiles, running
node example.js
outputs the following to console, then exits:Actual behavior:
TypeScript fails to compile with the following error:
@types/jsdom defines the
DOMWindow
interface as:The
Window
interface it extends is the one defined by TypeScript. That interface is missing definitions for the Event types, although these Event types are declared outside theWindow
interface. In web browsers, the Event types exist both globally and on thewindow
object. TypeScript currently handles the former but not the latter.jsdom does in fact implement the Event types on the
dom.window
object. You can modify the code above to compile and behave as expected by extending theDOMWindow
interface, adding theMouseEvent
type to it, and casting thedom.window
object to this newly defined interface:I've spoken to the maintainer of @types/jsdom (see this issue) and they suggested raising an issue with your team instead. I agree, seeing as Event types exist on the
window
object in web browsers.The text was updated successfully, but these errors were encountered: