Angular 108 🅰️ Angular Language Service and IDE Setup
The Angular Language Service is the tool that gives editors and IDEs a real understanding of Angular templates. Without it, an HTML file is just text. With it, the editor knows that user in {{ user.name }} refers to a component property, that app-user-card is a component selector, and that binding to an unknown property is an error. The service provides completions, diagnostics, quick info, and go-to-definition inside templates, whether the template is inline in a .ts file or external in a .html file .
The previous chapters covered testing, performance, and debugging. This chapter covers the setup that makes all of that work in the editor. The Language Service is not part of the Angular runtime. It is a separate tool that reads the project’s tsconfig.json, finds the templates, and provides the same kind of intelligence that TypeScript provides for .ts files. The service is available for VS Code, WebStorm, Sublime Text, Eclipse, Neovim, and other editors through either official extensions or community plugins .
Key point: The Angular Language Service is not the Angular compiler. It does not build the application. It is a language server that provides editor intelligence by reusing the compiler’s analysis. The service reads the project’s tsconfig.json and angularCompilerOptions to determine how to analyze the templates. The strictTemplates option enables the strongest diagnostics. Without it, the service provides completions but weaker error checking .
Why the Language Service Matters
Angular templates are not plain HTML. They contain interpolations, property bindings, event bindings, structural directives, and component selectors. A plain HTML editor sees none of this. The Angular Language Service adds the Angular-specific understanding.
The completion problem. In a template, {{ user. }} should suggest the properties of the user object. The Language Service provides the completion list. In a template, <app- should suggest the component selectors available in the module. The Language Service provides the list. Without it, the developer types the property or selector from memory .
The error problem. A template that binds to [userName] when the component input is user is an error. A template that uses *ngFor without importing CommonModule is an error. The Language Service reports these errors in the editor, before the build runs. The errors are the same errors the compiler would report, but they appear immediately .
The navigation problem. Hovering over app-user-card in a template shows where the component is defined. Pressing F12 or clicking “Go to definition” jumps to the component class. The Language Service provides the navigation. Without it, the developer searches the file system manually .
The AOT problem. The Language Service uses the same analysis that the Ahead-of-Time compiler uses. The diagnostics are AOT diagnostics. This means the errors the editor shows are the errors the production build would produce. The editor becomes a fast preview of the build .
The trade-off. The Language Service adds a background process to the editor. It reads the project’s TypeScript configuration and analyzes the templates as the developer types. On a large project, the analysis can be slow. The strictTemplates option makes the analysis stronger but also slower. The trade-off is between the precision of the diagnostics and the responsiveness of the editor.
a. Features
The Angular Language Service provides four core features inside templates: autocompletion, error checking, quick info, and go-to-definition .
Autocompletion provides contextual suggestions as the developer types. In an interpolation, the service suggests the properties and methods of the component. In an element, the service suggests the component selectors, the directives, and the HTML elements. The completion list is filtered by the context. Pressing Tab accepts the completion .
Error checking reports template errors as the developer types. The errors include unknown properties, unknown elements, type mismatches in bindings, and missing imports. The errors are the same errors the AOT compiler reports during the build. The editor shows them as squiggly underlines and in the Problems panel .
Quick info shows the type and the origin of a symbol when the developer hovers over it. Hovering over a component selector shows the component class. Hovering over a property binding shows the property type. The quick info is the same kind of information TypeScript provides for .ts files .
Go to definition navigates from a template symbol to its definition. Clicking “Go to definition” or pressing F12 on a component selector jumps to the component class. On a pipe, it jumps to the pipe class. On a property, it jumps to the property declaration .
The service also provides AOT diagnostic messages. These are the messages the Ahead-of-Time compiler produces. The messages include the template location, the error code, and the error description .
b. Configuring strictTemplates
The strictTemplates option in tsconfig.json enables the strongest diagnostics from the Language Service. Without it, the service provides completions but the error checking is weaker .
{
"angularCompilerOptions": {
"strictTemplates": true
}
}
The strictTemplates option enables a set of strict checks for templates. It includes strictInputTypes, strictNullInputTypes, strictDomEventTypes, strictOutputEventTypes, strictSafeNavigationTypes, and strictContextGenerics. Each check is a separate flag that can be enabled or disabled individually. The strictTemplates option enables all of them .
When strictTemplates is enabled, the Language Service reports errors that would otherwise be missed. A binding that passes a string to an input that expects a number is an error. A binding that passes a possibly null value to an input that does not accept null is an error. A DOM event binding that does not match the event type is an error. The errors appear in the editor as the developer types .
The trade-off is that enabling strictTemplates on an existing project may produce many errors. The errors are real, but they were not reported before. The recommended approach is to enable the option and fix the errors incrementally. The Angular compiler options guide documents each flag and its effect .
c. Editor Setup
The Angular Language Service is available for multiple editors. The installation method depends on the editor.
Visual Studio Code has the official extension maintained and distributed by the Angular team. The extension is installed from the Extensions marketplace. Open the marketplace with the Extensions icon or with Ctrl+P and typing ? ext. Search for “Angular Language Service” and install it .
WebStorm has the Angular and AngularJS plugin built in. The plugin is enabled from the Settings menu. Since WebStorm 2019.1, the @angular/language-service package is no longer required in package.json and should be removed if present .
Visual Studio has an extension maintained by Microsoft with help from the Angular team. The extension is installed from the Extensions menu .
Sublime Text supports the Language Service through a plug-in. The plug-in supports inline templates. For external templates, a custom plug-in or modifications are needed. The installation requires the @angular/language-service package and a TypeScript plug-in configuration .
Eclipse IDE supports the Language Service through the “Eclipse IDE for Web and JavaScript developers” package or the Wild Web Developer extension. The package comes with the Angular Language Server included .
Neovim supports the Language Service through the Conquer of Completion (COC) plugin. The coc-angular extension provides the integration. The COC plugin has the fullest implementation of the Language Service because it ports the VS Code client. The extension provides the same completions, diagnostics, quick info, and go-to-definition features .
d. How It Works Under the Hood
The Angular Language Service is a language server that communicates with the editor through the Language Server Protocol (LSP) or through a custom protocol. The service reads the project’s tsconfig.json and uses the Angular compiler’s analysis to provide the editor features .
The service is built on the Ivy compiler. It uses the compiler’s incremental compilation to stay responsive. When the developer types in a template, the service recompiles only the affected component. The incremental compilation is the same mechanism that makes ng serve fast. The service pushes it further because it recompiles as the developer types, not just on save .
The template analysis uses Type Check Blocks (TCBs). The compiler generates TypeScript code for each template. The generated code represents the bindings and expressions in the template. The compiler asks TypeScript to check the generated code. The errors TypeScript finds in the TCB indicate real errors in the template. The TCB is the bridge between the Angular template and the TypeScript type system .
The service runs as a separate process from the editor. The editor sends the file content to the service. The service analyzes the content and sends back the diagnostics, completions, and navigation results. The communication is through LSP or a custom protocol. The separation means the service can be updated independently of the editor .
Complete Example Session
This session demonstrates the Language Service features in a VS Code environment.
// ============================================
// PART 1: THE COMPONENT
// ============================================
// user-profile.component.ts
import { Component, input } from '@angular/core';
export interface User {
id: number;
name: string;
email: string;
}
@Component({
selector: 'app-user-profile',
template: `
<div class="profile">
<h2>{{ user().name }}</h2>
<p>{{ user().email }}</p>
</div>
`,
})
export class UserProfileComponent {
user = input.required<User>();
}
// ============================================
// PART 2: THE PARENT TEMPLATE
// ============================================
// app.component.html
<app-user-profile [user]="currentUser" />
<!-- Type "app-" and the Language Service suggests "app-user-profile" -->
<!-- Type "currentUser." inside the binding and the service suggests "id", "name", "email" -->
// ============================================
// PART 3: THE ERROR DIAGNOSTIC
// ============================================
// app.component.html
<app-user-profile [user]="wrongUser" />
<!-- The Language Service reports: "Property 'wrongUser' does not exist on type 'AppComponent'" -->
// ============================================
// PART 4: THE TYPE ERROR
// ============================================
// app.component.html
<app-user-profile [user]="'not a user'" />
<!-- The Language Service reports: "Type 'string' is not assignable to type 'User'" -->
// ============================================
// PART 5: THE QUICK INFO
// ============================================
// Hover over "app-user-profile" in the template.
// The quick info shows: "Component: UserProfileComponent"
// Press F12 to go to the definition.
// ============================================
// PART 6: THE COMPLETION
// ============================================
// Inside the interpolation {{ user(). }}:
// The service suggests: "id", "name", "email"
// Inside the element <app-:
// The service suggests: "app-user-profile"
// ============================================
// PART 7: THE strictTemplates CONFIGURATION
// ============================================
// tsconfig.json
{
"angularCompilerOptions": {
"strictTemplates": true
}
}
// With strictTemplates enabled:
// - The null check is enforced
// - The type check is enforced
// - The DOM event type is enforced
// ============================================
// PART 8: THE INSTALLATION IN VS CODE
// ============================================
// 1. Open VS Code.
// 2. Press Ctrl+P (Cmd+P on Mac).
// 3. Type "? ext" and press Enter.
// 4. Search for "Angular Language Service".
// 5. Click Install.
// 6. Reload the window.
// ============================================
// PART 9: THE WEBSTORM SETUP
// ============================================
// 1. Open WebStorm.
// 2. Go to Settings > Languages & Frameworks > TypeScript.
// 3. Enable the "Angular and AngularJS" plugin.
// 4. Remove @angular/language-service from package.json if present.
// ============================================
// PART 10: THE SUMMARY
// ============================================
// Features: completion, diagnostics, quick info, go-to-definition
// Configuration: strictTemplates in tsconfig.json
// Editors: VS Code, WebStorm, Sublime, Eclipse, Neovim
// Architecture: Ivy compiler, TCB, LSP
The ten parts cover the component, the parent template, the error diagnostic, the type error, the quick info, the completion, the strictTemplates configuration, the VS Code installation, the WebStorm setup, and the summary.
Quick Reference
The Features
| Feature | Description |
|---|---|
| Autocompletion | Contextual suggestions in templates |
| Error checking | AOT diagnostic messages |
| Quick info | Type and origin on hover |
| Go to definition | Navigate to the definition |
The strictTemplates Flags
| Flag | Purpose |
|---|---|
strictTemplates | Enable all strict checks |
strictInputTypes | Check input binding types |
strictNullInputTypes | Check null in input bindings |
strictDomEventTypes | Check DOM event types |
strictOutputEventTypes | Check output event types |
strictSafeNavigationTypes | Check safe navigation types |
strictContextGenerics | Check generic context |
The Editor Support
| Editor | Support | Maintained By |
|---|---|---|
| VS Code | Official extension | Angular team |
| WebStorm | Built-in plugin | JetBrains |
| Visual Studio | Official extension | Microsoft |
| Sublime Text | Community plug-in | Community |
| Eclipse | Wild Web Developer | Eclipse |
| Neovim | coc-angular | Community |
The Architecture
| Component | Purpose |
|---|---|
| Ivy compiler | The analysis engine |
| Type Check Block | The bridge to TypeScript |
| LSP | The editor protocol |
| Incremental compilation | The responsiveness mechanism |
Best Practices
✅ Do This:
// Enable strictTemplates in tsconfig.json
{ "angularCompilerOptions": { "strictTemplates": true } } // ✅
# Install the official VS Code extension
# Angular Language Service from the marketplace // ✅
// Use the completion and diagnostics
// The editor reports template errors before the build // ✅
❌ Don’t Do This:
# Don't install @angular/language-service in WebStorm
# It is built in since 2019.1 // ❌
// Don't forget to reload VS Code after installation
// The extension needs a window reload // ❌
Common Pitfalls
| Pitfall | Why It Happens | Fix |
|---|---|---|
| Extension not working | VS Code not reloaded | Reload the window |
| No diagnostics | strictTemplates not enabled | Enable it in tsconfig.json |
| Slow analysis | Large project | Wait or reduce project scope |
| WebStorm conflict | @angular/language-service in package.json | Remove it |
Real-World Examples
1. Installation in VS Code
# Extensions: Angular Language Service
2. Enable strictTemplates
{ "angularCompilerOptions": { "strictTemplates": true } }
3. Completion in Interpolation
{{ user(). }}
4. Completion in Element
<app-
5. Error Diagnostic
[user]="wrongUser"
6. Quick Info
Hover over "app-user-profile"
7. Go to Definition
Press F12 on "app-user-profile"
8. WebStorm Setup
# Enable Angular and AngularJS plugin
9. Sublime Text Setup
{ "plugins": [{ "name": "@angular/language-service" }] }
10. Neovim Setup
require'lspconfig'.angularls.setup{}
Visual
The Language Service Architecture
┌──────────────────────────────────────────────┐
│ EDITOR (client) │
│ ├─ VS Code │
│ ├─ WebStorm │
│ ├─ Sublime Text │
│ └─ Neovim │
│ │ │
│ │ LSP / custom protocol │
│ ▼ │
│ ANGULAR LANGUAGE SERVICE (server) │
│ ├─ Reads tsconfig.json │
│ ├─ Uses the Ivy compiler │
│ ├─ Generates Type Check Blocks │
│ └─ Returns diagnostics, completions, │
│ quick info, definitions │
│ │
└──────────────────────────────────────────────┘
The Type Check Block
┌──────────────────────────────────────────────┐
│ TEMPLATE │
│ <p>{{ user.name }}</p> │
│ <address-view [address]="user.address" /> │
│ │
│ GENERATED TYPE CHECK BLOCK (simplified) │
│ function UserComponent_TCB(ctx: UserComponent) { │
│ '' + ctx.user.name; │
│ let c0: AddressView = (null!); │
│ c0.address = ctx.user.address; │
│ } │
│ │
│ TypeScript checks the TCB. │
│ Errors in the TCB are errors in the template.│
│ │
└──────────────────────────────────────────────┘
The strictTemplates Checks
┌──────────────────────────────────────────────┐
│ strictTemplates: true │
│ ├─ strictInputTypes │
│ ├─ strictNullInputTypes │
│ ├─ strictDomEventTypes │
│ ├─ strictOutputEventTypes │
│ ├─ strictSafeNavigationTypes │
│ └─ strictContextGenerics │
│ │
│ Each flag can be enabled individually. │
│ strictTemplates enables all of them. │
│ │
└──────────────────────────────────────────────┘
The Editor Support
┌──────────────────────────────────────────────┐
│ VS CODE │
│ Official extension, Angular team │
│ │
│ WEBSTORM │
│ Built-in plugin, JetBrains │
│ │
│ SUBLIME TEXT │
│ Community plug-in, inline templates │
│ │
│ NEOVIM │
│ coc-angular, community │
│ │
└──────────────────────────────────────────────┘
Summary
| Item | Value |
|---|---|
| Language Service | Editor intelligence for Angular templates |
| Features | Completion, diagnostics, quick info, go-to-definition |
| Configuration | strictTemplates in tsconfig.json |
| Editors | VS Code, WebStorm, Sublime, Eclipse, Neovim |
| Architecture | Ivy compiler, Type Check Blocks, LSP |
| VS Code | Official extension, Angular team |
| WebStorm | Built-in plugin |
| Strict templates | Enables stronger diagnostics |
Key takeaways:
- The Angular Language Service provides editor intelligence for templates. It gives completions, errors, hints, and navigation inside Angular templates, whether they are inline in
.tsfiles or external in.htmlfiles . - The
strictTemplatesoption enables the strongest diagnostics. Without it, the service provides completions but weaker error checking. With it, the service enforces input types, null checks, DOM event types, and output event types . - The service is available for multiple editors. VS Code has the official extension maintained by the Angular team. WebStorm has the plugin built in. Sublime Text, Eclipse, and Neovim have community support .
- The service uses the Ivy compiler and Type Check Blocks. The compiler generates TypeScript code for each template. TypeScript checks the generated code. The errors in the generated code are the errors in the template .
- The service is a language server. It runs as a separate process from the editor. The editor communicates with it through the Language Server Protocol or a custom protocol. The separation allows the service to be updated independently .
- The service supports AOT diagnostics. The errors the service reports are the same errors the Ahead-of-Time compiler reports during the build. The editor becomes a fast preview of the build .
- The setup is a one-time configuration. Install the extension, enable
strictTemplates, and the editor provides the intelligence. The service reads the project’stsconfig.jsonand analyzes the templates automatically .
Remember: The Angular Language Service is the tool that makes templates first-class in the editor. It provides completions, diagnostics, quick info, and navigation. It reads the project’s tsconfig.json and uses the Ivy compiler to analyze the templates. The strictTemplates option enables the strongest diagnostics. The service is available for VS Code, WebStorm, Sublime Text, Eclipse, and Neovim. Install the extension, enable the option, and the editor provides the intelligence.
Stop using slow, ad-bloated tool sites! 🤮
🔎 Search “KandZ Tools” on Google to use many professional utilities for free.
KandZ.me is the ultimate minimalist hub for:
✅ Finance (Mortgage, Interest, Inflation)
✅ Tech (Base64, JSON, Dev Suite, IP)
✅ Health (BMI, BMR, TDEE)
✅ Productivity (Timer, Workspace, QR)
⚡️ Fast & Private
🔒 No data leaves your device
💎 100% Free
🔗 Use it now: https://tools.kandz.me
🔖 Bookmark it—you’ll need it later!