react-bootstrap: React-Bootstrap 1.1.1 throwing TypeScript error Declaration of statement expected

Describe the bug

Project fails to compile: TypeScript error in /Users/alexwarner/PhpstormProjects/test-project/node_modules/react-bootstrap/esm/index.d.ts(5,1): Declaration or statement expected. TS1128

To Reproduce

Steps to reproduce the behavior:

  1. Use CRA to setup new React project
  2. Install react-bootstrap npm install react-bootstrap bootstrap
  3. Import any bootstrap component: import {Form} from “react-bootstrap”
  4. When the app compiles the above error is thrown

Screenshots

Screen Shot 2020-07-08 at 1 13 13 PM Screen Shot 2020-07-08 at 1 13 04 PM

Environment (please complete the following information)

  • Operating System: [e.g. macOS 10.15.5]
  • Browser, Version [Firefox 77]
  • React-Bootstrap Version [1.1.1]

Additional context

See screenshot above, in the index.d.ts file included in the RB package my code linter is flagging errors on any line using the syntax,export type { AccordionProps } from './Accordion';

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 8
  • Comments: 20 (3 by maintainers)

Most upvoted comments

type imports were added in typescript 3.8, upgrade and it should be fixed

@SolucionARG, @RagibHossain, after changing typescript’s version in your package.json to 3.9.X, you should also run npm install in your project directory, and you’re all set.

Great! thanks a lot for you help!

  1. node_modules/typescript remove
  2. package.json “typescript”: 3.7.3 remove
  3. typescript reinstall => npm install typescript

I’m still having this problem and I have 3.9.7. I try with a new project, just adding import Container from ‘react-bootstrap’; creates the error.

For those using VS Code, make sure that your workspace / project version are accurate and not just the editor version. I struggled for a minute wondering what was going on until I checked my package.json file and saw that version was only 3.7.X though my editor was using 3.9.X. Upgrading the version fixed the issue.

Great! It works perfect importing that way. Thanks a lot for your help.

I’m still having this problem and I have 3.9.7. I try with a new project, just adding import Container from ‘react-bootstrap’; creates the error.

Maybe some additional info since I see you use some JetBrains product. When I was using WebStorm’s build-in React App template, it defaulted to use an outdated version 3.7.x of typescript. You’ll need to manually bump the version then.