microsoft/TypeScript
Language-service features
The user-facing IDE capabilities the language service provides. This page is the per-feature index; for the architecture of the service itself see systems/language-service, and for refactors and code-fixes specifically see features/refactors-and-codefixes.
Feature catalogue
| Feature | File | Notes |
|---|---|---|
| Completions | src/services/completions.ts (6,173 lines) |
Symbol-based, keyword, JSX-attribute, string-literal, paths, JSDoc-tag completions; auto-import support |
| String completions | src/services/stringCompletions.ts |
Specifically string-literal contexts: imports, process.env, etc. |
Hover (quickInfo) |
src/services/services.ts → symbolDisplay.ts |
Type + JSDoc panel |
| Signature help | src/services/signatureHelp.ts |
Per-parameter info while typing a call |
| Go to definition | src/services/goToDefinition.ts |
Definition / type-definition / implementation |
| Find all references | src/services/findAllReferences.ts (2,803 lines) |
Powers find-references and rename |
| Rename | services/rename.ts + reuses findAllReferences |
Single-symbol cross-file rename |
| Document highlights | src/services/documentHighlights.ts |
Same-file occurrence highlighting |
| Inlay hints | src/services/inlayHints.ts |
Inferred-type / parameter-name hints |
| Outlining (folding) | src/services/outliningElementsCollector.ts |
Foldable regions |
| Smart selection | src/services/smartSelection.ts |
"Expand selection" |
| Navigate to | src/services/navigateTo.ts |
Fuzzy symbol search |
| Navigation bar | src/services/navigationBar.ts |
Top-of-document outline |
| Call hierarchy | src/services/callHierarchy.ts |
Incoming/outgoing calls |
| Breakpoints | src/services/breakpoints.ts |
Validate/compute breakable spans |
| Classifier | src/services/classifier.ts + classifier2020.ts |
Syntactic + semantic colourisation |
| Suggestion diagnostics | src/services/suggestionDiagnostics.ts |
"Did you mean async?", unused-symbol style suggestions |
| Format | src/services/formatting/ |
On-type, range, document formatting |
| Map code | src/services/mapCode.ts |
Suggest-diff-style mapping for AI assistants |
| Paste edits | src/services/pasteEdits.ts |
Update imports when pasting code from another file |
| Rename file | src/services/getEditsForFileRename.ts |
Update import paths when a file is renamed |
| Organize imports | src/services/organizeImports.ts |
Sort + remove unused imports |
| Code fixes | src/services/codefixes/ |
See features/refactors-and-codefixes |
| Refactors | src/services/refactors/ |
See features/refactors-and-codefixes |
| Transpile | src/services/transpile.ts |
transpileModule / transpileDeclaration (used by tools like Babel and Vite) |
Cross-feature primitives
Several files are heavily reused:
src/services/utilities.ts(170k+ effective lines) — finding the right node/symbol for a position, walking AST contexts, etc.src/services/textChanges.ts— theChangeTrackerused by every feature that returns edits.src/services/exportInfoMap.ts— auto-import index of exports across the program.src/services/importTracker.ts— find-all-references support across import boundaries.src/services/patternMatcher.ts— fuzzy matcher for navigateTo and completions.
Feature lifecycle
sequenceDiagram
participant Editor
participant tsserver as src/server/session.ts
participant Service as createLanguageService
participant Provider as e.g. completions.ts
participant Checker as checker.ts
Editor->>tsserver: { command: "completionInfo", ... }
tsserver->>Service: getCompletionsAtPosition(file, pos, options)
Service->>Provider: getCompletionsAtPosition
Provider->>Service: program.getTypeChecker
Service->>Checker: getSymbolsInScope, getTypeAtLocation
Checker-->>Provider: types/symbols
Provider->>Service: CompletionInfo
Service->>tsserver: CompletionInfo (translated to protocol shape)
tsserver->>Editor: response messageTests
Almost all language-service features are tested with fourslash. The pattern:
/// <reference path="fourslash.ts" />
////import { /*1*/ } from "./util";
verify.completions({ marker: '1', includes: ['foo', 'bar'] });tests/cases/fourslash/ contains roughly 3,500 of these. See how-to-contribute/testing.
Entry points for modification
- New feature: extend
LanguageServiceinsrc/services/types.ts, implement undersrc/services/, expose throughtsserverviasrc/server/protocol.tsand aSessionhandler insrc/server/session.ts. - New language-service mode behaviour: see
LanguageServiceModeinsrc/services/types.tsand the dispatch inservices.ts.
See systems/language-service for the surrounding architecture.
Built by Factory AutoWiki from public repository content. It is a generated preview for codebase exploration, not source-maintained documentation.