[英]React app build failed for popper js typescript error
我有使用引導程序 4.3.1 作為節點模塊的反應應用程序。當我構建應用程序時,它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";
之前還好。 今天出現錯誤。
這是由於 Typescript type-only-imports-and-export引入的新語法
將 package.json 中的typescript
模塊package.json
到 > 3.8.0 和@type
定義應該可以解決此問題。
這是相關的Stackoverflow主題。
我在為 SPFx 編寫 web 部件時遇到了同樣的問題,這略有不同,但由於搜索將我帶到了這里,所以我將在未來為任何人留下答案。
雖然在運行gulp serve
時將 typescript 更新為 4.4,但我得到了typescript version: 3.7.7
。 補救措施:
npm i @microsoft/rush-stack-compiler-3.9
此變體選擇 TypeScript 3.9tsconfig.json
更改extends
到"extends": "./node_modules/@microsoft/rush-stack-compiler-3.9/includes/tsconfig-web.json",
tslint.json
中刪除"no-use-before-declare": true,
因為它會導致錯誤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.
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.