mirror of
https://github.com/facebook/react-native.git
synced 2026-11-18 20:19:07 +00:00
Type Animated.Value.addListener callback (#57992)
Summary: Pull Request resolved: https://github.com/react/react-native/pull/57992 Addresses a type narrowness regression (Strict API vs legacy manual types), raised by user feedback: https://github.com/react-native-community/discussions-and-proposals/discussions/1015#discussioncomment-18053943 Changelog: [General][Fixed] - **Animated**: `Animated.Value.addListener()` types its callback payload as `{value: number}` rather than `any` Reviewed By: vzaidman Differential Revision: D116440622 fbshipit-source-id: b85c7d7fbd8e81cc2e953c9a6f60701f3991ba6e
This commit is contained in:
1 parent
3eb330a365
commit
3eab03df4c
3 files changed
+25
-24
No files matched your search
@@ -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,
|
||||
|
||||
@@ -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';
|
||||
@@ -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) {
|
||||
|
||||
+22
-21
@@ -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<<5335b26453a7d4d5bb9b7d54ded6218f>>
|
||||
* @generated SignedSource<<aa2e1e5d4537b814b54eaaeafe35469c>>
|
||||
*
|
||||
* This file was generated by scripts/js-api/build-types/index.js.
|
||||
*/
|
||||
@@ -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,
|
||||
@@ -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]
|
||||
@@ -5730,7 +5731,7 @@ export {
|
||||
AlertOptions, // 8a116d2a
|
||||
AlertType, // 5ab91217
|
||||
AndroidKeyboardEvent, // e03becc8
|
||||
Animated, // f23abee5
|
||||
Animated, // c8741f58
|
||||
AppConfig, // 35c0ca70
|
||||
AppRegistry, // 1e8c5a00
|
||||
AppState, // 12012be5
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -5953,7 +5954,7 @@ export {
|
||||
StatusBarProps, // c2a44d88
|
||||
StatusBarStyle, // 78f53eea
|
||||
StyleProp, // fa0e9b4a
|
||||
StyleSheet, // daba2860
|
||||
StyleSheet, // a6a3620c
|
||||
SubmitBehavior, // c4ddf490
|
||||
Switch, // f495bab3
|
||||
SwitchChangeEvent, // 899635b1
|
||||
@@ -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
|
||||
@@ -6009,10 +6010,10 @@ 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
|
||||
@@ -6020,9 +6021,9 @@ export {
|
||||
processColor, // 6e877698
|
||||
registerCallableModule, // 839c8cfe
|
||||
requireNativeComponent, // aa36a6dd
|
||||
useAnimatedColor, // a9dffd9f
|
||||
useAnimatedValue, // 25733d13
|
||||
useAnimatedValueXY, // 04c70878
|
||||
useAnimatedColor, // 31a919f9
|
||||
useAnimatedValue, // 3eb9d3c0
|
||||
useAnimatedValueXY, // b434ca0f
|
||||
useColorScheme, // d585efdb
|
||||
usePressability, // 782138ed
|
||||
useWindowDimensions, // bb4b683f
|
||||
|
||||
Reference in new issue
Block a user