From dbb9252d288d614f08fa0d9364331835c427e080 Mon Sep 17 00:00:00 2001 From: Sam Zhou Date: Tue, 1 Nov 2022 13:37:03 -0700 Subject: [PATCH] Annotate `Array.map` returns when the implicit return type is widened Summary: Changelog: [Internal] Differential Revision: D40840078 fbshipit-source-id: 0104444060d8d6a1a22066d63579ac06ff715226 --- Libraries/LogBox/Data/__tests__/LogBoxLog-test.js | 2 +- .../Data/__tests__/LogBoxSymbolication-test.js | 2 +- .../__tests__/LogBoxInspectorStackFrames-test.js | 4 +++- packages/rn-tester/js/utils/testerStateUtils.js | 14 ++++++++------ 4 files changed, 13 insertions(+), 9 deletions(-) diff --git a/Libraries/LogBox/Data/__tests__/LogBoxLog-test.js b/Libraries/LogBox/Data/__tests__/LogBoxLog-test.js index 0281ad416e2..2327492caf9 100644 --- a/Libraries/LogBox/Data/__tests__/LogBoxLog-test.js +++ b/Libraries/LogBox/Data/__tests__/LogBoxLog-test.js @@ -50,7 +50,7 @@ function getLogBoxSymbolication(): {| } const createStack = (methodNames: Array) => - methodNames.map(methodName => ({ + methodNames.map((methodName): StackFrame => ({ column: null, file: 'file://path/to/file.js', lineNumber: 1, diff --git a/Libraries/LogBox/Data/__tests__/LogBoxSymbolication-test.js b/Libraries/LogBox/Data/__tests__/LogBoxSymbolication-test.js index 09ba968f465..3d272839c59 100644 --- a/Libraries/LogBox/Data/__tests__/LogBoxSymbolication-test.js +++ b/Libraries/LogBox/Data/__tests__/LogBoxSymbolication-test.js @@ -24,7 +24,7 @@ const symbolicateStackTrace: JestMockFn< > = (require('../../../Core/Devtools/symbolicateStackTrace'): any); const createStack = (methodNames: Array) => - methodNames.map(methodName => ({ + methodNames.map((methodName): StackFrame => ({ column: null, file: 'file://path/to/file.js', lineNumber: 1, diff --git a/Libraries/LogBox/UI/__tests__/LogBoxInspectorStackFrames-test.js b/Libraries/LogBox/UI/__tests__/LogBoxInspectorStackFrames-test.js index 83ce6b449e9..c1b6b50d97f 100644 --- a/Libraries/LogBox/UI/__tests__/LogBoxInspectorStackFrames-test.js +++ b/Libraries/LogBox/UI/__tests__/LogBoxInspectorStackFrames-test.js @@ -9,6 +9,8 @@ * @oncall react_native */ +import type {StackFrame} from '../../../Core/NativeExceptionsManager'; + import LogBoxInspectorStackFrames, { getCollapseMessage, } from '../LogBoxInspectorStackFrames'; @@ -33,7 +35,7 @@ const createLogWithFrames = (collapsedOptions: Array) => { }; const createCollapsedFrames = (collapsedOptions: Array) => { - return collapsedOptions.map(option => ({ + return collapsedOptions.map((option): StackFrame => ({ column: 1, file: 'dependency.js', lineNumber: 1, diff --git a/packages/rn-tester/js/utils/testerStateUtils.js b/packages/rn-tester/js/utils/testerStateUtils.js index 78ed6219039..a7ec6ae7c4d 100644 --- a/packages/rn-tester/js/utils/testerStateUtils.js +++ b/packages/rn-tester/js/utils/testerStateUtils.js @@ -62,11 +62,13 @@ export const getExamplesListWithBookmarksAndRecentlyUsed = ({ return null; } - const components = RNTesterList.Components.map(componentExample => ({ - ...componentExample, - isBookmarked: bookmarks.components.includes(componentExample.key), - exampleType: Screens.COMPONENTS, - })); + const components = RNTesterList.Components.map( + (componentExample): RNTesterModuleInfo => ({ + ...componentExample, + isBookmarked: bookmarks.components.includes(componentExample.key), + exampleType: Screens.COMPONENTS, + }), + ); const recentlyUsedComponents = recentlyUsed.components .map(recentComponentKey => @@ -78,7 +80,7 @@ export const getExamplesListWithBookmarksAndRecentlyUsed = ({ component => component.isBookmarked, ); - const apis = RNTesterList.APIs.map(apiExample => ({ + const apis = RNTesterList.APIs.map((apiExample): RNTesterModuleInfo => ({ ...apiExample, isBookmarked: bookmarks.apis.includes(apiExample.key), exampleType: Screens.APIS,