UNPKG

2.54 kBTypeScriptView Raw
1/**
2 * @license
3 * Copyright Google LLC All Rights Reserved.
4 *
5 * Use of this source code is governed by an MIT-style license that can be
6 * found in the LICENSE file at https://angular.io/license
7 */
8/**
9 * @module
10 * @description
11 * Entry point for all public APIs of the language service package.
12 */
13import ts from 'typescript';
14export interface PluginConfig {
15 /**
16 * If true, return only Angular results. Otherwise, return Angular + TypeScript
17 * results.
18 */
19 angularOnly: boolean;
20 /**
21 * If true, enable `strictTemplates` in Angular compiler options regardless
22 * of its value in tsconfig.json.
23 */
24 forceStrictTemplates?: true;
25 /**
26 * If false, disables parsing control flow blocks in the compiler. Should be used only when older
27 * versions of Angular that do not support blocks (pre-v17) used with the language service.
28 */
29 enableBlockSyntax?: false;
30 /**
31 * Version of `@angular/core` that was detected in the user's workspace.
32 */
33 angularCoreVersion?: string;
34}
35export type GetTcbResponse = {
36 /**
37 * The filename of the SourceFile this typecheck block belongs to.
38 * The filename is entirely opaque and unstable, useful only for debugging
39 * purposes.
40 */
41 fileName: string;
42 /** The content of the SourceFile this typecheck block belongs to. */
43 content: string;
44 /**
45 * Spans over node(s) in the typecheck block corresponding to the
46 * TS code generated for template node under the current cursor position.
47 *
48 * When the cursor position is over a source for which there is no generated
49 * code, `selections` is empty.
50 */
51 selections: ts.TextSpan[];
52};
53export type GetComponentLocationsForTemplateResponse = ts.DocumentSpan[];
54export type GetTemplateLocationForComponentResponse = ts.DocumentSpan | undefined;
55/**
56 * `NgLanguageService` describes an instance of an Angular language service,
57 * whose API surface is a strict superset of TypeScript's language service.
58 */
59export interface NgLanguageService extends ts.LanguageService {
60 getTcb(fileName: string, position: number): GetTcbResponse | undefined;
61 getComponentLocationsForTemplate(fileName: string): GetComponentLocationsForTemplateResponse;
62 getTemplateLocationForComponent(fileName: string, position: number): GetTemplateLocationForComponentResponse;
63 getTypescriptLanguageService(): ts.LanguageService;
64}
65export declare function isNgLanguageService(ls: ts.LanguageService | NgLanguageService): ls is NgLanguageService;