简体   繁体   中英

React app build failed for popper js typescript error

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"; 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.

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.

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. Error - [tslint] no-use-before-declare is deprecated. Since TypeScript 2.9. Please use the built-in compiler checks instead.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM