fix: use Object.prototype.hasOwnProperty.call for safe property checks (#27661)
The error 'TypeError: value.hasOwnProperty is not a function' can occur when objects are created without the standard Object prototype (e.g., via Object.create(null) or certain parsing methods). Using Object.prototype.hasOwnProperty.call() is the safe way to check for property existence on any object. Fixed in: - GetSlotsInputPipe (isById, isByUsernameAndEventTypeSlug, isByTeamSlugAndEventTypeSlug) - CancelBookingInputPipe (isCancelSeatedBookingInput) - CreateBookingInputPipe (isRecurringBookingInput, isInstantBookingInput) Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
@@ -77,6 +77,6 @@ export class CancelBookingInputPipe implements PipeTransform {
|
||||
private isCancelSeatedBookingInput(
|
||||
value: CancelBookingInput
|
||||
): value is CancelSeatedBookingInput_2024_08_13 {
|
||||
return value.hasOwnProperty("seatUid");
|
||||
return Object.prototype.hasOwnProperty.call(value, "seatUid");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -102,10 +102,12 @@ export class CreateBookingInputPipe implements PipeTransform {
|
||||
private isRecurringBookingInput(
|
||||
value: CreateBookingInput
|
||||
): value is CreateRecurringBookingInput_2024_08_13 {
|
||||
return value.hasOwnProperty("recurrenceCount");
|
||||
return Object.prototype.hasOwnProperty.call(value, "recurrenceCount");
|
||||
}
|
||||
|
||||
private isInstantBookingInput(value: CreateBookingInput): value is CreateInstantBookingInput_2024_08_13 {
|
||||
return value.hasOwnProperty("instant") && "instant" in value && value.instant === true;
|
||||
return (
|
||||
Object.prototype.hasOwnProperty.call(value, "instant") && "instant" in value && value.instant === true
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -131,18 +131,24 @@ export class GetSlotsInputPipe implements PipeTransform {
|
||||
}
|
||||
|
||||
private isById(value: GetSlotsInput_2024_09_04): value is ById_2024_09_04 {
|
||||
return value.hasOwnProperty("eventTypeId");
|
||||
return Object.prototype.hasOwnProperty.call(value, "eventTypeId");
|
||||
}
|
||||
|
||||
private isByUsernameAndEventTypeSlug(
|
||||
value: GetSlotsInput_2024_09_04
|
||||
): value is ByUsernameAndEventTypeSlug_2024_09_04 {
|
||||
return value.hasOwnProperty("username") && value.hasOwnProperty("eventTypeSlug");
|
||||
return (
|
||||
Object.prototype.hasOwnProperty.call(value, "username") &&
|
||||
Object.prototype.hasOwnProperty.call(value, "eventTypeSlug")
|
||||
);
|
||||
}
|
||||
|
||||
private isByTeamSlugAndEventTypeSlug(
|
||||
value: GetSlotsInput_2024_09_04
|
||||
): value is ByTeamSlugAndEventTypeSlug_2024_09_04 {
|
||||
return value.hasOwnProperty("teamSlug") && value.hasOwnProperty("eventTypeSlug");
|
||||
return (
|
||||
Object.prototype.hasOwnProperty.call(value, "teamSlug") &&
|
||||
Object.prototype.hasOwnProperty.call(value, "eventTypeSlug")
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user