Skip to content

Fix incompatiblity in types with new versions of react-native #4840

Closed
@XantreDev

Description

Description

Reanimated type is not compatible with new react-native types for transforms (added string type)

src/Components/Slider.tsx:97:17 - error TS2322: Type '{ translateX: number; }' is not assignable to type 'never'.

97 transform: [{ translateX: translateX.value }],
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

src/Features/UpdateNotifications/InAppUpdateProgress.tsx:66:7 - error TS2322: Type 'StyleProp' is not assignable to type 'StyleProp<AnimateStyle<MaybeSharedValue<StyleProp>>>'.
Type 'ViewStyle' is not assignable to type 'StyleProp<AnimateStyle<MaybeSharedValue<StyleProp>>>'.
Type 'ViewStyle' is not assignable to type 'AnimateStyle<MaybeSharedValue>'.
Types of property 'transform' are incompatible.
Type 'string | (PerpectiveTransform | RotateTransform | RotateXTransform | RotateYTransform | RotateZTransform | ... 7 more ... | MatrixTransform)[] | undefined' is not assignable to type 'AnimatedTransform | undefined'.
Type 'string' is not assignable to type 'never[]'.

66 style={style}
~~~~~

node_modules/react-native-reanimated/lib/typescript/reanimated2/helperTypes.d.ts:28:5
28 style?: StyleProp<AnimateStyle<StylesOrDefault

>>;
~~~~~
The expected type comes from property 'style' which is declared here on type 'IntrinsicAttributes & IntrinsicClassAttributes<Component<AnimateProps, any, any>> & Readonly<...>'

src/Features/UpdateNotifications/InAppUpdateProgress.tsx:75:15 - error TS2322: Type '{ translateX: number; }' is not assignable to type 'never'.

75 {
~
76 translateX: -(width.value ?? 0) / 2,

77               },
~~~~~~~~~~~~~~~

src/Features/UpdateNotifications/InAppUpdateProgress.tsx:78:15 - error TS2322: Type '{ scaleX: number; }' is not assignable to type 'never'.

78               {
              ~
79                 scaleX: progressShared.value,
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
80               },
~~~~~~~~~~~~~~~

src/Features/UpdateNotifications/InAppUpdateProgress.tsx:81:15 - error TS2322: Type '{ translateX: number; }' is not assignable to type 'never'.

81               {
              ~
82                 translateX: (width.value ?? 0) / 2,
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
83               },
~~~~~~~~~~~~~~~

src/Toast.tsx:181:9 - error TS2322: Type 'AnimatedStyleProp<ViewStyle | ImageStyle | TextStyle>' is not assignable to type 'StyleProp<ViewStyle>'.
Type 'AnimateStyle<ViewStyle>' is not assignable to type 'StyleProp<ViewStyle>'.
 Type 'AnimateStyle<ViewStyle>' is not assignable to type 'ViewStyle'.
   Types of property 'backfaceVisibility' are incompatible.
     Type 'number | "hidden" | "visible" | undefined' is not assignable to type '"hidden" | "visible" | undefined'.
       Type 'number' is not assignable to type '"hidden" | "visible" | undefined'.

181         style={useAnimatedStyle(() => ({
         ~~~~~

node_modules/react-native/Libraries/Components/View/ViewPropTypes.d.ts:234:3
 234   style?: StyleProp<ViewStyle> | undefined;
       ~~~~~
 The expected type comes from property 'style' which is declared here on type 'IntrinsicAttributes & ViewProps & { animatedProps?: Partial<ViewProps> | undefined; layout?: typeof BaseAnimationBuilder | BaseAnimationBuilder | LayoutAnimationFunction | undefined; entering?: any; exiting?: any; } & MotiProps<...> & { ...; } & RefAttributes<...>'

src/Toast.tsx:183:23 - error TS2322: Type '{ translateY: number; }' is not assignable to type 'never'.

183           transform: [{ translateY: translateY.value }],

### Steps to reproduce

1.  Try to use transform in reanimated with react-native 0.71.12

### Snack or a link to a repository

*

### Reanimated version

3.4.1

### React Native version

0.71.12

### Platforms

Android, iOS

### JavaScript runtime

None

### Workflow

None

### Architecture

None

### Build type

None

### Device

None

### Device model

_No response_

### Acknowledgements

Yes

Metadata

Assignees

Labels

Close when staleThis issue is going to be closed when there is no activity for a whileMissing infoThe user didn't precise the problem enoughMissing reproThis issue need minimum repro scenarioNeeds reviewIssue is ready to be reviewed by a maintainerPlatform: AndroidThis issue is specific to AndroidPlatform: iOSThis issue is specific to iOS

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions