Skip to content

Conversation

@OleksandraKordonets
Copy link

@OleksandraKordonets OleksandraKordonets commented Nov 21, 2025

Fixes #956
This PR adds optional support for a new TypeScript server feature that allows the editor to provide file watch events instead of having tsserver watch all files directly. When enabled and supported, this can significantly reduce the number of filesystem watchers in large workspaces.

Changes:

  • Added a new optional CLI option: --canUseWatchEvents
  • Passed --canUseWatchEvents to tsserver when supported
  • Implemented a WatchEventManager to track tsserver watcher requests and manage dynamic workspace watchers
  • Forwarded relevant client file change notifications to tsserver using the watchChange request
  • Added support for new tsserver events: createFileWatcher, createDirectoryWatcher, closeFileWatcher
  • Added fallback behavior with warnings when prerequisites are not met

When this feature is enabled and all requirements are satisfied the server will:

  • Launch tsserver with --canUseWatchEvents
  • Register minimal LSP file watchers instead of tsserver watching everything
  • Forward DidChangeWatchedFiles events to tsserver as watchChange notifications
  • If any prerequisite is missing, the server logs an explanation and falls back to the existing behavior, ensuring there is no change or risk for existing users.

Notes:
Requires TypeScript >= 5.4 and client support for dynamic watched-files registration and relative patterns. And if any prerequisite is missing, a warning is logged and the server continues with normal tsserver file watching, so no behavior change for existing users.

@OleksandraKordonets OleksandraKordonets changed the title Add support for --canUseWatchEvents and watch event forwarding feat: Add support for --canUseWatchEvents and watch event forwarding Nov 21, 2025
@github-actions github-actions bot added the feat label Nov 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Pass --canUseWatchEvents to tsserver

1 participant