Skip to content

Commit

Permalink
Annotate empty objects in xplat
Browse files Browse the repository at this point in the history
Reviewed By: pieterv

Differential Revision: D40134090

fbshipit-source-id: 3dd0bdb41ed559d9f72f0ff35c14e5551789fcc0
  • Loading branch information
SamChou19815 authored and facebook-github-bot committed Oct 6, 2022
1 parent 7c36d0b commit abb21dd
Show file tree
Hide file tree
Showing 9 changed files with 20 additions and 16 deletions.
2 changes: 1 addition & 1 deletion Libraries/Animated/AnimatedImplementation.js
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ const parallel = function (
): CompositeAnimation {
let doneCount = 0;
// Make sure we only call stop() at most once for each animation
const hasEnded = {};
const hasEnded: {[number]: boolean} = {};
const stopTogether = !(config && config.stopTogether === false);

const result = {
Expand Down
10 changes: 7 additions & 3 deletions Libraries/Animated/NativeAnimatedHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,12 @@ const useSingleOpBatching =
ReactNativeFeatureFlags.animatedShouldUseSingleOp();
let flushQueueTimeout = null;

const eventListenerGetValueCallbacks = {};
const eventListenerAnimationFinishedCallbacks = {};
const eventListenerGetValueCallbacks: {
[$FlowFixMe | number]: ((value: number) => void) | void,
} = {};
const eventListenerAnimationFinishedCallbacks: {
[$FlowFixMe | number]: EndCallback | void,
} = {};
let globalEventEmitterGetValueListener: ?EventSubscription = null;
let globalEventEmitterAnimationFinishedListener: ?EventSubscription = null;

Expand Down Expand Up @@ -79,7 +83,7 @@ const nativeOps: ?typeof NativeAnimatedModule = useSingleOpBatching
'addListener', // 20
'removeListener', // 21
];
return apis.reduce((acc, functionName, i) => {
return apis.reduce<{[string]: number}>((acc, functionName, i) => {
// These indices need to be kept in sync with the indices in native (see NativeAnimatedModule in Java, or the equivalent for any other native platform).
// $FlowFixMe[prop-missing]
acc[functionName] = i + 1;
Expand Down
2 changes: 1 addition & 1 deletion Libraries/Inspector/NetworkOverlay.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ class NetworkOverlay extends React.Component<Props, State> {
this.setState(({requests}) => {
const networkRequestInfo = requests[xhrIndex];
if (!networkRequestInfo.requestHeaders) {
networkRequestInfo.requestHeaders = {};
networkRequestInfo.requestHeaders = ({}: {[any]: any});
}
networkRequestInfo.requestHeaders[header] = value;
return {requests};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ function PointerEventAttributesHoverablePointersTestCase(
) {
const {harness} = props;

const detected_pointertypesRef = useRef({});
const detected_eventTypesRef = useRef({});
const detected_pointertypesRef = useRef(({}: {[string]: boolean}));
const detected_eventTypesRef = useRef(({}: {[string]: boolean}));
const expectedPointerIdRef = useRef(NaN);

const [square1Visible, setSquare1Visible] = useState(true);
Expand Down Expand Up @@ -189,7 +189,7 @@ function PointerEventAttributesHoverablePointersTestCase(
eventList.length
) {
setSquare1Visible(false);
detected_eventTypesRef.current = {};
detected_eventTypesRef.current = ({}: {[string]: boolean});
setSquare2Visible(true);
expectedPointerIdRef.current = NaN;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ function PointerEventAttributesNoHoverPointersTestCase(
) {
const {harness} = props;

const detected_pointertypesRef = useRef({});
const detected_eventTypesRef = useRef({});
const detected_pointertypesRef = useRef(({}: {[string]: boolean}));
const detected_eventTypesRef = useRef(({}: {[string]: boolean}));
const expectedPointerIdRef = useRef(NaN);

const [square1Visible, setSquare1Visible] = useState(true);
Expand Down Expand Up @@ -157,7 +157,7 @@ function PointerEventAttributesNoHoverPointersTestCase(
eventList.length
) {
setSquare1Visible(false);
detected_eventTypesRef.current = {};
detected_eventTypesRef.current = ({}: {[string]: boolean});
setSquare2Visible(true);
expectedPointerIdRef.current = NaN;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ function PointerEventPointerMoveTestCase(
) {
const {harness} = props;

const detectedPointerTypesRef = useRef({});
const detectedPointerTypesRef = useRef(({}: {[string]: boolean}));
const testPointerMove = harness.useAsyncTest('pointermove event received');

const handlers = useTestEventHandler(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ function PointerEventPrimaryTouchPointerTestCase(
) {
const {harness} = props;

const detected_eventsRef = useRef({});
const detected_eventsRef = useRef(({}: {[string]: boolean}));

const handleIncomingPointerEvent = useCallback(
(boxLabel: string, eventType: string, isPrimary: boolean) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ export function useTestEventHandler(
const eventProps: any = useMemo(() => {
const handlerFactory = (eventName: string) => (event: any) =>
handler(event, eventName);
const props = {};
const props: {[string]: (event: any) => void} = {};
for (const eventName of eventNames) {
const eventPropName =
'on' + eventName[0].toUpperCase() + eventName.slice(1);
Expand Down
4 changes: 2 additions & 2 deletions packages/rn-tester/js/utils/RNTesterReducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const getUpdatedBookmarks = ({
key,
bookmarks,
}: {
exampleType: string,
exampleType: 'apis' | 'components',
key: string,
bookmarks: ComponentList,
}) => {
Expand All @@ -47,7 +47,7 @@ const getUpdatedRecentlyUsed = ({
key,
recentlyUsed,
}: {
exampleType: string,
exampleType: 'apis' | 'components',
key: string,
recentlyUsed: ComponentList,
}) => {
Expand Down

0 comments on commit abb21dd

Please sign in to comment.