Skip to content

nodeRef type not compatible with React 19 typings #768

Open
@Philipp91

Description

@Philipp91

To reproduce, run the type checker with the new React version, e.g. like this:

  1. Fork this repo
  2. Change to react v19 in package.json, especially the typings:
    "@types/react": "^19.0.1",
    "@types/react-dom": "^19.0.1",
    "react": "^19.0.0",
    "react-dom": "^19.0.0",
    "react-frame-component": "^5.2.6",
    "react-test-renderer": "^19.0.0",
    
  3. npm update, cd typings
  4. ../node_modules/typescript/bin/tsc

While it worked fine with the older React version, now it throws this error:

test.tsx:33:5 - error TS2322: Type 'RefObject<HTMLDivElement | null>' is not assignable to type 'RefObject<HTMLElement>'.
  Type 'HTMLDivElement | null' is not assignable to type 'HTMLElement'.
    Type 'null' is not assignable to type 'HTMLElement'.

33     nodeRef={nodeRef}
       ~~~~~~~

  index.d.ts:53:5
    53     nodeRef?: React.RefObject<HTMLElement>,
           ~~~~~~~
    The expected type comes from property 'nodeRef' which is declared here on type 'IntrinsicAttributes & IntrinsicClassAttributes<Draggable> & Pick<Readonly<Partial<DraggableProps>>, never> & InexactPartial<...> & InexactPartial<...>'

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions