计算属性“解析错误:'}'预期在”

Blu*_*rog 3 typescript eslint vue.js vuex

我正在使用 typescript 在我的 Vue 组件中设置一个计算属性来定义返回类型,而 eslint 给了我一个错误。关于发生了什么的任何想法?应用程序按预期运行

我曾尝试删除打字或设置get()关联,但无论格式如何,问题仍然存在。

presets():Array<Iperf>{
    return this.$store.state.presets.iperf
}
Run Code Online (Sandbox Code Playgroud)

预期结果应该没有错误,但实际结果是:

Module Warning (from ./node_modules/eslint-loader/index.js):
error: Parsing error: '}' expected at src\views\Iperf.view.vue:58:17:
  56 |     },
  57 |     computed: {
> 58 |         presets():Array<Iperf>{
     |                 ^
  59 |             return this.$store.state.presets.iperf
  60 |         }
  61 |     }
Run Code Online (Sandbox Code Playgroud)

Blu*_*rog 7

我发现 ESLINT 试图将我的 TypeScript 解析为 JSX。所以我修复了一些格式。

不能用: iperf:<Iperf>{}

使用插入: iperf: {} as Iperf