reactjs - React Native - 将选项allowNamespaces传递给babel typescript 插件

标签 reactjs react-native expo babeljs

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

所以我将 babel.config.js 更改为:

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

但是现在我收到错误错误:[BABEL]/node_modules/expo/AppEntry.js: .allowNamespaces 不是有效的插件属性,因此它在开头添加了点。

我尝试将其放入 .babelrc 但仍然相同。知道如何解决这个问题吗?谢谢

最佳答案

我进行了多次尝试,最终.babelrc配置正确传递:

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

关于reactjs - React Native - 将选项allowNamespaces传递给babel typescript 插件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59162784/

相关文章:

react-native - 如何使 react native svg 路径更平滑

javascript - 自动导入具有相同文件后缀的模块

javascript - 如何清除 FileReader() 缓冲区的内容?

javascript - React componentDidUpdate 不会在 url 更改时更改 props.match.params ?

javascript - 如何在React路由器上获取{match.params.id}的值

performance - 如何让 Perf 在 React-Native 上运行?

javascript - 如何在几秒钟后卸载或删除 React 组件?

android - Expo - 使用 "app signing"证书构建 android app-bundle

android - express 端口 3000,react native 端口 8081,如何发出 get 请求

javascript - 处理 expo react native 中的多个复选框