UNPKG

2.71 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/ivy/display_parts" />
9import { DirectiveInScope, ReferenceSymbol, VariableSymbol } from '@angular/compiler-cli/src/ngtsc/typecheck/api';
10import * as ts from 'typescript';
11export declare const ALIAS_NAME: string;
12export declare const SYMBOL_INTERFACE: string;
13export declare const SYMBOL_PUNC: string;
14export declare const SYMBOL_SPACE: string;
15export declare const SYMBOL_TEXT: string;
16/**
17 * Label for various kinds of Angular entities for TS display info.
18 */
19export declare enum DisplayInfoKind {
20 ATTRIBUTE = "attribute",
21 COMPONENT = "component",
22 DIRECTIVE = "directive",
23 EVENT = "event",
24 REFERENCE = "reference",
25 ELEMENT = "element",
26 VARIABLE = "variable",
27 PIPE = "pipe",
28 PROPERTY = "property",
29 METHOD = "method",
30 TEMPLATE = "template"
31}
32export interface DisplayInfo {
33 kind: DisplayInfoKind;
34 displayParts: ts.SymbolDisplayPart[];
35 documentation: ts.SymbolDisplayPart[] | undefined;
36}
37export declare function getSymbolDisplayInfo(tsLS: ts.LanguageService, typeChecker: ts.TypeChecker, symbol: ReferenceSymbol | VariableSymbol): DisplayInfo;
38/**
39 * Construct a compound `ts.SymbolDisplayPart[]` which incorporates the container and type of a
40 * target declaration.
41 * @param name Name of the target
42 * @param kind component, directive, pipe, etc.
43 * @param containerName either the Symbol's container or the NgModule that contains the directive
44 * @param type user-friendly name of the type
45 * @param documentation docstring or comment
46 */
47export declare function createDisplayParts(name: string, kind: DisplayInfoKind, containerName: string | undefined, type: string | undefined): ts.SymbolDisplayPart[];
48/**
49 * Convert a `SymbolDisplayInfoKind` to a `ts.ScriptElementKind` type, allowing it to pass through
50 * TypeScript APIs.
51 *
52 * In practice, this is an "illegal" type cast. Since `ts.ScriptElementKind` is a string, this is
53 * safe to do if TypeScript only uses the value in a string context. Consumers of this conversion
54 * function are responsible for ensuring this is the case.
55 */
56export declare function unsafeCastDisplayInfoKindToScriptElementKind(kind: DisplayInfoKind): ts.ScriptElementKind;
57export declare function getDirectiveDisplayInfo(tsLS: ts.LanguageService, dir: DirectiveInScope): DisplayInfo;
58export declare function getTsSymbolDisplayInfo(tsLS: ts.LanguageService, checker: ts.TypeChecker, symbol: ts.Symbol, kind: DisplayInfoKind, ownerName: string | null): DisplayInfo | null;