Skip to content
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

feat: add type parameter to EventTarget #1712

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Commits on May 3, 2024

  1. feat: add type parameter to EventTarget

    This introduces a type parameter to `EventTarget` such that the
    following is now possible:
    
    ```ts
    interface CustomMap {
      'test-event': CustomEvent<{x: number; y: number}>;
    }
    
    declare const customTarget: EventTarget<CustomMap>;
    
    customTarget.addEventListener('test-event', (event) => {
      // event is now `CustomEvent<{x: number; y: number}>`
      event.detail.x;
      event.detail.y;
    });
    ```
    
    Defaults to `T = any` to maintain existing behaviour otherwise.
    43081j committed May 3, 2024
    Configuration menu
    Copy the full SHA
    c8d61bf View commit details
    Browse the repository at this point in the history