Skip to content

ref(types): Add undefined as possible value to EventType#6584

Merged
Lms24 merged 1 commit intomasterfrom
lms-event-type
Dec 20, 2022
Merged

ref(types): Add undefined as possible value to EventType#6584
Lms24 merged 1 commit intomasterfrom
lms-event-type

Conversation

@Lms24
Copy link
Copy Markdown
Member

@Lms24 Lms24 commented Dec 20, 2022

Fixes #6575

As described in the issue, setting an Event's property type: undefined, like we do in the SDK for ErrorEvents

export interface ErrorEvent extends Event {
type: undefined;
}

causes a TS error, whenever the recommended exactOptionalPropertyTypes TS option is enabled. This option was introduced in TS 4.4. Since we're on TS 3.8, we couldn't catch this error.

This PR changes to EventType type declaration to also accept undefined as a value, thereby resolving the TS error.

Note:
The initially suggested fix to change the Event's type type to type: EventType | undefined causes TS errors all over the place as it would require us to set type explicitly to undefined whenever we create error events. I'd vote not to do this as it is a breaking change because it makes an optional parameter non-optional. Furthermore, it requires a lot of changes and also increases bundle size

@Lms24 Lms24 merged commit 292cab8 into master Dec 20, 2022
@Lms24 Lms24 deleted the lms-event-type branch December 20, 2022 12:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Interface 'ErrorEvent' incorrectly extends interface 'Event'

2 participants