diff --git a/native/chat/swipeable-message.react.js b/native/chat/swipeable-message.react.js --- a/native/chat/swipeable-message.react.js +++ b/native/chat/swipeable-message.react.js @@ -19,6 +19,9 @@ cancelAnimation, Extrapolate, type SharedValue, + // ESLint doesn't understand Flow comment syntax + // eslint-disable-next-line no-unused-vars + type WithSpringConfig, } from 'react-native-reanimated'; import tinycolor from 'tinycolor2'; @@ -33,7 +36,11 @@ const panGestureHandlerActiveOffsetX = [-4, 4]; const panGestureHandlerFailOffsetY = [-5, 5]; -function dividePastDistance(value, distance, factor) { +function dividePastDistance( + value /*: number */, + distance /*: number */, + factor /*: number */, +) /*: number */ { 'worklet'; const absValue = Math.abs(value); if (absValue < distance) { @@ -43,7 +50,7 @@ return absFactor * (distance + (absValue - distance) / factor); } -function makeSpringConfig(velocity) { +function makeSpringConfig(velocity /*: number */) /*: WithSpringConfig */ { 'worklet'; return { stiffness: 257.1370588235294, @@ -56,19 +63,27 @@ }; } -function interpolateOpacityForViewerPrimarySnake(translateX) { +function interpolateOpacityForViewerPrimarySnake( + translateX /*: number */, +) /*: number */ { 'worklet'; return interpolate(translateX, [-20, -5], [1, 0], Extrapolate.CLAMP); } -function interpolateOpacityForNonViewerPrimarySnake(translateX) { +function interpolateOpacityForNonViewerPrimarySnake( + translateX /*: number */, +) /*: number */ { 'worklet'; return interpolate(translateX, [5, 20], [0, 1], Extrapolate.CLAMP); } -function interpolateTranslateXForViewerSecondarySnake(translateX) { +function interpolateTranslateXForViewerSecondarySnake( + translateX /*: number */, +) /*: number */ { 'worklet'; return interpolate(translateX, [-130, -120, -60, 0], [-130, -120, -5, 20]); } -function interpolateTranslateXForNonViewerSecondarySnake(translateX) { +function interpolateTranslateXForNonViewerSecondarySnake( + translateX /*: number */, +) /*: number */ { 'worklet'; return interpolate(translateX, [0, 80, 120, 130], [0, 30, 120, 130]); } @@ -198,11 +213,17 @@ const translateX = useSharedValue(0); const swipeEvent = useAnimatedGestureHandler( { - onStart: (event: PanGestureEvent, ctx: { [string]: mixed }) => { + onStart: ( + event /*: PanGestureEvent */, + ctx /*: { [string]: mixed } */, + ) => { ctx.translationAtStart = translateX.value; cancelAnimation(translateX.value); }, - onActive: (event: PanGestureEvent, ctx: { [string]: mixed }) => { + onActive: ( + event /*: PanGestureEvent */, + ctx /*: { [string]: mixed } */, + ) => { const { translationAtStart } = ctx; invariant( typeof translationAtStart === 'number', @@ -231,7 +252,7 @@ } ctx.prevPastSecondaryThreshold = pastSecondaryThreshold; }, - onEnd: (event: PanGestureEvent) => { + onEnd: (event /*: PanGestureEvent */) => { const absValue = Math.abs(translateX.value); if (absValue >= secondaryThreshold && secondaryActionExists) { runOnJS(secondaryAction)(); diff --git a/native/flow-typed/npm/react-native-reanimated_v2.x.x.js b/native/flow-typed/npm/react-native-reanimated_v2.x.x.js --- a/native/flow-typed/npm/react-native-reanimated_v2.x.x.js +++ b/native/flow-typed/npm/react-native-reanimated_v2.x.x.js @@ -503,7 +503,7 @@ dependencies?: $ReadOnlyArray, ) => T; - declare type WithSpringConfig = $Shape<{| + declare export type WithSpringConfig = $Shape<{| +stiffness: number, +damping: number, +mass: number,