8000 Type errors with React 19 · Issue #6879 · react-bootstrap/react-bootstrap · GitHub
[go: up one dir, main page]

Skip to content
Type errors with React 19 #6879
Closed
Closed
@JstnMcBrd

Description

@JstnMcBrd

Prerequisites

Describe the bug

I'm trying to upgrade a project with react-bootstrap and TypeScript to React 19.

Dependencies:

  • typescript@5.7.2
  • react-bootstrap@2.10.6
  • react@18.3.1 -> 19.0.0
  • react-dom@18.3.1 -> 19.0.0
  • @types/react@18.3.12 -> 19.0.1
  • @types/react-dom@18.3.1 -> 19.0.2

Several new type errors are being thrown. I believe these are caused by incompatibilities with the new versions of @types/react@19 and/or @types/react-dom@19.

node_modules/@restart/ui/esm/Button.d.ts:13:21 - error TS2503: Cannot find namespace 'JSX'.

13     tagName?: keyof JSX.IntrinsicElements;
                       ~~~

node_modules/@restart/ui/esm/Button.d.ts:38:16 - error TS2503: Cannot find namespace 'JSX'.

38     as?: keyof JSX.IntrinsicElements | undefined;
                  ~~~

node_modules/@restart/ui/esm/types.d.ts:3:43 - error TS2503: Cannot find namespace 'JSX'.

3 export type IntrinsicElementTypes = keyof JSX.IntrinsicElements;
                                            ~~~

node_modules/react-bootstrap/esm/Dropdown.d.ts:6:18 - error TS2320: Interface 'DropdownProps' cannot simultaneously extend types 'DropdownProps' and 'Omit<HTMLAttributes<HTMLElement>, "children" | "onSelect">'.
  Named property 'onToggle' of types 'DropdownProps' and 'Omit<HTMLAttributes<HTMLElement>, "children" | "onSelect">' are not identical.

6 export interface DropdownProps extends BaseDropdownProps, BsPrefixProps, Omit<React.HTMLAttributes<HTMLElement>, 'onSelect' | 'children'> {
                   ~~~~~~~~~~~~~

node_modules/react-bootstrap/esm/Image.d.ts:2:23 - error TS7016: Could not find a declaration file for module 'prop-types'. '/home/projects/node-mkwgd4bm/node_modules/prop-types/index.js' implicitly has an 'any' type.
  Try `npm i --save-dev @types/prop-types` if it exists or add a new declaration (.d.ts) file containing `declare module 'prop-types';`

2 import PropTypes from 'prop-types';
                        ~~~~~~~~~~~~

node_modules/react-bootstrap/esm/Navbar.d.ts:4:18 - error TS2430: Interface 'NavbarProps' incorrectly extends interface 'Omit<HTMLAttributes<HTMLElement>, "onSelect">'.
  Types of property 'onToggle' are incompatible.
    Type '((expanded: boolean) => void) | undefined' is not assignable to type 'ToggleEventHandler<HTMLElement> | undefined'.
      Type '(expanded: boolean) => void' is not assignable to type 'ToggleEventHandler<HTMLElement>'.
        Types of parameters 'expanded' and 'event' are incompatible.
          Type 'ToggleEvent<HTMLElement>' is not assignable to type 'boolean'.

4 export interface NavbarProps extends BsPrefixProps, Omit<React.HTMLAttributes<HTMLElement>, 'onSelect'> {
                   ~~~~~~~~~~~

node_modules/react-bootstrap/esm/Ratio.d.ts:5:21 - error TS2694: Namespace 'React' has no exported member 'ReactChild'.

5     children: React.ReactChild;
                      ~~~~~~~~~~

node_modules/react-bootstrap/esm/Tab.d.ts:1:23 - error TS7016: Could not find a declaration file for module 'prop-types'. '/home/projects/node-mkwgd4bm/node_modules/prop-types/index.js' implicitly has an 'any' type.
  Try `npm i --save-dev @types/prop-types` if it exists or add a new declaration (.d.ts) file containing `declare module 'prop-types';`

1 import PropTypes from 'prop-types';
                        ~~~~~~~~~~~~

node_modules/react-bootstrap/esm/TabContainer.d.ts:2:23 - error TS7016: Could not find a declaration file for module 'prop-types'. '/home/projects/node-mkwgd4bm/node_modules/prop-types/index.js' implicitly has an 'any' type.
  Try `npm i --save-dev @types/prop-types` if it exists or add a new declaration (.d.ts) file containing `declare module 'prop-types';`

2 import PropTypes from 'prop-types';
                        ~~~~~~~~~~~~

node_modules/react-bootstrap/esm/Tabs.d.ts:2:23 - error TS7016: Could not find a declaration file for module 'prop-types'. '/home/projects/node-mkwgd4bm/node_modules/prop-types/index.js' implicitly has an 'any' type.
  Try `npm i --save-dev @types/prop-types` if it exists or add a new declaration (.d.ts) file containing `declare module 'prop-types';`

2 import PropTypes from 'prop-types';
                        ~~~~~~~~~~~~

node_modules/react-bootstrap/esm/createUtilityClasses.d.ts:1:23 - error TS7016: Could not find a declaration file for module 'prop-types'. '/home/projects/node-mkwgd4bm/node_modules/prop-types/index.js' implicitly has an 'any' type.
  Try `npm i --save-dev @types/prop-types` if it exists or add a new declaration (.d.ts) file containing `declare module 'prop-types';`

1 import PropTypes from 'prop-types';
                        ~~~~~~~~~~~~

node_modules/react-bootstrap/esm/types.d.ts:1:23 - error TS7016: Could not find a declaration file for module 'prop-types'. '/home/projects/node-mkwgd4bm/node_modules/prop-types/index.js' implicitly has an 'any' type.
  Try `npm i --save-dev @types/prop-types` if it exists or add a new declaration (.d.ts) file containing `declare module 'prop-types';`

1 import PropTypes from 'prop-types';
                        ~~~~~~~~~~~~


Found 12 errors in 11 files.

Errors  Files
     2  node_modules/@restart/ui/esm/Button.d.ts:13
     1  node_modules/@restart/ui/esm/types.d.ts:3
     1  node_modules/react-bootstrap/esm/Dropdown.d.ts:6
     1  node_modules/react-bootstrap/esm/Image.d.ts:2
     1  node_modules/react-bootstrap/esm/Navbar.d.ts:4
     1  node_modules/react-bootstrap/esm/Ratio.d.ts:5
     1  node_modules/react-bootstrap/esm/Tab.d.ts:1
     1  node_modules/react-bootstrap/esm/TabContainer.d.ts:2
     1  node_modules/react-bootstrap/esm/Tabs.d.ts:2
     1  node_modules/react-bootstrap/esm/createUtilityClasses.d.ts:1
     1  node_modules/react-bootstrap/esm/types.d.ts:1

Expected behavior

No type errors.

To Reproduce

  1. Install typescript, react-bootstrap, react, react-dom, @types/react, and @types/react-dom.
  2. Create tsconfig - exact settings don't matter, but include "jsx": "react-jsx"
  3. Create example file and import from react-bootstrap
  4. Run tsc and build will fail

Reproducible Example

https://stackblitz.com/edit/node-mkwgd4bm

What version of React-Bootstrap are you using?

2.10.6

Workaround

Turn on skipLibCheck and the build will still pass, and everything appears to work the same.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0