【问题标题】:Stop Visual Studio Code from automatically adding semicolons and single quotes in .ts files阻止 Visual Studio Code 在 .ts 文件中自动添加分号和单引号
【发布时间】:2019-11-23 03:59:45
【问题描述】:

to this question 相关,但与.ts 文件不同。在使用 QuickFix 函数添加缺少的导入时,我希望它使用双引号并阻止它以分号结尾以与现有代码库保持一致。

我已禁用所有扩展,所以我认为这一定是内置的 Typescript 格式。我试过查看visual studio code base,但还没有找到完成的地方。

也许无法使用首选项文件中的某些设置来配置它?

【问题讨论】:

  • 我没有看到这个问题。您是否尝试过使用 code --disable-extensions 启动 Visual Studio Code?​​span>
  • 是的,code --disable-extensions 仍然有这种行为。我正在运行 1.36.1 版,你自己 @grooveplex 吗?
  • 是的,我也是。您查看过您的用户设置吗?
  • 是的,虽然我刚刚找到"typescript.preferences.quoteStyle": "double",,这很好! @grooveplex。我以前只在"typescript.format.... 下查看过一半:) 只需要删除一个分号比用双引号替换单引号要少得多。

标签: typescript visual-studio-code vscode-settings


【解决方案1】:

"typescript.preferences.quoteStyle": "double", 添加到您的settings.json 文件以默认使用双引号。

目前还没有不自动插入分号的解决方案。

【讨论】:

    【解决方案2】:

    尝试这些新设置 (v1.41):

    javascript.format.semicolons

    typescript.format.semicolons

    https://github.com/microsoft/vscode-docs/blob/vnext/release-notes/v1_41.md#semicolon-formatter-options-for-javascript-and-typescript

    选项是:

    • ignore — 不添加或删除分号(默认)。
    • insert — 插图 语句结束处的分号。
    • remove — 删除不必要的分号。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-10-13
      • 2022-07-29
      • 1970-01-01
      • 2011-02-13
      • 2021-12-31
      • 2018-08-12
      • 1970-01-01
      • 2012-04-10
      相关资源
      最近更新 更多