mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Fix Flow types for performance.measure (#52431)
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/52431 Changelog: [internal] `performance.measure` supports passing mark names as `start` and `end` options, so this fixes the Flow type before fixing the actual implementation. It also makes it so you can't specify both `end` and `duration`, enforced by the type system. Reviewed By: huntie Differential Revision: D77795991 fbshipit-source-id: e89f509c7efc2fa49d17d79bc19bc1d14e007871
This commit is contained in:
committed by
Facebook GitHub Bot
parent
2edda6d967
commit
34201d8387
@@ -38,12 +38,17 @@ declare var global: {
|
||||
const getCurrentTimeStamp: () => DOMHighResTimeStamp =
|
||||
NativePerformance?.now ?? global.nativePerformanceNow ?? (() => Date.now());
|
||||
|
||||
export type PerformanceMeasureOptions = {
|
||||
detail?: DetailType,
|
||||
start?: DOMHighResTimeStamp,
|
||||
duration?: DOMHighResTimeStamp,
|
||||
end?: DOMHighResTimeStamp,
|
||||
};
|
||||
export type PerformanceMeasureOptions =
|
||||
| {
|
||||
detail?: DetailType,
|
||||
start?: DOMHighResTimeStamp | string,
|
||||
duration?: DOMHighResTimeStamp,
|
||||
}
|
||||
| {
|
||||
detail?: DetailType,
|
||||
start?: DOMHighResTimeStamp | string,
|
||||
end?: DOMHighResTimeStamp | string,
|
||||
};
|
||||
|
||||
const ENTRY_TYPES_AVAILABLE_FROM_TIMELINE: $ReadOnlyArray<PerformanceEntryType> =
|
||||
['mark', 'measure'];
|
||||
|
||||
-7
@@ -159,7 +159,6 @@ describe('Performance', () => {
|
||||
startTime: 10,
|
||||
});
|
||||
|
||||
// $FlowFixMe[incompatible-call]
|
||||
const measure = performance.measure('measure-with-start-mark', {
|
||||
start: 'start-mark',
|
||||
});
|
||||
@@ -179,7 +178,6 @@ describe('Performance', () => {
|
||||
startTime: 50,
|
||||
});
|
||||
|
||||
// $FlowFixMe[incompatible-call]
|
||||
const measure = performance.measure('measure-with-end-mark', {
|
||||
end: 'end-mark',
|
||||
});
|
||||
@@ -205,7 +203,6 @@ describe('Performance', () => {
|
||||
|
||||
const measure = performance.measure(
|
||||
'measure-with-start-mark-and-end-mark',
|
||||
// $FlowFixMe[incompatible-call]
|
||||
{
|
||||
start: 'start-mark',
|
||||
end: 'end-mark',
|
||||
@@ -263,7 +260,6 @@ describe('Performance', () => {
|
||||
|
||||
const measure = performance.measure(
|
||||
'measure-with-start-mark-and-duration',
|
||||
// $FlowFixMe[incompatible-call]
|
||||
{
|
||||
start: 'start-mark',
|
||||
duration: 30,
|
||||
@@ -281,7 +277,6 @@ describe('Performance', () => {
|
||||
it('throws if the specified mark does NOT exist', () => {
|
||||
const missingStartMarkError = ensureInstance(
|
||||
getThrownError(() => {
|
||||
// $FlowFixMe[incompatible-call]
|
||||
performance.measure('measure', {
|
||||
start: 'start',
|
||||
end: 'end',
|
||||
@@ -299,7 +294,6 @@ describe('Performance', () => {
|
||||
|
||||
const missingEndMarkError = ensureInstance(
|
||||
getThrownError(() => {
|
||||
// $FlowFixMe[incompatible-call]
|
||||
performance.measure('measure', {
|
||||
start: 'start',
|
||||
end: 'end',
|
||||
@@ -314,7 +308,6 @@ describe('Performance', () => {
|
||||
|
||||
performance.mark('end');
|
||||
expect(() => {
|
||||
// $FlowFixMe[incompatible-call]
|
||||
performance.measure('measure', {
|
||||
start: 'start',
|
||||
end: 'end',
|
||||
|
||||
Reference in New Issue
Block a user