【问题标题】:react native - passing option allowNamespaces to babel typescript pluginreact native - 将选项 allowNamespaces 传递给 babel typescript 插件
【发布时间】:2020-03-28 11:23:26
【问题描述】:

我想在 react native 中使用 TensorFlow - 由 expo 管理的流程。当我使用https://github.com/tensorflow/tfjs/tree/master/tfjs-react-native 网桥时,在android 上运行时出现错误,babel 需要将@babel/plugin-transform-typescript 的选项allowNamespaces 设置为true。

所以我把 babel.config.js 改成了:

module.exports = function(api) {
  api.cache(true);
  return {
    presets: ["babel-preset-expo"],
    plugins: [
      "@babel/plugin-transform-typescript",
      {
        allowNamespaces: true
      }
    ]
  };
};

但现在我收到错误Error: [BABEL] /node_modules/expo/AppEntry.js: .allowNamespaces is not a valid Plugin property,所以它在开头添加了点。

我尝试将其放入.babelrc,但还是一样。知道如何解决这个问题吗?谢谢

【问题讨论】:

    标签: reactjs react-native expo babeljs


    【解决方案1】:

    我做了更多尝试,最后,.babelrc 配置正确传递:

    {
        "plugins": [
            ["@babel/plugin-transform-typescript", { "allowNamespaces": true }]
        ]
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-05-11
      • 2019-01-18
      • 1970-01-01
      • 2019-02-18
      • 1970-01-01
      • 2021-03-17
      • 1970-01-01
      相关资源
      最近更新 更多