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

CustomEvent is not a generic type #1504

Closed
Cherry opened this issue Dec 21, 2023 · 0 comments · Fixed by #1759
Closed

CustomEvent is not a generic type #1504

Cherry opened this issue Dec 21, 2023 · 0 comments · Fixed by #1759
Assignees
Labels
bug Something isn't working types Related to @cloudflare/workers-types

Comments

@Cherry
Copy link
Contributor

Cherry commented Dec 21, 2023

In other implementations of CustomEvent, it's a generic type that supports passing a type for details property, like so:

interface SomeCustomEventData {
  foo: boolean;
  bar: string;
}

const customEvent = new CustomEvent<SomeCustomEventData>('something', {
  detail: {
    foo: false,
    bar: 'abc'
  }
});

customEvent.detail.bar // string type

Reference: https://tsplay.dev/wXgvVW

With workers-types, CustomEvent doesn't appear to support this, so detail is always any | undefined. Attempting to pass a type in just errors with Expected 0 type arguments, but got 1. ts(2558).

@Cherry Cherry added the types Related to @cloudflare/workers-types label Dec 21, 2023
@github-project-automation github-project-automation bot moved this to Untriaged in workers-sdk Dec 21, 2023
@jasnell jasnell added the bug Something isn't working label Jan 3, 2024
@github-project-automation github-project-automation bot moved this from Untriaged to Done in workers-sdk Mar 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working types Related to @cloudflare/workers-types
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants