typescript-native-lsp
TypeScript and JavaScript code intelligence for Claude Code from the language server that the native TypeScript 7 compiler has built in (tsc --lsp --stdio). It replaces the official typescript-lsp plugin, which runs typescript-language-server: that server wraps tsserver.js, and TypeScript 7 does not ship it.
Install
From a Claude Code session (Claude Code 2.1.275 or later; on an older version use the shell commands below):
/plugin install typescript-native-lsp --marketplace vshuraeff/typescript-native-lsp
Or from the shell:
claude plugin marketplace add vshuraeff/typescript-native-lsp
claude plugin install typescript-native-lsp@typescript-native-lsp
If the official typescript-lsp plugin is installed, disable or uninstall it, so the two servers do not both claim .ts and .js files: claude plugin uninstall typescript-lsp@claude-plugins-official. Restart Claude Code after installing.
Why the relay
Claude Code reads type errors only from pushed textDocument/publishDiagnostics notifications. TypeScript 7 serves per-file diagnostics only on request (textDocument/diagnostic), so without help Claude never sees the errors an edit introduces (anthropics/claude-code#101041).
server/relay.ts sits between the two. It answers the server's workspace/diagnostic/refresh request itself until Claude Code pulls diagnostics on its own, keeps the server's replies to its own diagnostic pulls (Claude Code gets the resulting publishDiagnostics instead), numbers the document versions it sends the server itself, forwards the server's requests to Claude Code under ids of its own (see Idle shutdown), forwards all other traffic unchanged, and it also:
- adds pull-diagnostic support to the client capabilities of
initialize, with the diagnostic details the client accepts for pushed diagnostics;
- requests diagnostics for every open document once 150 ms have passed since the latest
didOpen, didChange, didSave, didClose, workspace/diagnostic/refresh or change found on disk, so continuous typing delays the pull until it pauses; it pulls every open document because a change in one file can change the errors of another;
- pushes each answer to Claude Code as
publishDiagnostics, and pushes an empty list when a document closes;
- drops an answer that a later open, change, close or refresh has made stale, and cancels the pulls it supersedes;
- pulls a document once more when the server cancels its pull with
ServerCancelled and does not set retriggerRequest: false, and no more than once per round;
- sends no pulls after the client's
shutdown, and kills the server when the client closes its end and the server does not exit within 2 s;
- keeps open documents in line with disk. Claude Code opens a document the first time it edits or queries a file, never closes it, and sends nothing when the file changes outside its Edit and Write tools (a shell command,
git checkout, a formatter, code generation), while the server trusts an open document over the file. Before each request from Claude Code the relay checks every open file: document: when the file's mtime or size changed and its text differs from what the server holds, the server gets the file's text; when the file is gone, the relay closes the document on the server and pushes an empty list, and opens it again when the file comes back or Claude Code changes it. A change found on disk starts new pulls like a didChange;
- switches its own pulls off the first time Claude Code sends a
textDocument/diagnostic request itself: it cancels the pulls in flight, publishes nothing more, and forwards workspace/diagnostic/refresh to Claude Code instead of answering it. It decides on that request rather than on the capabilities Claude Code announces.
The relay pulls nothing when the server announces no diagnosticProvider. Its disk sync stays on in every case.
Claude Code starts the server in the project directory. plugin.json therefore runs bun with --no-env-file and --config pointing at the plugin's empty bunfig.toml, so a project's .env and bunfig.toml (a preload above all, which could write to stdout and break the LSP stream) do not reach the relay or the server.
Idle shutdown