[英]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.