Skip to content

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 --stdio answer to an LSP initialize request, 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 .ts files, and how does language_servers in its settings change it?
  • Why can the editor show an error that tsc does 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's tsc --lsp --stdio returns to an initialize request
  • editor_setup_hover_request_js.js — a textDocument/hover for a variable in a small file, answered by the same server with its inferred type

See also

Sources to start from