Skip to content

Commit

Permalink
ref(types): Add undefined as possible event type (#6584)
Browse files Browse the repository at this point in the history
Setting an `Event`'s property `type: undefined`, like we do in the SDK for `ErrorEvent`s 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 patch changes to `EventType` type declaration to also accept `undefined` as a value, thereby resolving the TS error.
  • Loading branch information
Lms24 committed Dec 20, 2022
1 parent 6e27ce9 commit 292cab8
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions packages/types/src/event.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,12 @@ export interface Event {
};
}

/** JSDoc */
export type EventType = 'transaction' | 'profile';
/**
* The type of an `Event`.
* Note that `ErrorEvent`s do not have a type (hence its undefined),
* while all other events are required to have one.
*/
export type EventType = 'transaction' | 'profile' | undefined;

export interface ErrorEvent extends Event {
type: undefined;
Expand Down

0 comments on commit 292cab8

Please sign in to comment.