Skip to content

Broken types with react-native@0.71.9+ and reanimated 3.2.0 #4548

@efstathiosntonas

Description

@efstathiosntonas

Description

react-native 0.71.9 and 0.71.10 were published today and the typings are now broken probably because of this PR. Downgrading react-native@0.71.8 eliminates the issue.

diffs: 0.71.8..0.71.9 and 0.71.9..0.71.10

TS2344: Type 'ViewStyle' does not satisfy the constraint 'AnimatedStyleProp<ViewStyle | TextStyle | ImageStyle>'.   Type 'ViewStyle' is not assignable to type 'AnimateStyle<TextStyle>'.     Types of property 'transform' are incompatible.       Type 'string | (PerpectiveTransform | RotateTransform | RotateXTransform | RotateYTransform | RotateZTransform | ... 7 more ... | MatrixTransform)[] | undefined' is not assignable to type 'AnimatedTransform | undefined'.

Screenshot 2023-06-08 at 00 13 23

TS2345: Argument of type '() => { transform: { translateY: number; }[]; opacity: number; zIndex: number; }' is not assignable to parameter of type '() => AnimatedStyleProp<ViewStyle | TextStyle | ImageStyle>'.   Type '{ transform: { translateY: number; }[]; opacity: number; zIndex: number; }' is not assignable to type 'AnimatedStyleProp<ViewStyle | TextStyle | ImageStyle>'.     Type '{ transform: { translateY: number; }[]; opacity: number; zIndex: number; }' is not assignable to type 'AnimateStyle<ImageStyle>'.       Types of property 'transform' are incompatible.         Type '{ translateY: number; }[]' is not assignable to type 'never[]'.           Type '{ translateY: number; }' is not assignable to type 'never'.

Screenshot 2023-06-08 at 00 14 22

const input = useRef<TextInput>(null); produces this on const AnimatedTextInput = Animated.createAnimatedComponent(TextInput); while using "@types/react": "18.2.7":

TS2769: No overload matches this call.   Overload 1 of 2, '(props: { value?: string | SharedValue<string | undefined> | undefined; id?: string | SharedValue<string | undefined> | undefined; children?: ReactNode | SharedValue<...>; ... 148 more ...; sharedTransitionStyle?: ILayoutAnimationBuilder | undefined; } & { ...; } & { ...; }): ReactElement<...>', gave the following error.     Type 'RefObject<TextInput>' is not assignable to type 'Ref<Component<AnimateProps<TextInputProps>, any, any>> | undefined'.       Type 'RefObject<TextInput>' is not assignable to type 'RefObject<Component<AnimateProps<TextInputProps>, any, any>>'.         Type 'TextInput' is not assignable to type 'Component<AnimateProps<TextInputProps>, any, any>'.           The types of 'props.style' are incompatible between these types.             Type 'StyleProp<TextStyle>' is not assignable to type 'StyleProp<AnimateStyle<StyleProp<TextStyle>>>'.               Type 'TextStyle' is not assignable to type 'StyleProp<AnimateStyle<StyleProp<TextStyle>>>'.                 Type 'TextStyle' is not assignable to type 'AnimateStyle<TextStyle>'.   Overload 2 of 2, '(props: StyledComponentPropsWithAs<ComponentClass<AnimateProps<TextInputProps>, any>, { announcements: { title: string; date: string; }; introductionDialog: { overlayColor: string; }; ... 105 more ...; walkthrough_dialogs: { ...; }; }, {}, never, ComponentClass<...>, ComponentClass<...>>): ReactElement<...>', gave the following error.     Type 'RefObject<TextInput>' is not assignable to type 'Ref<Component<AnimateProps<TextInputProps>, any, any>> | undefined'.  index.d.ts(146, 9): The expected type comes from property 'ref' which is declared here on type 'IntrinsicAttributes & { value?: string | SharedValue<string | undefined> | undefined; id?: string | SharedValue<string | undefined> | undefined; ... 149 more ...; sharedTransitionStyle?: ILayoutAnimationBuilder | undefined; } & { ...; } & { ...; }' index.d.ts(146, 9): The expected type comes from property 'ref' which is declared here on type 'IntrinsicAttributes & { value?: string | SharedValue<string | undefined> | undefined; id?: string | SharedValue<string | undefined> | undefined; ... 149 more ...; sharedTransitionStyle?: ILayoutAnimationBuilder | undefined; } & { ...; } & { ...; }'

Screenshot 2023-06-08 at 08 54 56

Steps to reproduce

  1. update react-native@0.71.9+

Snack or a link to a repository

none needed

Reanimated version

3.2.0

React Native version

0.71.9+

Platforms

Android, iOS, Web

JavaScript runtime

Hermes

Workflow

React Native (without Expo)

Architecture

Paper (Old Architecture)

Build type

Debug mode

Device

iOS simulator

Device model

No response

Acknowledgements

Yes

Metadata

Metadata

Assignees

No one assigned

    Labels

    Missing reproThis issue need minimum repro scenarioNeeds reviewIssue is ready to be reviewed by a maintainerPlatform: AndroidThis issue is specific to AndroidPlatform: WebThis issue is specific to webPlatform: 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