microsoft / microsoft/TypeScript
Add support for `willDeleteFiles`/`didDeleteFiles` to tsserver
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 111k
- Forks
- 14.4k
- Avg merge
- 1d 19h
- Merged PRs (30d)
- 117
Description
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.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reviewing tsserver's filesystem-watching behavior and the linked Language Server Protocol specification for workspace file deletion notifications. Trace how file deletion and renaming currently reach tsserver, then determine the notification handling needed. Done means editors can notify tsserver through willDeleteFiles/didDeleteFiles and its diagnostics stay synchronized without requiring a restart.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- devtools
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100