【问题标题】:How to stop visual studio warning about presence of 'public' modifier如何停止有关“公共”修饰符存在的视觉工作室警告
【发布时间】:2018-05-20 08:55:03
【问题描述】:

我有打字稿课

class UserModel
{
    public vipTiers: Array<VipTierDto>;
    public games: Array<GameDto>;
}

这导致在 VisualStudio 2015、TypeScript 2.0.6 中向我显示此警告 您的代码风格要求没有“公共”修饰符

显然我更喜欢保留私有/公共修饰符。在哪里可以设置编码风格?

这是我的 tsconfig.json

{
  "compileOnSave": true,
  "compilerOptions": {
    "module": "commonjs",
    "noImplicitAny": true,
    "preserveConstEnums": true,
    "removeComments": true,
    "sourceMap": true
  },
  "include": [
    "**/*.ts"
  ]
}

【问题讨论】:

  • 一些很好的讨论 here 关于这方面的最佳实践。

标签: visual-studio typescript


【解决方案1】:

我认为这个警告来自 ReSharper 而不是 Visual Studio。如果使用 ReSharper,您可以转到 ReSharper --> 选项 --> TypeScript --> 代码样式。然后选中“使用显式'public'修饰符”。对我有用。

【讨论】:

  • 谢谢。请注意,在较新版本的 VS 中,它是 Extensions --> Resharper --> ....
猜你喜欢
  • 1970-01-01
  • 2016-02-11
  • 2011-06-10
  • 2017-04-25
  • 1970-01-01
  • 2021-03-28
  • 1970-01-01
  • 2011-08-23
  • 1970-01-01
相关资源
最近更新 更多