【问题标题】:How to make prettier autoformatter in VScode not remove commas from typescript types after I added React添加React后如何在VScode中制作更漂亮的自动格式而不是从打字稿类型中删除逗号
【发布时间】:2022-01-01 22:32:25
【问题描述】:

当我打开自动格式化保存文件时,类型

type Params = {
  fileName: string,
  isTxt: boolean
}

将保存为

type Params = {
  fileName: string
  isTxt: boolean
}

哪个 React 不再接受。在我将 React 添加到项目后,Prettier 才开始删除逗号。我怎样才能让更漂亮不要那样做?

我在 VScode 1.62.3 中使用 Prettier 扩展 v9.0.0 和 Typescript v4.5.2。

使用.prettierrc

{
  "semi": false,
  "trailingComma": "none",
  "singleQuote": true,
  "printWidth": 80
}

【问题讨论】:

    标签: reactjs typescript visual-studio-code prettier


    【解决方案1】:

    您可以将trailingComma 设置为all

    【讨论】:

    • 即使我想要一个尾随逗号 - 它也行不通。
    • 您应该更正更漂亮的配置文件的名称。当前名称是 pretterc 并将其更改为 .prettierrc @MilanSmolík
    • 文件命名正确,我在问题中拼错了。我会更新的。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2022-11-18
    • 2018-01-06
    • 2018-07-08
    • 2021-08-14
    • 2020-05-02
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多