UNPKG

2.2 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/// <amd-module name="@angular/language-service/api" />
9/**
10 * @module
11 * @description
12 * Entry point for all public APIs of the language service package.
13 */
14import ts from 'typescript';
15export interface PluginConfig {
16 /**
17 * If true, return only Angular results. Otherwise, return Angular + TypeScript
18 * results.
19 */
20 angularOnly: boolean;
21 /**
22 * If true, enable `strictTemplates` in Angular compiler options regardless
23 * of its value in tsconfig.json.
24 */
25 forceStrictTemplates?: true;
26}
27export declare type GetTcbResponse = {
28 /**
29 * The filename of the SourceFile this typecheck block belongs to.
30 * The filename is entirely opaque and unstable, useful only for debugging
31 * purposes.
32 */
33 fileName: string;
34 /** The content of the SourceFile this typecheck block belongs to. */
35 content: string;
36 /**
37 * Spans over node(s) in the typecheck block corresponding to the
38 * TS code generated for template node under the current cursor position.
39 *
40 * When the cursor position is over a source for which there is no generated
41 * code, `selections` is empty.
42 */
43 selections: ts.TextSpan[];
44};
45export declare type GetComponentLocationsForTemplateResponse = ts.DocumentSpan[];
46export declare type GetTemplateLocationForComponentResponse = ts.DocumentSpan | undefined;
47/**
48 * `NgLanguageService` describes an instance of an Angular language service,
49 * whose API surface is a strict superset of TypeScript's language service.
50 */
51export interface NgLanguageService extends ts.LanguageService {
52 getTcb(fileName: string, position: number): GetTcbResponse | undefined;
53 getComponentLocationsForTemplate(fileName: string): GetComponentLocationsForTemplateResponse;
54 getTemplateLocationForComponent(fileName: string, position: number): GetTemplateLocationForComponentResponse;
55}
56export declare function isNgLanguageService(ls: ts.LanguageService | NgLanguageService): ls is NgLanguageService;