导出的标识符“_default”未在 Babel 的范围跟踪器中声明

Eur*_*e01 6 javascript typescript package.json babeljs

我最近在升级到最新版本的 TypeScript 后升级了 babel 配置。当我升级 babel 时,我现在收到这个错误,我不知道为什么。以前有人遇到过这个问题吗?如果有,我该如何解决?决议是什么?

The exported identifier "_default" is not declared in Babel's scope tracker
as a JavaScript value binding, and "@babel/plugin-transform-typescript"
never encountered it as a TypeScript type declaration.
It will be treated as a JavaScript value.

This problem is likely caused by another plugin injecting
"_default" without registering it in the scope tracker. If you are the author
 of that plugin, please use "scope.registerDeclaration(declarationPath)".
The exported identifier "_default" is not declared in Babel's scope tracker
as a JavaScript value binding, and "@babel/plugin-transform-typescript"
never encountered it as a TypeScript type declaration.
Run Code Online (Sandbox Code Playgroud)

我的项目中的 Babel 依赖项:

    "@babel/core": "^7.13.8",
    "@babel/plugin-proposal-class-properties": "^7.13.0",
    "@babel/plugin-proposal-numeric-separator": "^7.12.13",
    "@babel/preset-env": "^7.13.8",
    "@babel/preset-react": "^7.12.13",
    "@babel/preset-typescript": "^7.13.0"
Run Code Online (Sandbox Code Playgroud)

小智 1

此配置帮助我解决了同样的问题。把这个放在你的 babelrc 中

{
  "presets": [
    ["@babel/preset-env", { "targets": { "node": 4 } }],
    "@babel/preset-typescript",
    "@babel/preset-react"
  ],
  "plugins": [
    "@babel/plugin-transform-runtime",
    "transform-class-properties"
  ]
}
Run Code Online (Sandbox Code Playgroud)