带有 ESLint 的 TypeScript:解析错误:关键字 'enum' 是保留的 eslint [英] TypeScript with ESLint: Parsing error: The keyword 'enum' is reserved eslint

查看:520
本文介绍了带有 ESLint 的 TypeScript:解析错误:关键字 'enum' 是保留的 eslint的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在用 React 编写 TypeScript.该项目是由 CRA 生成的.我为 .eslintrc.json 使用了 react-app 配置.但是我决定使用 eslint-config-airbnb 所以我添加了它并更改了我的 .eslintrc.json

I am writing TypeScript with React. The project was generated with CRA. and I used react-app config for the .eslintrc.json. However I decided to use eslint-config-airbnb so I added it and changed my .eslintrc.json

{
  "extends": [
    "airbnb",
  ]
}

突然我从 ESLint 得到了关于我在代码库中使用的 enum 类型的解析错误

suddenly I got parsing error from ESLint about the enum type I used in the codebase

`Parsing error: The keyword 'enum' is reserved eslint`

我用谷歌搜索但找不到答案.尝试添加一些额外的配置,如

I googled it but cannot find the answer. Tried to add some extra config like

"parserOptions": {
    "ecmaVersion": 7,
  }

但它并没有解决问题

推荐答案

我发现我只需要在 ESLint 的配置文件中添加这一行

I found out I just needed to add this one line in the config file of ESLint

"parser": "@typescript-eslint/parser"

这篇关于带有 ESLint 的 TypeScript:解析错误:关键字 'enum' 是保留的 eslint的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆