Editor setup — the TypeScript language server in VS Code and Zed¶
Level: 101 · for anyone who writes TypeScript in an editor
Stub — an outline, not a lesson. There is no runnable example behind this page yet, so nothing on it has been through the check that backs every other claim in this library. The questions below are what the finished page has to answer.
One line: The red squiggles come from a language server, not from tsc: TypeScript 7 builds one into tsc itself (tsc --lsp --stdio answers as typescript-go), but VS Code and Zed start their own tsserver-based server by default, which can check with a different TypeScript.
Keywords: language server, LSP, tsc --lsp, VS Code, Zed, vtsls
What the finished page will answer¶
- What does
tsc --lsp --stdioanswer to an LSPinitializerequest, and which features does it list? - Which TypeScript version does VS Code use for a project that pins 7.0.2, and how does the TypeScript 7 extension change that?
- Which language server does Zed start for
.tsfiles, and how doeslanguage_serversin its settings change it? - Why can the editor show an error that
tscdoes not, and how do you find out which TypeScript each one used? - What does Zed run on save for a TypeScript file, and how do you turn format on save off for one language?
Examples it will need¶
-
editor_setup_tsc_language_server_js.js— the serverInfo and the hover, definition and rename capabilities TypeScript 7'stsc --lsp --stdioreturns to an initialize request -
editor_setup_hover_request_js.js— atextDocument/hoverfor a variable in a small file, answered by the same server with its inferred type
See also¶
- TypeScript 7 — the Go compiler that also serves the editor
tscandtsconfig.json— thetsconfig.jsonthe language server reads- Prettier — the formatter Zed runs on save
- ESLint — lint errors shown beside type errors
- Debugging Node — the debugger both editors attach
- Rust: Zed for Rust: one key to save and run, and three defaults in its way ↗ — the same editor, set up for Rust
- Rust: Choosing an editor for Rust ↗ — choosing an editor for Rust