【问题标题】:Private/public modifiers with Typescript and eslint使用 Typescript 和 eslint 的私有/公共修饰符
【发布时间】:2016-11-22 04:20:52
【问题描述】:

如何配置 eslint 以允许 Typescript 类成员修饰符(private、public)?

目前如果我写:

class Foo {
    constructor(private bar) {

    }
}

eslint 告诉我:error Parsing error: Unexpected token

我在我的.eslintrc 中使用"parser": "babel-eslint"

【问题讨论】:

  • 删除我的答案...因为我不知道语法是可能的。无论如何,它的可读性似乎很糟糕
  • Typescript 不是javascript,不能在上面使用java script 相关工具。

标签: javascript typescript


【解决方案1】:

TSLint is deprecated

改用@typescript-eslint/eslint-plugin 包。

查看this 了解有关 typescript eslint 插件的更多信息。

【讨论】:

  • 是的,它解决了我的问题
【解决方案2】:

babel-eslint doesn't support TypeScript。改用TSLint 可能会更好。

【讨论】:

  • tslint 不支持indent-size 规则:|
  • @kamilkp:是的,它并不完美):但在 TypeScript linting 方面,它几乎是唯一得到良好支持的选项。
  • @JoeClay tslint 已弃用
猜你喜欢
  • 2011-01-31
  • 2017-01-03
  • 1970-01-01
  • 2021-10-09
  • 1970-01-01
  • 2011-11-11
  • 2015-09-26
  • 2019-07-15
相关资源
最近更新 更多