diff --git a/Libraries/Core/Devtools/parseErrorStack.js b/Libraries/Core/Devtools/parseErrorStack.js index e0039c85d6f..c85ddf05f13 100644 --- a/Libraries/Core/Devtools/parseErrorStack.js +++ b/Libraries/Core/Devtools/parseErrorStack.js @@ -16,7 +16,7 @@ import type {HermesParsedStack} from './parseHermesStack'; const parseHermesStack = require('./parseHermesStack'); function convertHermesStack(stack: HermesParsedStack): Array { - const frames = []; + const frames: Array = []; for (const entry of stack.entries) { if (entry.type !== 'FRAME') { continue; diff --git a/Libraries/Lists/FlatList.js b/Libraries/Lists/FlatList.js index 66e50b5f7a2..3da7714a670 100644 --- a/Libraries/Lists/FlatList.js +++ b/Libraries/Lists/FlatList.js @@ -571,8 +571,8 @@ class FlatList extends React.PureComponent, void> { const numColumns = numColumnsOrDefault(this.props.numColumns); if (onViewableItemsChanged) { if (numColumns > 1) { - const changed = []; - const viewableItems = []; + const changed: Array = []; + const viewableItems: Array = []; info.viewableItems.forEach(v => this._pushMultiColumnViewable(viewableItems, v), ); diff --git a/Libraries/Lists/ViewabilityHelper.js b/Libraries/Lists/ViewabilityHelper.js index 9c402c44107..104f3931c0a 100644 --- a/Libraries/Lists/ViewabilityHelper.js +++ b/Libraries/Lists/ViewabilityHelper.js @@ -214,7 +214,7 @@ class ViewabilityHelper { ) { return; } - let viewableIndices = []; + let viewableIndices: Array = []; if (itemCount) { viewableIndices = this.computeViewableItems( props, diff --git a/Libraries/Lists/VirtualizedList.js b/Libraries/Lists/VirtualizedList.js index 00343aff436..4e46e1458c3 100644 --- a/Libraries/Lists/VirtualizedList.js +++ b/Libraries/Lists/VirtualizedList.js @@ -811,7 +811,7 @@ export default class VirtualizedList extends StateSafePureComponent< ? styles.horizontallyInverted : styles.verticallyInverted : null; - const cells = []; + const cells: Array = []; const stickyIndicesFromProps = new Set(this.props.stickyHeaderIndices); const stickyHeaderIndices = []; diff --git a/Libraries/Lists/VirtualizedSectionList.js b/Libraries/Lists/VirtualizedSectionList.js index 14e1f12e252..6d9aecdc432 100644 --- a/Libraries/Lists/VirtualizedSectionList.js +++ b/Libraries/Lists/VirtualizedSectionList.js @@ -173,7 +173,7 @@ class VirtualizedSectionList< const listHeaderOffset = this.props.ListHeaderComponent ? 1 : 0; const stickyHeaderIndices = this.props.stickySectionHeadersEnabled - ? [] + ? ([]: Array) : undefined; let itemCount = 0; diff --git a/Libraries/LogBox/Data/LogBoxSymbolication.js b/Libraries/LogBox/Data/LogBoxSymbolication.js index 324f4d9379e..9e5aaa9ce56 100644 --- a/Libraries/LogBox/Data/LogBoxSymbolication.js +++ b/Libraries/LogBox/Data/LogBoxSymbolication.js @@ -27,7 +27,7 @@ const sanitize = ({ if (!Array.isArray(maybeStack)) { throw new Error('Expected stack to be an array.'); } - const stack = []; + const stack: Array = []; for (const maybeFrame of maybeStack) { let collapse = false; if ('collapse' in maybeFrame) { diff --git a/Libraries/LogBox/Data/__tests__/parseLogBoxLog-test.js b/Libraries/LogBox/Data/__tests__/parseLogBoxLog-test.js index 4b9a2fc8bf9..c92dc50bb75 100644 --- a/Libraries/LogBox/Data/__tests__/parseLogBoxLog-test.js +++ b/Libraries/LogBox/Data/__tests__/parseLogBoxLog-test.js @@ -11,6 +11,8 @@ 'use strict'; +import type {StackFrame} from '../../../Core/NativeExceptionsManager'; + const {parseLogBoxException, parseLogBoxLog} = require('../parseLogBoxLog'); describe('parseLogBoxLog', () => { @@ -230,7 +232,7 @@ describe('parseLogBoxLog', () => { name: '', isComponentError: false, componentStack: '', - stack: [], + stack: ([]: Array), id: 0, isFatal: true, }; @@ -267,7 +269,7 @@ describe('parseLogBoxLog', () => { name: '', isComponentError: false, componentStack: '', - stack: [], + stack: ([]: Array), id: 0, isFatal: true, }; @@ -327,7 +329,7 @@ If you are sure the module exists, try these steps: name: '', isComponentError: false, componentStack: '', - stack: [], + stack: ([]: Array), id: 0, isFatal: true, }; @@ -381,7 +383,7 @@ If you are sure the module exists, try these steps: name: '', isComponentError: false, componentStack: '', - stack: [], + stack: ([]: Array), id: 0, isFatal: true, }; @@ -429,7 +431,7 @@ Please follow the instructions at: fburl.com/rn-remote-assets name: '', isComponentError: false, componentStack: '', - stack: [], + stack: ([]: Array), id: 0, isFatal: true, }; @@ -475,7 +477,7 @@ Please follow the instructions at: fburl.com/rn-remote-assets name: '', isComponentError: false, componentStack: '', - stack: [], + stack: ([]: Array), id: 0, isFatal: true, }; diff --git a/Libraries/LogBox/Data/parseLogBoxLog.js b/Libraries/LogBox/Data/parseLogBoxLog.js index 64004956ebe..f0abc77961d 100644 --- a/Libraries/LogBox/Data/parseLogBoxLog.js +++ b/Libraries/LogBox/Data/parseLogBoxLog.js @@ -317,7 +317,7 @@ export function parseLogBoxLog(args: $ReadOnlyArray): {| message: Message, |} { const message = args[0]; - let argsWithoutComponentStack = []; + let argsWithoutComponentStack: Array = []; let componentStack: ComponentStack = []; // Extract component stack from warnings like "Some warning%s". diff --git a/Libraries/NativeComponent/StaticViewConfigValidator.js b/Libraries/NativeComponent/StaticViewConfigValidator.js index f1217d849e3..47ddb60c9cb 100644 --- a/Libraries/NativeComponent/StaticViewConfigValidator.js +++ b/Libraries/NativeComponent/StaticViewConfigValidator.js @@ -47,7 +47,7 @@ export function validate( nativeViewConfig: ViewConfig, staticViewConfig: ViewConfig, ): ValidationResult { - const differences = []; + const differences: Array = []; accumulateDifferences( differences, [], diff --git a/Libraries/Utilities/__tests__/useRefEffect-test.js b/Libraries/Utilities/__tests__/useRefEffect-test.js index 24a31f26fdf..ee163330d85 100644 --- a/Libraries/Utilities/__tests__/useRefEffect-test.js +++ b/Libraries/Utilities/__tests__/useRefEffect-test.js @@ -94,7 +94,7 @@ function mockEffectRegistry(): { mockEffectWithoutCleanup: string => () => void, registry: $ReadOnlyArray, } { - const registry = []; + const registry: Array = []; return { mockEffect(name: string): () => () => void { return instance => { diff --git a/Libraries/Utilities/groupByEveryN.js b/Libraries/Utilities/groupByEveryN.js index 51489ec0592..0ef4c12d216 100644 --- a/Libraries/Utilities/groupByEveryN.js +++ b/Libraries/Utilities/groupByEveryN.js @@ -28,7 +28,7 @@ function groupByEveryN(array: Array, n: number): Array> { const result = []; - let temp = []; + let temp: Array = []; for (let i = 0; i < array.length; ++i) { if (i > 0 && i % n === 0) { diff --git a/Libraries/Utilities/stringifySafe.js b/Libraries/Utilities/stringifySafe.js index 922ce9bd8bc..a61716ab49a 100644 --- a/Libraries/Utilities/stringifySafe.js +++ b/Libraries/Utilities/stringifySafe.js @@ -26,7 +26,9 @@ export function createStringifySafeWithLimits(limits: {| maxArrayLimit = Number.POSITIVE_INFINITY, maxObjectKeysLimit = Number.POSITIVE_INFINITY, } = limits; - const stack = []; + const stack: Array< + string | {+[string]: mixed} | {'...(truncated keys)...': number}, + > = []; /* $FlowFixMe[missing-this-annot] The 'this' type annotation(s) required by * Flow's LTI update could not be added via codemod */ function replacer(key: string, value: mixed): mixed { diff --git a/packages/hermes-inspector-msggen/src/Graph.js b/packages/hermes-inspector-msggen/src/Graph.js index d14760ce93d..359e4673924 100644 --- a/packages/hermes-inspector-msggen/src/Graph.js +++ b/packages/hermes-inspector-msggen/src/Graph.js @@ -63,7 +63,7 @@ export class Graph { root.children.add(node); } - const output = []; + const output: Array = []; postorder(root, output); // remove fake root node diff --git a/packages/hermes-inspector-msggen/src/index.js b/packages/hermes-inspector-msggen/src/index.js index 7952d539f30..5826643c753 100644 --- a/packages/hermes-inspector-msggen/src/index.js +++ b/packages/hermes-inspector-msggen/src/index.js @@ -44,9 +44,9 @@ function parseDomains( includeExperimental: Set, ): Descriptor { const desc = { - types: [], - commands: [], - events: [], + types: ([]: Array), + commands: ([]: Array), + events: ([]: Array), }; for (const obj of domainObjs) { diff --git a/packages/rn-tester/js/examples/XHR/XHRExampleFetch.js b/packages/rn-tester/js/examples/XHR/XHRExampleFetch.js index 4be970b0965..159a447a131 100644 --- a/packages/rn-tester/js/examples/XHR/XHRExampleFetch.js +++ b/packages/rn-tester/js/examples/XHR/XHRExampleFetch.js @@ -44,7 +44,7 @@ class XHRExampleFetch extends React.Component { return null; } - const responseHeaders = []; + const responseHeaders: Array = []; const keys = Object.keys(this.responseHeaders.map); for (let i = 0; i < keys.length; i++) { const key = keys[i];