-
Notifications
You must be signed in to change notification settings - Fork 123
Design
This document outlines the goals and implementation of the Angular language service (LS).
- User: Provide useful editor features to Angular users for a better developer experience
- Performance: Fast and efficient real-time editing capabilities
- Compatibility: Primarily with VSCode, but must support other editors
- Client
- Server
The client is a VSCode-specific extension that runs in the VSCode extension host. When activated, the client would spawn a server process and synchronizes documents with the server as they are opened and edited by user.
The server is a proper implementation of the Language Service Protocol (LSP).
It is a standalone module, and could be deployed independently of the client.
The server is very similar to tsserver
in functionality, except for the way it handles non-TS files.
In essence, the server is a "bridge" between tsserver
and LSP, but it only answers queries relevant to Angular.
- Efficiency (TypeScript parsing)
- No version skew for both TypeScript and Angular
- Support for external template
Angular LS inherently works hand-in-hand with TypeScript compiler due to the nature of the code. Angular compiler is effectively an extension of the TypeScript compiler.
Ideally, it is desirable that TypeScript code not be parsed twice, once by the native TypeScript extension,
and again by the Angular LS. However, this forces the Angular LS to be a strict tsserver
plugin, and such move causes multiple drawbacks.
- Support for external files in
tsserver
is not feature complete.
There has been much discussion around this, but many edge cases must be taken into account before it could be implemented. - Compatibility with editors other than VSCode.
In order fortsserver
to support non-TS files, there ought to be client side changes, but these changes are different for each editor.
For the reasons above, the Angular LS remains an implementation of Language Service Protocol (LSP).
This does not mean that tsserver
plugin is abandoned completely. Angular LS aims to be fully compatible with tsserver
, sans support for external template. This does not preclude the plugin from supporting external templates in the future. If such capability is baked into tsserver
one day, Angular LS is in a good position to adopt the change quickly. Internally, the new Angular LS loads @angular/language-service
as a tsserver
plugin.
It is very important to establish the right nomenclatures for discussion purposes.
- Extension
A VSCode extension that users install via the editor. - Plugin
Atsserver
plugin that augments the behavior of TypeScript LS. - ProjectService
A singleton instance that handles multiple projects insidetsserver
. - Project
A "server" concept of a collection of files that belong to the sametsconfig
. The collection could be any files, not necessarily TS only. - ScriptInfo
A "server" concept of a document, i.e. a file. This is language agnostic. - SourceFile
Specifically refers to a TypeScript file, and contains the AST for the source. - Program
A "compiler" concept of a collection of TS files, along with its transitive dependencies.