【问题标题】:React app build failed for popper js typescript error由于 popper js typescript 错误,React 应用程序构建失败
【发布时间】:2021-03-03 12:37:56
【问题描述】:

我有使用 bootstrap 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"; 之前很好。今天出现错误。

【问题讨论】:

    标签: reactjs typescript popperjs


    【解决方案1】:

    这是由于 Typescript type-only-imports-and-export 引入了一种新语法

    package.json 中的typescript 模块升级到> 3.8.0 和@type 定义应该可以解决这个问题。

    这是相关的Stackoverflow 主题。

    【讨论】:

      【解决方案2】:

      我在为 SPFx 编写 Web 部件时遇到了同样的问题,这略有不同,但由于搜索将我带到了这里,所以我将在未来将答案留给任何人。

      在运行 gulp serve 时将 typescript 更新为 4.4,我得到了 typescript version: 3.7.7。补救措施:

      1. 运行npm i @microsoft/rush-stack-compiler-3.9这个变种选择TypeScript 3.9
      2. tsconfig.json 中将extends 更改为"extends": "./node_modules/@microsoft/rush-stack-compiler-3.9/includes/tsconfig-web.json",
      3. 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.

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2022-11-02
        • 1970-01-01
        • 2021-02-12
        • 2020-03-30
        • 1970-01-01
        • 2021-07-02
        • 2020-11-04
        • 1970-01-01
        相关资源
        最近更新 更多