microsoft / microsoft/TypeScript

Add support for `willDeleteFiles`/`didDeleteFiles` to tsserver

オープン
#54,986 コメント 0 件 リアクション 4 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

Awaiting More Feedback Suggestion
主要言語
Go
スター
111k
フォーク
14.4k
平均マージ
1日 19時間
マージ済み PR(30日)
117

説明

Suggestion

🔍 Search Terms

willDeleteFiles/didDeleteFiles
update errors after deleting file
deleting file
removing file
renaming file

✅ Viability Checklist

My suggestion meets these guidelines:

  • This wouldn't be a breaking change in existing TypeScript/JavaScript code
  • This wouldn't change the runtime behavior of existing JavaScript code
  • This could be implemented without emitting different JS based on the types of the expressions
  • This isn't a runtime feature (e.g. library functionality, non-ECMAScript syntax with JavaScript output, new syntax sugar for JS, etc.)
  • This feature would agree with the rest of TypeScript's Design Goals.

⭐ Suggestion

Add support for willDeleteFiles/didDeleteFiles (https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#workspace_willDeleteFiles)
As for my current knowledge, tsserver right now watches filesystem on its own, as mentioned in this article. Unfortunately this method is not always correct and sometimes (specifically in larger repositories) after renaming files, or deleting them - tsserver does not know that the filesystem was changed resulting in out-of-sync error messages.
Adding support for such methods would allow editors to notify tsserver that something has changed and then tsserver could internally update it's state about the files.

📃 Motivating Example

https://github.com/microsoft/TypeScript/assets/35625949/1eec8678-8af6-43d0-bf2f-25eecbac0b96

In this example, when file is deleted by the user, the diagnostic about file not existing is not shown. It might be shown after some time in the future, but an editor can send this notification to the server immediately after user performs an action

💻 Use Cases

For now the only way to deal with this is to restart tsserver. While this solution works it would be nicer user experience for this to happen automatically.

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

まず、tsserver のファイルシステム監視の動作と、ワークスペースのファイル削除通知に関するリンク先の Language Server Protocol 仕様を確認します。現在、ファイルの削除と名前変更がどのように tsserver に到達しているかを追跡し、その後、必要な通知処理を特定します。エディターが willDeleteFiles/didDeleteFiles を通じて tsserver に通知でき、再起動を必要とせずにその診断が同期された状態を保てれば完了です。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
typescript
領域
devtools
issue の種類
機能追加
難易度
4/5
見積もり時間
3〜5日
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
35/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。