Skip to content

Commit 5a9da2a

Browse files
CopilotneSpecc
andcommitted
Simplify null check and remove redundant conditions
Co-authored-by: neSpecc <3684889+neSpecc@users.noreply.github.com>
1 parent 68cb0e0 commit 5a9da2a

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

src/modules/event.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,8 @@ export default class EventPayload {
8484
// eslint-disable-next-line @typescript-eslint/no-explicit-any
8585
const value = (this.error as any)[prop];
8686

87-
// Only include serializable values
88-
if (value !== undefined && value !== null) {
87+
// Only include serializable values (checks for both undefined and null)
88+
if (value != null) {
8989
// Check if value is JSON-serializable
9090
if (this.isSerializable(value)) {
9191
// eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -106,13 +106,9 @@ export default class EventPayload {
106106
*/
107107
// eslint-disable-next-line @typescript-eslint/no-explicit-any
108108
private isSerializable(value: any): boolean {
109-
// Primitives are always serializable
110-
if (value === null || value === undefined) {
111-
return false;
112-
}
113-
114109
const type = typeof value;
115110

111+
// Primitives are serializable
116112
if (type === 'boolean' || type === 'number' || type === 'string') {
117113
return true;
118114
}

0 commit comments

Comments
 (0)