0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

VSCodeのPrettierでTypeScript5.2(using句等)をサポートさせる

Last updated at Posted at 2023-12-06

TypeScript5.2で導入されたusing句を使ってみたところ、VSCodeのPrettierが以下のようにエラーを吐いて整形してくれませんでした。

SyntaxError: Unexpected keyword or identifier. (17:5)
> 17 |     using db = await DataBase.connect();

色々調べたところTypeScript5.2はPrettier V3からサポートされているようです。

Support TypeScript 5.2 · Issue #15004 · prettier/prettier · GitHub
https://github.com/prettier/prettier/issues/15004

Prettier V3を使用させる場合は以下の手順が必要でした(勘違いがあればご指摘ください)。

  1. 以下のコマンドでプロジェクトにPrettier V3をインストールする

    npm install prettier@3
    
  2. プロジェクトの.vscode/settings.jsonに以下の設定を追加(パスはプロジェクトごとに合わせる)

    json
    {
        //
        // 省略
        //
        "prettier.prettierPath": "./path/to/node_modules/prettier"
    }
    
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?