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/core/schematics/migrations/undecorated-classes-with-di/transform" />
|
---|
9 | import { AotCompiler } from '@angular/compiler';
|
---|
10 | import { PartialEvaluator } from '@angular/compiler-cli/src/ngtsc/partial_evaluator';
|
---|
11 | import * as ts from 'typescript';
|
---|
12 | import { UpdateRecorder } from './update_recorder';
|
---|
13 | export interface TransformFailure {
|
---|
14 | node: ts.Node;
|
---|
15 | message: string;
|
---|
16 | }
|
---|
17 | export declare class UndecoratedClassesTransform {
|
---|
18 | private typeChecker;
|
---|
19 | private compiler;
|
---|
20 | private evaluator;
|
---|
21 | private getUpdateRecorder;
|
---|
22 | private printer;
|
---|
23 | private importManager;
|
---|
24 | private decoratorRewriter;
|
---|
25 | private compilerHost;
|
---|
26 | private symbolResolver;
|
---|
27 | private metadataResolver;
|
---|
28 | /** Set of class declarations which have been decorated with "@Directive". */
|
---|
29 | private decoratedDirectives;
|
---|
30 | /** Set of class declarations which have been decorated with "@Injectable" */
|
---|
31 | private decoratedProviders;
|
---|
32 | /**
|
---|
33 | * Set of class declarations which have been analyzed and need to specify
|
---|
34 | * an explicit constructor.
|
---|
35 | */
|
---|
36 | private missingExplicitConstructorClasses;
|
---|
37 | constructor(typeChecker: ts.TypeChecker, compiler: AotCompiler, evaluator: PartialEvaluator, getUpdateRecorder: (sf: ts.SourceFile) => UpdateRecorder);
|
---|
38 | /**
|
---|
39 | * Migrates decorated directives which can potentially inherit a constructor
|
---|
40 | * from an undecorated base class. All base classes until the first one
|
---|
41 | * with an explicit constructor will be decorated with the abstract "@Directive()"
|
---|
42 | * decorator. See case 1 in the migration plan: https://hackmd.io/@alx/S1XKqMZeS
|
---|
43 | */
|
---|
44 | migrateDecoratedDirectives(directives: ts.ClassDeclaration[]): TransformFailure[];
|
---|
45 | /**
|
---|
46 | * Migrates decorated providers which can potentially inherit a constructor
|
---|
47 | * from an undecorated base class. All base classes until the first one
|
---|
48 | * with an explicit constructor will be decorated with the "@Injectable()".
|
---|
49 | */
|
---|
50 | migrateDecoratedProviders(providers: ts.ClassDeclaration[]): TransformFailure[];
|
---|
51 | private _migrateProviderBaseClass;
|
---|
52 | private _migrateDirectiveBaseClass;
|
---|
53 | private _migrateDecoratedClassWithInheritedCtor;
|
---|
54 | /**
|
---|
55 | * Adds the abstract "@Directive()" decorator to the given class in case there
|
---|
56 | * is no existing directive decorator.
|
---|
57 | */
|
---|
58 | private _addAbstractDirectiveDecorator;
|
---|
59 | /**
|
---|
60 | * Adds the abstract "@Injectable()" decorator to the given class in case there
|
---|
61 | * is no existing directive decorator.
|
---|
62 | */
|
---|
63 | private _addInjectableDecorator;
|
---|
64 | /** Adds a comment for adding an explicit constructor to the given class declaration. */
|
---|
65 | private _addMissingExplicitConstructorTodo;
|
---|
66 | /**
|
---|
67 | * Migrates undecorated directives which were referenced in NgModule declarations.
|
---|
68 | * These directives inherit the metadata from a parent base class, but with Ivy
|
---|
69 | * these classes need to explicitly have a decorator for locality. The migration
|
---|
70 | * determines the inherited decorator and copies it to the undecorated declaration.
|
---|
71 | *
|
---|
72 | * Note that the migration serializes the metadata for external declarations
|
---|
73 | * where the decorator is not part of the source file AST.
|
---|
74 | *
|
---|
75 | * See case 2 in the migration plan: https://hackmd.io/@alx/S1XKqMZeS
|
---|
76 | */
|
---|
77 | migrateUndecoratedDeclarations(directives: ts.ClassDeclaration[]): TransformFailure[];
|
---|
78 | private _migrateDerivedDeclaration;
|
---|
79 | /** Records all changes that were made in the import manager. */
|
---|
80 | recordChanges(): void;
|
---|
81 | /**
|
---|
82 | * Constructs a TypeScript decorator node from the specified declaration metadata. Returns
|
---|
83 | * null if the metadata could not be simplified/resolved.
|
---|
84 | */
|
---|
85 | private _constructDecoratorFromMetadata;
|
---|
86 | /**
|
---|
87 | * Resolves the declaration metadata of a given static symbol. The metadata
|
---|
88 | * is determined by resolving metadata for the static symbol.
|
---|
89 | */
|
---|
90 | private _resolveDeclarationMetadata;
|
---|
91 | private _getStaticSymbolOfIdentifier;
|
---|
92 | /**
|
---|
93 | * Disables that static symbols are resolved through summaries. Summaries
|
---|
94 | * cannot be used for decorator analysis as decorators are omitted in summaries.
|
---|
95 | */
|
---|
96 | private _disableSummaryResolution;
|
---|
97 | }
|
---|