The Language Service Architecture
What you'll learn: How TypeScript's language service enables real-time type-checking and editor features without constantly recompiling your entire project.
When you type in VS Code or another editor, TypeScript doesn't run tsc over and over. Instead, a separate program called tsserver (the TypeScript language service) runs in the background as a long-lived process. Your editor communicates with tsserver, sending it information about what file you're editing and what changes you've made.
How the Architecture Works
Think of tsserver as a dedicated assistant who knows your entire codebase. When you open a file, your editor tells tsserver: "The user opened users.ts." When you type a character, the editor sends: "Line 42 now has this new text."
Tsserver maintains an in-memory representation of your project's type information. It doesn't re-parse everything from scratch with each keystroke. Instead, it:
- Updates only the affected file's Abstract Syntax Tree (AST)
- Re-checks types incrementally based on what changed
- Caches type information for unchanged files
- Responds to the editor with diagnostics (errors/warnings), autocompletion suggestions, or type information
Why Type-Checking Is Continuous
Because tsserver runs persistently, type-checking happens continuously in the background. You don't wait for a build step—the moment you introduce a type error, tsserver detects it and tells your editor to show a red squiggle.
This architecture separates the editing experience from the build process. Running tsc --build still compiles your code to JavaScript, but tsserver provides instant feedback without emitting any files at all.
Key Takeaway: TypeScript's language service architecture keeps tsserver running as a background process, enabling real-time type-checking and editor features through incremental, in-memory analysis rather than full recompilation.