React app build failed for popper js typescript error

9.7k views Asked by At

I have react app that used bootstrap 4.3.1 as node modules.When i am building the app its giving below error TypeScript error in /codebuild/output/src478180495/src/app-name/node_modules/@popperjs/core/lib/createPopper.d.ts(1,13): '=' expected. TS1005 > 1 | import type { OptionsGeneric, Modifier, Instance, VirtualElement } from "./types"; It was fine earlier. error coming up today.

2

There are 2 answers

0
Zachary Zhou On BEST ANSWER

It is due to a new syntax introduced by Typescript type-only-imports-and-export

Upgrade your typescript module in package.json to > 3.8.0 and @type definitions should solve this issue.

Heres the related Stackoverflow topic.

0
Edmund Sulzanok On

I ran into same problem while coding a web part for SPFx, which is slightly different, but since search led me here, so I'll leave the answer for anyone in the future.

while updated typescript to 4.4 when running gulp serve i got typescript version: 3.7.7. Steps to remedy:

  1. run npm i @microsoft/rush-stack-compiler-3.9 This variant selects TypeScript 3.9
  2. in tsconfig.json change extends to "extends": "./node_modules/@microsoft/rush-stack-compiler-3.9/includes/tsconfig-web.json",
  3. in tslint.json remove "no-use-before-declare": true, as it will cause error Error - [tslint] no-use-before-declare is deprecated. Since TypeScript 2.9. Please use the built-in compiler checks instead.