Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/react-native/Libraries/Animated/AnimatedEvent.js
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ export class AnimatedEvent {
this._attachedEvent && this._attachedEvent.detach();
}

__getHandler(): any | ((...args: any) => void) {
__getHandler(): (...args: any) => void {
if (this.__isNative) {
if (__DEV__) {
let validatedMapping = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -576,10 +576,14 @@ function unforkEventImpl(
}
}

const eventImpl = function <T>(
// NOTE: With `useNativeDriver: true` this returns an `AnimatedEvent` instance
// rather than a callable handler. That object is only ever meant to be handed
// straight back to an animated component's event prop, so the declared type
// describes the handler shape both branches are consumed as.
const eventImpl: <T>(
argMapping: ReadonlyArray<?Mapping>,
config: EventConfig<T>,
): any {
) => (...args: Array<any>) => void = function (argMapping, config): any {
const animatedEvent = new AnimatedEvent(argMapping, config);
if (animatedEvent.__isNative) {
return animatedEvent;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import type {PlatformConfig} from '../AnimatedPlatformConfig';
import NativeAnimatedHelper from '../../../src/private/animated/NativeAnimatedHelper';
import invariant from 'invariant';

type ValueListenerCallback = (state: {value: number, ...}) => unknown;
export type ValueListenerCallback = (state: {value: number}) => unknown;

export type AnimatedNodeConfig = Readonly<{
debugID?: string,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import type {
InterpolationConfigType,
} from './AnimatedInterpolation';
import type AnimatedNode from './AnimatedNode';
import type {AnimatedNodeConfig} from './AnimatedNode';
import type {AnimatedNodeConfig, ValueListenerCallback} from './AnimatedNode';
import type AnimatedTracking from './AnimatedTracking';

import NativeAnimatedHelper from '../../../src/private/animated/NativeAnimatedHelper';
Expand Down Expand Up @@ -138,7 +138,7 @@ export default class AnimatedValue extends AnimatedWithChildren {
}
}

addListener(callback: (value: any) => unknown): string {
addListener(callback: ValueListenerCallback): string {
const id = super.addListener(callback);
this._listenerCount++;
if (this.__isNative) {
Expand Down
45 changes: 23 additions & 22 deletions packages/react-native/ReactNativeApi.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<44990574a74bcc122718d4f6142db8cd>>
* @generated SignedSource<<aa2e1e5d4537b814b54eaaeafe35469c>>
*
* This file was generated by scripts/js-api/build-types/index.js.
*/
Expand Down Expand Up @@ -232,7 +232,7 @@ declare const event: typeof $$AnimatedImplementation.event
declare const eventImpl: <T>(
argMapping: ReadonlyArray<Mapping | null | undefined>,
config: EventConfig<T>,
) => any
) => (...args: Array<any>) => void
declare const findNodeHandle: typeof $$ReactFabric.findNodeHandle
declare const flatten: typeof $$flattenStyle
declare const forkEvent: typeof $$AnimatedImplementation.forkEvent
Expand Down Expand Up @@ -1401,7 +1401,7 @@ declare class AnimatedTracking_default extends AnimatedNode_default {
update(): void
}
declare class AnimatedValue_default extends AnimatedWithChildren_default {
addListener(callback: (value: any) => unknown): string
addListener(callback: ValueListenerCallback): string
animate(
animation: Animation_default,
callback: EndCallback | null | undefined,
Expand Down Expand Up @@ -5404,6 +5404,7 @@ declare type UTFSequence = typeof UTFSequence
declare type Value = null | {
horizontal: boolean
}
declare type ValueListenerCallback = (state: { value: number }) => unknown
declare type ValueOfUnion<T, K> = T extends any
? K extends keyof T
? T[K]
Expand Down Expand Up @@ -5730,7 +5731,7 @@ export {
AlertOptions, // 8a116d2a
AlertType, // 5ab91217
AndroidKeyboardEvent, // e03becc8
Animated, // f23abee5
Animated, // c8741f58
AppConfig, // 35c0ca70
AppRegistry, // 1e8c5a00
AppState, // 12012be5
Expand All @@ -5744,8 +5745,8 @@ export {
BackPressEventName, // 4620fb76
BlurEvent, // 4ba4f941
BoxShadowValue, // b679703f
Button, // bc8f6464
ButtonInstance, // d94b4241
Button, // 586b24c2
ButtonInstance, // e3c42339
ButtonProps, // 21c5780c
Clipboard, // 41addb89
CodegenTypes, // ab4986cc
Expand Down Expand Up @@ -5782,9 +5783,9 @@ export {
EventSubscription, // b8d084aa
ExtendedExceptionData, // 5a6ccf5a
FilterFunction, // bf24c0e3
FlatList, // e1b005c7
FlatListInstance, // 2d1d8e45
FlatListProps, // 94fa2dc7
FlatList, // 2a814748
FlatListInstance, // 696cc805
FlatListProps, // 6d5e2d1f
FocusEvent, // 850f1517
FontVariant, // 7c7558bb
GestureResponderEvent, // 14d3e77a
Expand Down Expand Up @@ -5925,18 +5926,18 @@ export {
ScrollEvent, // d7abdd0a
ScrollResponderType, // ba188eae
ScrollToLocationParamsType, // d7ecdad1
ScrollView, // 066a8597
ScrollView, // 66fa774d
ScrollViewImperativeMethods, // 904c66fd
ScrollViewInstance, // ccf4f341
ScrollViewProps, // b62913d1
ScrollViewProps, // 678e4360
ScrollViewPropsAndroid, // 02f3df2e
ScrollViewPropsIOS, // 807cb4f6
ScrollViewScrollToOptions, // 3313411e
SectionBase, // 9f13db00
SectionList, // ee3e7972
SectionList, // 4a8d5792
SectionListData, // 1a4de01a
SectionListInstance, // c9b991fe
SectionListProps, // 0e933318
SectionListInstance, // b6326f35
SectionListProps, // d0058bb4
SectionListRenderItem, // 715b2086
SectionListRenderItemInfo, // 4a48a922
Separators, // 6a45f7e3
Expand All @@ -5953,7 +5954,7 @@ export {
StatusBarProps, // c2a44d88
StatusBarStyle, // 78f53eea
StyleProp, // fa0e9b4a
StyleSheet, // daba2860
StyleSheet, // a6a3620c
SubmitBehavior, // c4ddf490
Switch, // f495bab3
SwitchChangeEvent, // 899635b1
Expand Down Expand Up @@ -5989,9 +5990,9 @@ export {
TouchableNativeFeedback, // fe739e82
TouchableNativeFeedbackInstance, // 0877e3e4
TouchableNativeFeedbackProps, // 1d0c2f30
TouchableOpacity, // fe716ffc
TouchableOpacity, // 3eccd75e
TouchableOpacityInstance, // b186055b
TouchableOpacityProps, // a3b32b69
TouchableOpacityProps, // dd9e3393
TouchableWithoutFeedback, // ed159ba7
TouchableWithoutFeedbackProps, // e613ed05
TransformsStyle, // 65e70f18
Expand All @@ -6009,20 +6010,20 @@ export {
VirtualViewMode, // 6be59722
VirtualizedList, // 68c7345e
VirtualizedListInstance, // 423ee7c0
VirtualizedListProps, // f51f4a42
VirtualizedListProps, // 743d6082
VirtualizedSectionList, // 9fd9cd61
VirtualizedSectionListInstance, // 12b706d5
VirtualizedSectionListProps, // 8210f30a
VirtualizedSectionListProps, // 99c0a403
WrapperComponentProvider, // 9ef54e61
codegenNativeCommands, // 628a7c0a
codegenNativeComponent, // 32a1bca6
findNodeHandle, // 93f80214
processColor, // 6e877698
registerCallableModule, // 839c8cfe
requireNativeComponent, // aa36a6dd
useAnimatedColor, // a9dffd9f
useAnimatedValue, // 25733d13
useAnimatedValueXY, // 04c70878
useAnimatedColor, // 31a919f9
useAnimatedValue, // 3eb9d3c0
useAnimatedValueXY, // b434ca0f
useColorScheme, // d585efdb
usePressability, // 782138ed
useWindowDimensions, // bb4b683f
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ describe('Native Animated', () => {
const value = new Animated.Value(0);
value.__makeNative();
const listener = jest.fn();
const event = Animated.event([{nativeEvent: {foo: value}}], {
const event = new Animated.Event([{nativeEvent: {foo: value}}], {
useNativeDriver: true,
listener,
});
Expand Down
Loading