The editor and the TypeScript language server
How the TypeScript language server powers hovers, quick fixes, and refactors in your editor, and what the Go-native TypeScript 7 compiler changes.
The editor and the TypeScript language server
The player loads from youtube-nocookie.com when you press play. Nothing reaches YouTube before that.
Not started
What you'll learn
- Editor features like hovers, autocomplete, inline errors, go to definition, and rename all come from a TypeScript language server, a long-running process built on the same checker as `tsc`.
- The language server keeps your project in memory and rechecks only what a keystroke affects, which is why it can answer in milliseconds where a cold `tsc` run takes seconds.
- Quick fixes and refactors such as adding a missing import, extracting a function, or renaming a symbol across files are type-aware edits, safer than find-and-replace because the server knows which identifiers refer to the same thing.
- Make the editor use the project's own TypeScript version rather than the one it bundles, so the errors you see while typing match what `tsc` reports in CI.
- TypeScript 7 is a port of the compiler and language server from TypeScript to Go. Native code plus parallel checking makes it around ten times faster on large projects, which shortens CI type checks and keeps editors responsive in big codebases.
The checker that never stops running
Running tsc on a project means reading every file, parsing it, building types for everything, and checking each line, then exiting and throwing all that work away. On a large codebase that takes seconds or longer. That’s fine for CI. In an editor that has to react to every keystroke, it would be unusable.
So the editor doesn’t run tsc. It talks to a language server: a separate, long-lived process built on the same checker. It loads your project once, keeps the parsed files and computed types in memory, and after each edit redoes only the work that edit can affect. Then it answers small questions: what’s the type at line 12, column 8? Where is createUser defined? What can come after user.?
Think of the difference between a library that re-shelves every book each time someone asks a question, and a librarian who already knows where everything is and only updates the catalog when a new book arrives. Same knowledge, very different response time.
For most of TypeScript’s history this server was tsserver, shipped inside the typescript npm package. VS Code talks to it directly, and other editors such as Neovim, Zed, and WebStorm connect through their own integrations. The features are largely the same everywhere because they all come from TypeScript itself, not from the editor.
What the server gives you
- Hovers. Rest the cursor on any identifier and see its inferred type. This is the fastest way to learn what TypeScript actually thinks, and you’ll use it in every later lesson.
- Inline errors. The same diagnostics
tscwould print, underlined as you type. - Autocomplete that only offers members the type really has.
- Go to definition and find all references, across files and into
.d.tsfiles of libraries. - Rename symbol. Changes a function, variable, or property everywhere it’s actually referenced, including imports in other files, and leaves unrelated things with the same name alone.
Quick fixes and refactors
When there’s an error under the cursor, the editor’s lightbulb (Ctrl+. or Cmd+. in VS Code) asks the server for quick fixes:
const user = createUser("ada");
// Error: Cannot find name 'createUser'.
// Quick fix: Add import from "./users"
Others include adding a missing property to an object literal, implementing an interface’s members in a class, or adding await to an unawaited promise.
Refactors work on code that has no error: extract a selection into a function or constant, move a declaration to a new file (with imports updated), convert between named and default exports, or organize imports. These aren’t text macros. The server rewrites the code knowing what each identifier refers to, which is why they’re safe across a whole project.
Keep the editor and CI on the same version
VS Code bundles its own TypeScript. If your project pins a different version, the editor and tsc can disagree: green in the editor, red in CI. Run TypeScript: Select TypeScript Version from the command palette and choose the workspace version, the one in node_modules. Committing this to .vscode/settings.json sets it for the whole team:
{
"typescript.tsdk": "node_modules/typescript/lib"
}
One more difference: the editor mostly reports errors for files you have open. tsc --noEmit checks every file in the project, so it stays the final word.
TypeScript 7: the compiler rewritten in Go
The TypeScript compiler was always written in TypeScript, running on a JavaScript engine. That worked, but large projects pushed it hard: slow cold checks, long editor start-up, and heavy memory use.
The TypeScript team’s answer was a port, not a rewrite: the existing compiler and language server, translated file by file into Go and released as TypeScript 7. The type system is meant to behave the same. The speed-up, around ten times on large codebases, comes from two places. Go compiles to native machine code, so there’s no JIT warm-up. And the checker can now spread work across all CPU cores with shared memory, which a single JavaScript thread couldn’t do. During the preview period the native compiler was available as a separate command, tsgo.
What that means in practice:
- CI type checks that took minutes can take seconds.
- Editors load big projects faster and stay responsive. The new language server speaks the standard Language Server Protocol, the same protocol most editors already use for other languages.
- Tools built on the old JavaScript compiler API, such as some lint rules and plugins, need updates to work with the native version, so check your toolchain’s support before switching a large project.
What the video covers
This VS Code Day session with Matt Pocock is a live tour of the features above: hovers, quick fixes, refactors, navigation, and several lesser-known tricks for reading types in the editor. It’s from 2023, so it shows the original JavaScript-based tsserver and says nothing about TypeScript 7. The editor features it demonstrates still work the same way. For the native compiler, watch Anders Hejlsberg’s “TypeScript 7 Is Here” in the links below.
Check yourself
Why does renaming a function with the editor's Rename Symbol command beat a project-wide find-and-replace?
The language server knows which identifiers actually refer to that function, including imports and re-exports, and ignores unrelated things that share the name, such as a property on another type or a word in a comment. Find-and-replace only matches text.
Your editor shows no errors but CI's `tsc --noEmit` fails. What is a likely cause?
The editor is using a different TypeScript version or a different tsconfig than CI, often its bundled TypeScript instead of the project's. It can also be that the error is in a file you never opened, since editors focus on open files while `tsc` checks the whole project.
How can the language server respond instantly when a full `tsc` run takes several seconds?
It stays running and keeps the parsed and checked program in memory. After an edit it only redoes the work that edit can affect, and it answers questions about one position in one file rather than reporting on the whole project.
Why is TypeScript 7 so much faster than earlier versions?
The compiler and language server were ported from TypeScript, running on a JavaScript engine, to Go, which compiles to native code and can check files in parallel across CPU cores with shared memory. The type system itself is meant to behave the same.
Go deeper
Notes
Notes are saved to your account.
Everything else on this page works without one — progress and bookmarks keep themselves in this browser and come with you when you sign in. Notes are the one thing worth not trusting to a browser you might clear.
Your notes could not be loaded.