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/compiler-cli/src/ngtsc/typecheck/extended/api/api" />
|
---|
9 | import { AST, TmplAstNode } from '@angular/compiler';
|
---|
10 | import * as ts from 'typescript';
|
---|
11 | import { ErrorCode } from '../../../diagnostics';
|
---|
12 | import { NgTemplateDiagnostic, TemplateTypeChecker } from '../../api';
|
---|
13 | /**
|
---|
14 | * A Template Check receives information about the template it's checking and returns
|
---|
15 | * information about the diagnostics to be generated.
|
---|
16 | */
|
---|
17 | export interface TemplateCheck<T extends ErrorCode> {
|
---|
18 | /** Unique template check code, used for configuration and searching the error. */
|
---|
19 | code: T;
|
---|
20 | /** Runs check and returns information about the diagnostics to be generated. */
|
---|
21 | run(ctx: TemplateContext, component: ts.ClassDeclaration, template: TmplAstNode[]): NgTemplateDiagnostic<T>[];
|
---|
22 | }
|
---|
23 | /**
|
---|
24 | * The TemplateContext provided to a Template Check to get diagnostic information.
|
---|
25 | */
|
---|
26 | export interface TemplateContext {
|
---|
27 | /** Interface that provides information about template nodes. */
|
---|
28 | templateTypeChecker: TemplateTypeChecker;
|
---|
29 | /**
|
---|
30 | * TypeScript interface that provides type information about symbols that appear
|
---|
31 | * in the template (it is not to query types outside the Angular component).
|
---|
32 | */
|
---|
33 | typeChecker: ts.TypeChecker;
|
---|
34 | }
|
---|
35 | /**
|
---|
36 | * This abstract class provides a base implementation for the run method.
|
---|
37 | */
|
---|
38 | export declare abstract class TemplateCheckWithVisitor<T extends ErrorCode> implements TemplateCheck<T> {
|
---|
39 | abstract code: T;
|
---|
40 | /**
|
---|
41 | * Base implementation for run function, visits all nodes in template and calls
|
---|
42 | * `visitNode()` for each one.
|
---|
43 | */
|
---|
44 | run(ctx: TemplateContext, component: ts.ClassDeclaration, template: TmplAstNode[]): NgTemplateDiagnostic<T>[];
|
---|
45 | /**
|
---|
46 | * Visit a TmplAstNode or AST node of the template. Authors should override this
|
---|
47 | * method to implement the check and return diagnostics.
|
---|
48 | */
|
---|
49 | abstract visitNode(ctx: TemplateContext, component: ts.ClassDeclaration, node: TmplAstNode | AST): NgTemplateDiagnostic<T>[];
|
---|
50 | }
|
---|