Skip to content

typescript error caused by src/utils/forwardRef.tsx when running tsc #4609

@GamerGirlandCo

Description

@GamerGirlandCo

Current behaviour

node_modules/react-native-paper/src/utils/forwardRef.tsx:21:14 - error TS2322: Type '<T, P = {}>(render: ForwardRefRenderFunction<T, PropsWithoutRef<P>>) => ForwardRefExoticComponent<PropsWithoutRef<P> & RefAttributes<T>>' is not assignable to type '<T, P = {}>(render: ForwardRefRenderFunction<T, P>) => ForwardRefComponent<T, P>'.
  Types of parameters 'render' and 'render' are incompatible.
    Type 'ForwardRefRenderFunction<T, P>' is not assignable to type 'ForwardRefRenderFunction<T, PropsWithoutRef<P>>'.
      Types of parameters 'props' and 'props' are incompatible.
        Type 'PropsWithoutRef<P>' is not assignable to type 'P'.
          'P' could be instantiated with an arbitrary type which could be unrelated to 'PropsWithoutRef<P>'.

Expected behaviour

type checking should complete without errors

How to reproduce?

  1. clone/download https://snack.expo.dev/@the-tablet/6dd396
  2. run tsc --noEmit in the project directory

Preview

N/A

What have you tried so far?

  1. redeclaring typescript module react-native-paper/src/utils/forwardRef.tsx
import 'react-native-paper/src/utils/forwardRef';
declare module 'react-native-paper/src/utils/forwardRef' {
  export declare const forwardRef: <T, P = {}>(
    render: ForwardRefRenderFunction<T, PropsWithoutRef<P>>
  ) => ForwardRefComponent<T, P> = React.forwardRef;
}
  1. adding skipLibCheck: true to tsconfig.json
  2. explicitly adding node_modules/react-native-paper/src to the exclude array in tsconfig.json
  3. upgrading react-native-paper to the latest version

Your Environment

software version
ios n/a
android 35
react-native 0.76.6
react-native-paper 5.13.1
node 22.12.0
npm or yarn yarn 1.22.22
expo sdk N/A

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions