0

我目前正在创建一个小型 React Native 应用程序。为了测试,我声明使用 babel-plugin-rewire 来访问未导出的函数。现在我的所有测试都运行良好,但如果我尝试运行我的应用程序,我会收到以下错误:

node_modules\@react-navigation\native\src\NavigationContainer.tsx: C:\node_modules\@react-navigation\native\src\NavigationContainer.tsx: Property typeName of 
TSTypeReference expected node to be of a type ["TSEntityName"] but instead got "CallExpression"
transform[stderr]: The exported identifier "_DefaultExportValue" is not declared in Babel's scope tracker
transform[stderr]: as a JavaScript value binding, and "@babel/plugin-transform-typescript"
transform[stderr]: never encountered it as a TypeScript type declaration.
transform[stderr]: It will be treated as a JavaScript value.
transform[stderr]:
transform[stderr]: This problem is likely caused by another plugin injecting
transform[stderr]: "_DefaultExportValue" without registering it in the scope tracker. If you are the author
transform[stderr]: The exported identifier "_DefaultExportValue" is not declared in Babel's scope tracker
transform[stderr]: as a JavaScript value binding, and "@babel/plugin-transform-typescript"
transform[stderr]: never encountered it as a TypeScript type declaration.
transform[stderr]: It will be treated as a JavaScript value.
transform[stderr]:
transform[stderr]: This problem is likely caused by another plugin injecting
transform[stderr]: "_DefaultExportValue" without registering it in the scope tracker. If you are the author
transform[stderr]:  of that plugin, please use "scope.registerDeclaration(declarationPath)".

我的项目是用 JS 编写的。

.babelrc:

{
  "plugins": [
    ["@babel/plugin-transform-flow-strip-types"],
    [
      "module-resolver",
      {
        "root": ["./src/main"],
        "alias": {
          "src": "./src/main",
          "resources": "./src/main/resources"
        }
      }
    ],
    ["transform-inline-environment-variables"],
    ["babel-plugin-rewire"]
  ]
}

我已经搜索过,但从未找到有帮助或与 babel-plugin-rewire 相关的东西。

已经感谢您的帮助。

干杯

4

0 回答 0