From 1108b4d97bd55f8b979d9682f1eb6d9c93497cdf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rub=C3=A9n=20Norte?= Date: Wed, 30 Oct 2024 04:58:04 -0700 Subject: [PATCH] Clean up API of PerformanceMark and PerformanceMeasure (#47241) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/47241 Changelog: [internal] The options for the internal constructor of `PerformanceMeasure` shouldn't be optional. This just cleans that up. Reviewed By: rshest Differential Revision: D64480048 fbshipit-source-id: d0275276b11bd329aa2e4667646c67608d562299 --- .../src/private/webapis/performance/Performance.js | 2 +- .../src/private/webapis/performance/UserTiming.js | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/react-native/src/private/webapis/performance/Performance.js b/packages/react-native/src/private/webapis/performance/Performance.js index 992f048faab..8c9695384c1 100644 --- a/packages/react-native/src/private/webapis/performance/Performance.js +++ b/packages/react-native/src/private/webapis/performance/Performance.js @@ -218,7 +218,7 @@ export default class Performance { const measure = new PerformanceMeasure(measureName, { startTime: computedStartTime, - duration: computedDuration, + duration: computedDuration ?? 0, detail: options?.detail, }); diff --git a/packages/react-native/src/private/webapis/performance/UserTiming.js b/packages/react-native/src/private/webapis/performance/UserTiming.js index 9018103e703..55ff802ea16 100644 --- a/packages/react-native/src/private/webapis/performance/UserTiming.js +++ b/packages/react-native/src/private/webapis/performance/UserTiming.js @@ -25,8 +25,8 @@ export type TimeStampOrName = DOMHighResTimeStamp | string; export type PerformanceMeasureInit = { detail?: DetailType, - startTime?: DOMHighResTimeStamp, - duration?: DOMHighResTimeStamp, + startTime: DOMHighResTimeStamp, + duration: DOMHighResTimeStamp, }; export class PerformanceMark extends PerformanceEntry { @@ -53,12 +53,12 @@ export class PerformanceMark extends PerformanceEntry { export class PerformanceMeasure extends PerformanceEntry { #detail: DetailType; - constructor(measureName: string, measureOptions?: PerformanceMeasureInit) { + constructor(measureName: string, measureOptions: PerformanceMeasureInit) { super({ name: measureName, entryType: 'measure', - startTime: measureOptions?.startTime ?? 0, - duration: measureOptions?.duration ?? 0, + startTime: measureOptions.startTime, + duration: measureOptions.duration, }); if (measureOptions) {