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

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

Merged
merged 1 commit into from Dec 20, 2022

Conversation

Lms24
Copy link
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