We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent c242deb commit 8aa0688Copy full SHA for 8aa0688
src/utils/events/BaseEvent.ts
@@ -1,12 +1,16 @@
1
+type Config<T> = EventInit & {
2
+ details: T;
3
+};
4
+
5
abstract class BaseEvent<T> extends Event {
- private _details?: T;
6
+ private _details: T;
7
- public get details(): T | undefined {
8
+ public get details(): T {
9
return this._details;
10
}
11
- constructor(name: string, eventInit?: EventInit & { details?: T }) {
- const { details, ...init } = eventInit ?? {};
12
+ constructor(name: string, config: Config<T>) {
13
+ const { details, ...init } = config;
14
15
super(name, init);
16
0 commit comments