-
Notifications
You must be signed in to change notification settings - Fork 421
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
fix: updated CustomEvent.detail to be null when not defined #1586
base: main
Are you sure you want to change the base?
Conversation
Thanks for the PR! This section of the codebase is owned by @saschanaz - if they write a comment saying "LGTM" then it will be merged. |
I'll update the tests accordingly if this change is accepted |
Sounds fine to me. |
Can you perhaps also add unit tests for this? |
Is |
I'd prefer a separate file for custom events. |
I just noticed that it is possible to create broken CustomEvents: Do I try to address this too? Would this be a breaking change? Edit, suggested change: type CustomEventInit<T = any> = EventInit & (T extends {} ? { detail: T } : { detail?: T });
declare var CustomEvent: {
prototype: CustomEvent;
new <T>(
...args: T extends {}
? [type: string, eventInitDict: CustomEventInit<T>]
: [type: string, eventInitDict?: CustomEventInit<T>]
): CustomEvent<T>;
}; |
Looks right, although it starts to be over-complex... I'm okay with that if @sandersn says okay |
I don't know CustomEvent, but running the example from the playground link, it looks like interface CustomEventInit<T = any> extends EventInit {
detail: T; // note: you probably need to add the `T extends {} ? T : null` conditional type to map undefined -> null
}
declare var CustomEvent: {
prototype: CustomEvent;
new<T>(type: string, eventInitDict: CustomEventInit<T>): CustomEvent<T>
new(type: string): CustomEvent<null>
}; Of course this might break backward compatibility. I don't know how new or widely-used CustomEvent is. |
Fixes #1585