【问题标题】:Getting syntax error on my upgrade to RN 0.57 with TypeScript使用 TypeScript 升级到 RN 0.57 时出现语法错误
【发布时间】:2019-02-25 19:50:43
【问题描述】:

我正在尝试使用 react-native-typescript-transformer 升级我的项目,该项目使用 RN 0.56 + Typescript 编译器

现在最新版本的 Babel 支持 Typescript,我已经删除了 TS 编译器并尝试使用 RN + Babel 7 来编译我的代码。

但是,我收到以下错误:

error: bundling failed: SyntaxError: /Users/alexis.mangin/Workspace/zeos-native/packages/zeos-native-libs/ui/src/views/StickyTabView.tsx: Unexpected token, expected ")" (12:38)

  10 |
  11 | export interface IStickyTabViewProps {
> 12 |   renderTopNavigationBar: ({ opacity }: { opacity: Animated.AnimatedInterpolation }) => JSX.Element;
     |                                       ^
  13 |   renderHeader: () => JSX.Element;
  14 |   headerMinHeight: number;
  15 |   tabs: {

我在这里看到一些人遇到同样的问题:https://github.com/ds300/react-native-typescript-transformer/issues/77

尽管如此,即使删除了转换器的所有实例,我仍然无法让我的代码运行。

有谁知道我该如何解决这个问题?

RN:0.57.0 反应:16.5.0 打字稿:3.0.3

谢谢!

【问题讨论】:

    标签: typescript react-native babeljs


    【解决方案1】:

    检查您的 TSConfig;您可能需要通过将downlevelIteration 设置为true 来启用解构。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-06-14
      • 1970-01-01
      • 2018-11-14
      • 2018-12-22
      • 1970-01-01
      • 1970-01-01
      • 2016-11-22
      • 2015-05-24
      相关资源
      最近更新 更多