Skip to content

@types/jsdom missing Event definitions #21235

@KevinSnyderCodes

Description

@KevinSnyderCodes

@leonard-thieu

jsdom has Event constructors on the window object (e.g. MouseEvent), but there are no type definitions for these in @types/jsdom.

For example, the following is possible with jsdom, but missing the type definition for window.Event, causing the build to fail:

import { JSDOM } from 'jsdom';
let dom = new JSDOM();
let event = new dom.window.Event('someTypeArg');

In your current implementation the type definition for window is:

export interface DOMWindow extends Window { eval(script: string): void; }

Digging deeper, the Window interface as defined by TypeScript itself does not contain definitions for the Event types. However, they do have definitions for these types, just not on the Window interface.

This should be an easy fix, simply include these Event type definitions on the DOMWindow interface for @types/jsdom. They could also be added to the Window interface by the TypeScript team. I would also suggest the possibility of the jsdom team making the Event types global, but they are not interested in doing this as indicated in the MouseEvent link above.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions