Annotate empty arrays in xplat

Summary: Changelog: [Internal]

Differential Revision: D40410427

fbshipit-source-id: f819fcb00673e19b21aecb383541850436805a0e
This commit is contained in:
Sam Zhou
2022-10-17 12:40:57 -07:00
committed by Facebook GitHub Bot
parent cb2dcd327c
commit a0ee6fae5e
15 changed files with 27 additions and 23 deletions
+1 -1
View File
@@ -16,7 +16,7 @@ import type {HermesParsedStack} from './parseHermesStack';
const parseHermesStack = require('./parseHermesStack');
function convertHermesStack(stack: HermesParsedStack): Array<StackFrame> {
const frames = [];
const frames: Array<StackFrame> = [];
for (const entry of stack.entries) {
if (entry.type !== 'FRAME') {
continue;
+2 -2
View File
@@ -571,8 +571,8 @@ class FlatList<ItemT> extends React.PureComponent<Props<ItemT>, void> {
const numColumns = numColumnsOrDefault(this.props.numColumns);
if (onViewableItemsChanged) {
if (numColumns > 1) {
const changed = [];
const viewableItems = [];
const changed: Array<ViewToken> = [];
const viewableItems: Array<ViewToken> = [];
info.viewableItems.forEach(v =>
this._pushMultiColumnViewable(viewableItems, v),
);
+1 -1
View File
@@ -214,7 +214,7 @@ class ViewabilityHelper {
) {
return;
}
let viewableIndices = [];
let viewableIndices: Array<number> = [];
if (itemCount) {
viewableIndices = this.computeViewableItems(
props,
+1 -1
View File
@@ -811,7 +811,7 @@ export default class VirtualizedList extends StateSafePureComponent<
? styles.horizontallyInverted
: styles.verticallyInverted
: null;
const cells = [];
const cells: Array<any | React.Node> = [];
const stickyIndicesFromProps = new Set(this.props.stickyHeaderIndices);
const stickyHeaderIndices = [];
+1 -1
View File
@@ -173,7 +173,7 @@ class VirtualizedSectionList<
const listHeaderOffset = this.props.ListHeaderComponent ? 1 : 0;
const stickyHeaderIndices = this.props.stickySectionHeadersEnabled
? []
? ([]: Array<number>)
: undefined;
let itemCount = 0;
+1 -1
View File
@@ -27,7 +27,7 @@ const sanitize = ({
if (!Array.isArray(maybeStack)) {
throw new Error('Expected stack to be an array.');
}
const stack = [];
const stack: Array<StackFrame> = [];
for (const maybeFrame of maybeStack) {
let collapse = false;
if ('collapse' in maybeFrame) {
@@ -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<StackFrame>),
id: 0,
isFatal: true,
};
@@ -267,7 +269,7 @@ describe('parseLogBoxLog', () => {
name: '',
isComponentError: false,
componentStack: '',
stack: [],
stack: ([]: Array<StackFrame>),
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<StackFrame>),
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<StackFrame>),
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<StackFrame>),
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<StackFrame>),
id: 0,
isFatal: true,
};
+1 -1
View File
@@ -317,7 +317,7 @@ export function parseLogBoxLog(args: $ReadOnlyArray<mixed>): {|
message: Message,
|} {
const message = args[0];
let argsWithoutComponentStack = [];
let argsWithoutComponentStack: Array<mixed> = [];
let componentStack: ComponentStack = [];
// Extract component stack from warnings like "Some warning%s".
@@ -47,7 +47,7 @@ export function validate(
nativeViewConfig: ViewConfig,
staticViewConfig: ViewConfig,
): ValidationResult {
const differences = [];
const differences: Array<Difference> = [];
accumulateDifferences(
differences,
[],
@@ -94,7 +94,7 @@ function mockEffectRegistry(): {
mockEffectWithoutCleanup: string => () => void,
registry: $ReadOnlyArray<TestEffect | TestEffectCleanup>,
} {
const registry = [];
const registry: Array<TestEffect | TestEffectCleanup> = [];
return {
mockEffect(name: string): () => () => void {
return instance => {
+1 -1
View File
@@ -28,7 +28,7 @@
function groupByEveryN<T>(array: Array<T>, n: number): Array<Array<?T>> {
const result = [];
let temp = [];
let temp: Array<?T> = [];
for (let i = 0; i < array.length; ++i) {
if (i > 0 && i % n === 0) {
+3 -1
View File
@@ -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 {
@@ -63,7 +63,7 @@ export class Graph {
root.children.add(node);
}
const output = [];
const output: Array<NodeId> = [];
postorder(root, output);
// remove fake root node
@@ -44,9 +44,9 @@ function parseDomains(
includeExperimental: Set<string>,
): Descriptor {
const desc = {
types: [],
commands: [],
events: [],
types: ([]: Array<Type>),
commands: ([]: Array<Command>),
events: ([]: Array<Event>),
};
for (const obj of domainObjs) {
@@ -44,7 +44,7 @@ class XHRExampleFetch extends React.Component<any, any> {
return null;
}
const responseHeaders = [];
const responseHeaders: Array<React.Node> = [];
const keys = Object.keys(this.responseHeaders.map);
for (let i = 0; i < keys.length; i++) {
const key = keys[i];