@angular/compiler-cli 15.2.0 → 16.0.0-next.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bundles/{chunk-PKSKJEUS.js → chunk-2DMH5JXJ.js} +9 -18
- package/bundles/{chunk-PKSKJEUS.js.map → chunk-2DMH5JXJ.js.map} +1 -1
- package/bundles/{chunk-P6SWFK2U.js → chunk-4TCRZYAK.js} +2 -2
- package/bundles/{chunk-NJMZRTB6.js → chunk-54RHUHYB.js} +1 -2
- package/bundles/{chunk-2PLRZDNU.js → chunk-6CARGXRJ.js} +5 -5
- package/bundles/{chunk-O4JLZZWJ.js → chunk-EDWIBG7R.js} +1 -10
- package/bundles/chunk-EDWIBG7R.js.map +6 -0
- package/bundles/{chunk-6ZJFIQBG.js → chunk-GYHDNUIK.js} +1 -2
- package/bundles/{chunk-2OF2AI57.js → chunk-IS6KZYEA.js} +377 -609
- package/bundles/chunk-IS6KZYEA.js.map +6 -0
- package/bundles/{chunk-J3L7WZP3.js → chunk-JHMH3CX2.js} +3 -3
- package/bundles/{chunk-ZCBRXUPO.js → chunk-K2A5WD7L.js} +1 -6
- package/bundles/chunk-K2A5WD7L.js.map +6 -0
- package/bundles/{chunk-QRHWLC7U.js → chunk-PSGRCFPQ.js} +2 -2
- package/bundles/index.js +13 -13
- package/bundles/linker/babel/index.js +8 -8
- package/bundles/linker/index.js +4 -4
- package/bundles/private/bazel.js +1 -1
- package/bundles/private/localize.js +1 -1
- package/bundles/private/migrations.js +5 -5
- package/bundles/private/tooling.js +3 -3
- package/bundles/src/bin/ng_xi18n.js +7 -7
- package/bundles/src/bin/ngc.js +7 -7
- package/bundles_metadata.json +1 -1
- package/package.json +2 -15
- package/src/ngtsc/annotations/ng_module/src/handler.d.ts +1 -3
- package/src/ngtsc/core/api/src/adapter.d.ts +0 -7
- package/src/ngtsc/core/api/src/options.d.ts +2 -2
- package/src/ngtsc/core/api/src/public_options.d.ts +0 -25
- package/src/ngtsc/core/src/host.d.ts +3 -5
- package/src/ngtsc/shims/api.d.ts +0 -19
- package/src/ngtsc/shims/index.d.ts +0 -2
- package/src/transformers/api.d.ts +0 -5
- package/bundles/chunk-2OF2AI57.js.map +0 -6
- package/bundles/chunk-7DUI3BSX.js +0 -29
- package/bundles/chunk-7DUI3BSX.js.map +0 -6
- package/bundles/chunk-MLCT4AWL.js +0 -2187
- package/bundles/chunk-MLCT4AWL.js.map +0 -6
- package/bundles/chunk-NXCQCU6C.js +0 -5265
- package/bundles/chunk-NXCQCU6C.js.map +0 -6
- package/bundles/chunk-O4JLZZWJ.js.map +0 -6
- package/bundles/chunk-YRDMG3GM.js +0 -115
- package/bundles/chunk-YRDMG3GM.js.map +0 -6
- package/bundles/chunk-ZCBRXUPO.js.map +0 -6
- package/bundles/ngcc/index.js +0 -52
- package/bundles/ngcc/index.js.map +0 -6
- package/bundles/ngcc/main-ngcc.js +0 -49
- package/bundles/ngcc/main-ngcc.js.map +0 -6
- package/bundles/ngcc/src/execution/cluster/ngcc_cluster_worker.js +0 -114
- package/bundles/ngcc/src/execution/cluster/ngcc_cluster_worker.js.map +0 -6
- package/bundles/ngcc/src/locking/lock_file_with_child_process/ngcc_lock_unlocker.js +0 -34
- package/bundles/ngcc/src/locking/lock_file_with_child_process/ngcc_lock_unlocker.js.map +0 -6
- package/ngcc/index.d.ts +0 -19
- package/ngcc/main-ngcc.d.ts +0 -2
- package/ngcc/src/analysis/decoration_analyzer.d.ts +0 -80
- package/ngcc/src/analysis/migration_host.d.ts +0 -22
- package/ngcc/src/analysis/module_with_providers_analyzer.d.ts +0 -61
- package/ngcc/src/analysis/ngcc_references_registry.d.ts +0 -34
- package/ngcc/src/analysis/ngcc_trait_compiler.d.ts +0 -42
- package/ngcc/src/analysis/private_declarations_analyzer.d.ts +0 -29
- package/ngcc/src/analysis/types.d.ts +0 -29
- package/ngcc/src/analysis/util.d.ts +0 -11
- package/ngcc/src/command_line_options.d.ts +0 -3
- package/ngcc/src/constants.d.ts +0 -9
- package/ngcc/src/dependencies/commonjs_dependency_host.d.ts +0 -20
- package/ngcc/src/dependencies/dependency_host.d.ts +0 -77
- package/ngcc/src/dependencies/dependency_resolver.d.ts +0 -102
- package/ngcc/src/dependencies/dts_dependency_host.d.ts +0 -20
- package/ngcc/src/dependencies/esm_dependency_host.d.ts +0 -93
- package/ngcc/src/dependencies/module_resolver.d.ts +0 -134
- package/ngcc/src/dependencies/umd_dependency_host.d.ts +0 -9
- package/ngcc/src/entry_point_finder/directory_walker_entry_point_finder.d.ts +0 -41
- package/ngcc/src/entry_point_finder/entry_point_collector.d.ts +0 -41
- package/ngcc/src/entry_point_finder/interface.d.ts +0 -14
- package/ngcc/src/entry_point_finder/program_based_entry_point_finder.d.ts +0 -61
- package/ngcc/src/entry_point_finder/targeted_entry_point_finder.d.ts +0 -95
- package/ngcc/src/entry_point_finder/tracing_entry_point_finder.d.ts +0 -67
- package/ngcc/src/entry_point_finder/utils.d.ts +0 -38
- package/ngcc/src/execution/analyze_entry_points.d.ts +0 -9
- package/ngcc/src/execution/api.d.ts +0 -27
- package/ngcc/src/execution/cluster/api.d.ts +0 -51
- package/ngcc/src/execution/cluster/executor.d.ts +0 -29
- package/ngcc/src/execution/cluster/master.d.ts +0 -57
- package/ngcc/src/execution/cluster/ngcc_cluster_worker.d.ts +0 -8
- package/ngcc/src/execution/cluster/package_json_updater.d.ts +0 -22
- package/ngcc/src/execution/cluster/utils.d.ts +0 -44
- package/ngcc/src/execution/cluster/worker.d.ts +0 -10
- package/ngcc/src/execution/create_compile_function.d.ts +0 -10
- package/ngcc/src/execution/single_process_executor.d.ts +0 -34
- package/ngcc/src/execution/tasks/api.d.ts +0 -141
- package/ngcc/src/execution/tasks/completion.d.ts +0 -41
- package/ngcc/src/execution/tasks/queues/base_task_queue.d.ts +0 -38
- package/ngcc/src/execution/tasks/queues/parallel_task_queue.d.ts +0 -27
- package/ngcc/src/execution/tasks/queues/serial_task_queue.d.ts +0 -16
- package/ngcc/src/execution/tasks/utils.d.ts +0 -57
- package/ngcc/src/host/commonjs_host.d.ts +0 -69
- package/ngcc/src/host/commonjs_umd_utils.d.ts +0 -146
- package/ngcc/src/host/delegating_host.d.ts +0 -43
- package/ngcc/src/host/esm2015_host.d.ts +0 -935
- package/ngcc/src/host/esm5_host.d.ts +0 -299
- package/ngcc/src/host/ngcc_host.d.ts +0 -87
- package/ngcc/src/host/umd_host.d.ts +0 -85
- package/ngcc/src/host/utils.d.ts +0 -9
- package/ngcc/src/locking/async_locker.d.ts +0 -34
- package/ngcc/src/locking/lock_file.d.ts +0 -31
- package/ngcc/src/locking/lock_file_with_child_process/index.d.ts +0 -44
- package/ngcc/src/locking/lock_file_with_child_process/ngcc_lock_unlocker.d.ts +0 -1
- package/ngcc/src/locking/lock_file_with_child_process/util.d.ts +0 -16
- package/ngcc/src/locking/sync_locker.d.ts +0 -35
- package/ngcc/src/main.d.ts +0 -17
- package/ngcc/src/migrations/migration.d.ts +0 -59
- package/ngcc/src/migrations/missing_injectable_migration.d.ts +0 -35
- package/ngcc/src/migrations/undecorated_child_migration.d.ts +0 -15
- package/ngcc/src/migrations/undecorated_parent_migration.d.ts +0 -51
- package/ngcc/src/migrations/utils.d.ts +0 -41
- package/ngcc/src/ngcc_options.d.ts +0 -155
- package/ngcc/src/packages/adjust_cjs_umd_exports.d.ts +0 -16
- package/ngcc/src/packages/build_marker.d.ts +0 -44
- package/ngcc/src/packages/bundle_program.d.ts +0 -35
- package/ngcc/src/packages/configuration.d.ts +0 -222
- package/ngcc/src/packages/entry_point.d.ts +0 -109
- package/ngcc/src/packages/entry_point_bundle.d.ts +0 -46
- package/ngcc/src/packages/entry_point_manifest.d.ts +0 -79
- package/ngcc/src/packages/ngcc_compiler_host.d.ts +0 -36
- package/ngcc/src/packages/patch_ts_expando_initializer.d.ts +0 -41
- package/ngcc/src/packages/source_file_cache.d.ts +0 -97
- package/ngcc/src/packages/transformer.d.ts +0 -70
- package/ngcc/src/path_mappings.d.ts +0 -19
- package/ngcc/src/rendering/commonjs_rendering_formatter.d.ts +0 -34
- package/ngcc/src/rendering/dts_renderer.d.ts +0 -51
- package/ngcc/src/rendering/esm5_rendering_formatter.d.ts +0 -35
- package/ngcc/src/rendering/esm_rendering_formatter.d.ts +0 -84
- package/ngcc/src/rendering/ngcc_import_rewriter.d.ts +0 -13
- package/ngcc/src/rendering/renderer.d.ts +0 -72
- package/ngcc/src/rendering/rendering_formatter.d.ts +0 -37
- package/ngcc/src/rendering/source_maps.d.ts +0 -23
- package/ngcc/src/rendering/umd_rendering_formatter.d.ts +0 -54
- package/ngcc/src/rendering/utils.d.ts +0 -24
- package/ngcc/src/utils.d.ts +0 -112
- package/ngcc/src/writing/cleaning/cleaning_strategies.d.ts +0 -44
- package/ngcc/src/writing/cleaning/package_cleaner.d.ts +0 -38
- package/ngcc/src/writing/cleaning/utils.d.ts +0 -15
- package/ngcc/src/writing/file_writer.d.ts +0 -28
- package/ngcc/src/writing/in_place_file_writer.d.ts +0 -28
- package/ngcc/src/writing/new_entry_point_file_writer.d.ts +0 -48
- package/ngcc/src/writing/package_json_updater.d.ts +0 -98
- package/src/ngtsc/shims/src/factory_generator.d.ts +0 -24
- package/src/ngtsc/shims/src/summary_generator.d.ts +0 -15
- /package/bundles/{chunk-P6SWFK2U.js.map → chunk-4TCRZYAK.js.map} +0 -0
- /package/bundles/{chunk-NJMZRTB6.js.map → chunk-54RHUHYB.js.map} +0 -0
- /package/bundles/{chunk-2PLRZDNU.js.map → chunk-6CARGXRJ.js.map} +0 -0
- /package/bundles/{chunk-6ZJFIQBG.js.map → chunk-GYHDNUIK.js.map} +0 -0
- /package/bundles/{chunk-J3L7WZP3.js.map → chunk-JHMH3CX2.js.map} +0 -0
- /package/bundles/{chunk-QRHWLC7U.js.map → chunk-PSGRCFPQ.js.map} +0 -0
|
@@ -1,935 +0,0 @@
|
|
|
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
|
-
import ts from 'typescript';
|
|
9
|
-
import { Logger } from '../../../src/ngtsc/logging';
|
|
10
|
-
import { ClassDeclaration, ClassMember, ClassMemberKind, CtorParameter, Declaration, DeclarationNode, Decorator, EnumMember, TypeScriptReflectionHost } from '../../../src/ngtsc/reflection';
|
|
11
|
-
import { BundleProgram } from '../packages/bundle_program';
|
|
12
|
-
import { NgccClassSymbol, NgccReflectionHost } from './ngcc_host';
|
|
13
|
-
export declare const DECORATORS: ts.__String;
|
|
14
|
-
export declare const PROP_DECORATORS: ts.__String;
|
|
15
|
-
export declare const CONSTRUCTOR: ts.__String;
|
|
16
|
-
export declare const CONSTRUCTOR_PARAMS: ts.__String;
|
|
17
|
-
/**
|
|
18
|
-
* Esm2015 packages contain ECMAScript 2015 classes, etc.
|
|
19
|
-
* Decorators are defined via static properties on the class. For example:
|
|
20
|
-
*
|
|
21
|
-
* ```
|
|
22
|
-
* class SomeDirective {
|
|
23
|
-
* }
|
|
24
|
-
* SomeDirective.decorators = [
|
|
25
|
-
* { type: Directive, args: [{ selector: '[someDirective]' },] }
|
|
26
|
-
* ];
|
|
27
|
-
* SomeDirective.ctorParameters = () => [
|
|
28
|
-
* { type: ViewContainerRef, },
|
|
29
|
-
* { type: TemplateRef, },
|
|
30
|
-
* { type: undefined, decorators: [{ type: Inject, args: [INJECTED_TOKEN,] },] },
|
|
31
|
-
* ];
|
|
32
|
-
* SomeDirective.propDecorators = {
|
|
33
|
-
* "input1": [{ type: Input },],
|
|
34
|
-
* "input2": [{ type: Input },],
|
|
35
|
-
* };
|
|
36
|
-
* ```
|
|
37
|
-
*
|
|
38
|
-
* * Classes are decorated if they have a static property called `decorators`.
|
|
39
|
-
* * Members are decorated if there is a matching key on a static property
|
|
40
|
-
* called `propDecorators`.
|
|
41
|
-
* * Constructor parameters decorators are found on an object returned from
|
|
42
|
-
* a static method called `ctorParameters`.
|
|
43
|
-
*/
|
|
44
|
-
export declare class Esm2015ReflectionHost extends TypeScriptReflectionHost implements NgccReflectionHost {
|
|
45
|
-
protected logger: Logger;
|
|
46
|
-
protected isCore: boolean;
|
|
47
|
-
protected src: BundleProgram;
|
|
48
|
-
protected dts: BundleProgram | null;
|
|
49
|
-
/**
|
|
50
|
-
* A mapping from source declarations to typings declarations, which are both publicly exported.
|
|
51
|
-
*
|
|
52
|
-
* There should be one entry for every public export visible from the root file of the source
|
|
53
|
-
* tree. Note that by definition the key and value declarations will not be in the same TS
|
|
54
|
-
* program.
|
|
55
|
-
*/
|
|
56
|
-
protected publicDtsDeclarationMap: Map<DeclarationNode, ts.Declaration> | null;
|
|
57
|
-
/**
|
|
58
|
-
* A mapping from source declarations to typings declarations, which are not publicly exported.
|
|
59
|
-
*
|
|
60
|
-
* This mapping is a best guess between declarations that happen to be exported from their file by
|
|
61
|
-
* the same name in both the source and the dts file. Note that by definition the key and value
|
|
62
|
-
* declarations will not be in the same TS program.
|
|
63
|
-
*/
|
|
64
|
-
protected privateDtsDeclarationMap: Map<DeclarationNode, ts.Declaration> | null;
|
|
65
|
-
/**
|
|
66
|
-
* The set of source files that have already been preprocessed.
|
|
67
|
-
*/
|
|
68
|
-
protected preprocessedSourceFiles: Set<ts.SourceFile>;
|
|
69
|
-
/**
|
|
70
|
-
* In ES2015, class declarations may have been down-leveled into variable declarations,
|
|
71
|
-
* initialized using a class expression. In certain scenarios, an additional variable
|
|
72
|
-
* is introduced that represents the class so that results in code such as:
|
|
73
|
-
*
|
|
74
|
-
* ```
|
|
75
|
-
* let MyClass_1; let MyClass = MyClass_1 = class MyClass {};
|
|
76
|
-
* ```
|
|
77
|
-
*
|
|
78
|
-
* This map tracks those aliased variables to their original identifier, i.e. the key
|
|
79
|
-
* corresponds with the declaration of `MyClass_1` and its value becomes the `MyClass` identifier
|
|
80
|
-
* of the variable declaration.
|
|
81
|
-
*
|
|
82
|
-
* This map is populated during the preprocessing of each source file.
|
|
83
|
-
*/
|
|
84
|
-
protected aliasedClassDeclarations: Map<DeclarationNode, ts.Identifier>;
|
|
85
|
-
/**
|
|
86
|
-
* Caches the information of the decorators on a class, as the work involved with extracting
|
|
87
|
-
* decorators is complex and frequently used.
|
|
88
|
-
*
|
|
89
|
-
* This map is lazily populated during the first call to `acquireDecoratorInfo` for a given class.
|
|
90
|
-
*/
|
|
91
|
-
protected decoratorCache: Map<ClassDeclaration<DeclarationNode>, DecoratorInfo>;
|
|
92
|
-
constructor(logger: Logger, isCore: boolean, src: BundleProgram, dts?: BundleProgram | null);
|
|
93
|
-
/**
|
|
94
|
-
* Find a symbol for a node that we think is a class.
|
|
95
|
-
* Classes should have a `name` identifier, because they may need to be referenced in other parts
|
|
96
|
-
* of the program.
|
|
97
|
-
*
|
|
98
|
-
* In ES2015, a class may be declared using a variable declaration of the following structures:
|
|
99
|
-
*
|
|
100
|
-
* ```
|
|
101
|
-
* var MyClass = MyClass_1 = class MyClass {};
|
|
102
|
-
* ```
|
|
103
|
-
*
|
|
104
|
-
* or
|
|
105
|
-
*
|
|
106
|
-
* ```
|
|
107
|
-
* var MyClass = MyClass_1 = (() => { class MyClass {} ... return MyClass; })()
|
|
108
|
-
* ```
|
|
109
|
-
*
|
|
110
|
-
* Here, the intermediate `MyClass_1` assignment is optional. In the above example, the
|
|
111
|
-
* `class MyClass {}` node is returned as declaration of `MyClass`.
|
|
112
|
-
*
|
|
113
|
-
* @param declaration the declaration node whose symbol we are finding.
|
|
114
|
-
* @returns the symbol for the node or `undefined` if it is not a "class" or has no symbol.
|
|
115
|
-
*/
|
|
116
|
-
getClassSymbol(declaration: ts.Node): NgccClassSymbol | undefined;
|
|
117
|
-
/**
|
|
118
|
-
* Examine a declaration (for example, of a class or function) and return metadata about any
|
|
119
|
-
* decorators present on the declaration.
|
|
120
|
-
*
|
|
121
|
-
* @param declaration a TypeScript node representing the class or function over which to reflect.
|
|
122
|
-
* For example, if the intent is to reflect the decorators of a class and the source is in ES6
|
|
123
|
-
* format, this will be a `ts.ClassDeclaration` node. If the source is in ES5 format, this
|
|
124
|
-
* might be a `ts.VariableDeclaration` as classes in ES5 are represented as the result of an
|
|
125
|
-
* IIFE execution.
|
|
126
|
-
*
|
|
127
|
-
* @returns an array of `Decorator` metadata if decorators are present on the declaration, or
|
|
128
|
-
* `null` if either no decorators were present or if the declaration is not of a decoratable
|
|
129
|
-
* type.
|
|
130
|
-
*/
|
|
131
|
-
getDecoratorsOfDeclaration(declaration: DeclarationNode): Decorator[] | null;
|
|
132
|
-
/**
|
|
133
|
-
* Examine a declaration which should be of a class, and return metadata about the members of the
|
|
134
|
-
* class.
|
|
135
|
-
*
|
|
136
|
-
* @param clazz a `ClassDeclaration` representing the class over which to reflect.
|
|
137
|
-
*
|
|
138
|
-
* @returns an array of `ClassMember` metadata representing the members of the class.
|
|
139
|
-
*
|
|
140
|
-
* @throws if `declaration` does not resolve to a class declaration.
|
|
141
|
-
*/
|
|
142
|
-
getMembersOfClass(clazz: ClassDeclaration): ClassMember[];
|
|
143
|
-
/**
|
|
144
|
-
* Reflect over the constructor of a class and return metadata about its parameters.
|
|
145
|
-
*
|
|
146
|
-
* This method only looks at the constructor of a class directly and not at any inherited
|
|
147
|
-
* constructors.
|
|
148
|
-
*
|
|
149
|
-
* @param clazz a `ClassDeclaration` representing the class over which to reflect.
|
|
150
|
-
*
|
|
151
|
-
* @returns an array of `Parameter` metadata representing the parameters of the constructor, if
|
|
152
|
-
* a constructor exists. If the constructor exists and has 0 parameters, this array will be empty.
|
|
153
|
-
* If the class has no constructor, this method returns `null`.
|
|
154
|
-
*
|
|
155
|
-
* @throws if `declaration` does not resolve to a class declaration.
|
|
156
|
-
*/
|
|
157
|
-
getConstructorParameters(clazz: ClassDeclaration): CtorParameter[] | null;
|
|
158
|
-
getBaseClassExpression(clazz: ClassDeclaration): ts.Expression | null;
|
|
159
|
-
getInternalNameOfClass(clazz: ClassDeclaration): ts.Identifier;
|
|
160
|
-
getAdjacentNameOfClass(clazz: ClassDeclaration): ts.Identifier;
|
|
161
|
-
private getNameFromClassSymbolDeclaration;
|
|
162
|
-
/**
|
|
163
|
-
* Check whether the given node actually represents a class.
|
|
164
|
-
*/
|
|
165
|
-
isClass(node: ts.Node): node is ClassDeclaration;
|
|
166
|
-
/**
|
|
167
|
-
* Trace an identifier to its declaration, if possible.
|
|
168
|
-
*
|
|
169
|
-
* This method attempts to resolve the declaration of the given identifier, tracing back through
|
|
170
|
-
* imports and re-exports until the original declaration statement is found. A `Declaration`
|
|
171
|
-
* object is returned if the original declaration is found, or `null` is returned otherwise.
|
|
172
|
-
*
|
|
173
|
-
* In ES2015, we need to account for identifiers that refer to aliased class declarations such as
|
|
174
|
-
* `MyClass_1`. Since such declarations are only available within the module itself, we need to
|
|
175
|
-
* find the original class declaration, e.g. `MyClass`, that is associated with the aliased one.
|
|
176
|
-
*
|
|
177
|
-
* @param id a TypeScript `ts.Identifier` to trace back to a declaration.
|
|
178
|
-
*
|
|
179
|
-
* @returns metadata about the `Declaration` if the original declaration is found, or `null`
|
|
180
|
-
* otherwise.
|
|
181
|
-
*/
|
|
182
|
-
getDeclarationOfIdentifier(id: ts.Identifier): Declaration | null;
|
|
183
|
-
/**
|
|
184
|
-
* Gets all decorators of the given class symbol. Any decorator that have been synthetically
|
|
185
|
-
* injected by a migration will not be present in the returned collection.
|
|
186
|
-
*/
|
|
187
|
-
getDecoratorsOfSymbol(symbol: NgccClassSymbol): Decorator[] | null;
|
|
188
|
-
getVariableValue(declaration: ts.VariableDeclaration): ts.Expression | null;
|
|
189
|
-
/**
|
|
190
|
-
* Find all top-level class symbols in the given file.
|
|
191
|
-
* @param sourceFile The source file to search for classes.
|
|
192
|
-
* @returns An array of class symbols.
|
|
193
|
-
*/
|
|
194
|
-
findClassSymbols(sourceFile: ts.SourceFile): NgccClassSymbol[];
|
|
195
|
-
/**
|
|
196
|
-
* Get the number of generic type parameters of a given class.
|
|
197
|
-
*
|
|
198
|
-
* @param clazz a `ClassDeclaration` representing the class over which to reflect.
|
|
199
|
-
*
|
|
200
|
-
* @returns the number of type parameters of the class, if known, or `null` if the declaration
|
|
201
|
-
* is not a class or has an unknown number of type parameters.
|
|
202
|
-
*/
|
|
203
|
-
getGenericArityOfClass(clazz: ClassDeclaration): number | null;
|
|
204
|
-
/**
|
|
205
|
-
* Take an exported declaration of a class (maybe down-leveled to a variable) and look up the
|
|
206
|
-
* declaration of its type in a separate .d.ts tree.
|
|
207
|
-
*
|
|
208
|
-
* This function is allowed to return `null` if the current compilation unit does not have a
|
|
209
|
-
* separate .d.ts tree. When compiling TypeScript code this is always the case, since .d.ts files
|
|
210
|
-
* are produced only during the emit of such a compilation. When compiling .js code, however,
|
|
211
|
-
* there is frequently a parallel .d.ts tree which this method exposes.
|
|
212
|
-
*
|
|
213
|
-
* Note that the `ts.ClassDeclaration` returned from this function may not be from the same
|
|
214
|
-
* `ts.Program` as the input declaration.
|
|
215
|
-
*/
|
|
216
|
-
getDtsDeclaration(declaration: DeclarationNode): ts.Declaration | null;
|
|
217
|
-
getEndOfClass(classSymbol: NgccClassSymbol): ts.Node;
|
|
218
|
-
/**
|
|
219
|
-
* Check whether a `Declaration` corresponds with a known declaration, such as `Object`, and set
|
|
220
|
-
* its `known` property to the appropriate `KnownDeclaration`.
|
|
221
|
-
*
|
|
222
|
-
* @param decl The `Declaration` to check.
|
|
223
|
-
* @return The passed in `Declaration` (potentially enhanced with a `KnownDeclaration`).
|
|
224
|
-
*/
|
|
225
|
-
detectKnownDeclaration<T extends Declaration>(decl: T): T;
|
|
226
|
-
/**
|
|
227
|
-
* Extract all the "classes" from the `statement` and add them to the `classes` map.
|
|
228
|
-
*/
|
|
229
|
-
protected addClassSymbolsFromStatement(classes: Map<ts.Symbol, NgccClassSymbol>, statement: ts.Statement): void;
|
|
230
|
-
/**
|
|
231
|
-
* Compute the inner declaration node of a "class" from the given `declaration` node.
|
|
232
|
-
*
|
|
233
|
-
* @param declaration a node that is either an inner declaration or an alias of a class.
|
|
234
|
-
*/
|
|
235
|
-
protected getInnerDeclarationFromAliasOrInner(declaration: ts.Node): ts.Node;
|
|
236
|
-
/**
|
|
237
|
-
* A class may be declared as a top level class declaration:
|
|
238
|
-
*
|
|
239
|
-
* ```
|
|
240
|
-
* class OuterClass { ... }
|
|
241
|
-
* ```
|
|
242
|
-
*
|
|
243
|
-
* or in a variable declaration to a class expression:
|
|
244
|
-
*
|
|
245
|
-
* ```
|
|
246
|
-
* var OuterClass = ClassAlias = class InnerClass {};
|
|
247
|
-
* ```
|
|
248
|
-
*
|
|
249
|
-
* or in a variable declaration to an IIFE containing a class declaration
|
|
250
|
-
*
|
|
251
|
-
* ```
|
|
252
|
-
* var OuterClass = ClassAlias = (() => {
|
|
253
|
-
* class InnerClass {}
|
|
254
|
-
* ...
|
|
255
|
-
* return InnerClass;
|
|
256
|
-
* })()
|
|
257
|
-
* ```
|
|
258
|
-
*
|
|
259
|
-
* or in a variable declaration to an IIFE containing a function declaration
|
|
260
|
-
*
|
|
261
|
-
* ```
|
|
262
|
-
* var OuterClass = ClassAlias = (() => {
|
|
263
|
-
* function InnerClass() {}
|
|
264
|
-
* ...
|
|
265
|
-
* return InnerClass;
|
|
266
|
-
* })()
|
|
267
|
-
* ```
|
|
268
|
-
*
|
|
269
|
-
* This method returns an `NgccClassSymbol` when provided with one of these cases.
|
|
270
|
-
*
|
|
271
|
-
* @param declaration the declaration whose symbol we are finding.
|
|
272
|
-
* @returns the symbol for the class or `undefined` if `declaration` does not represent an outer
|
|
273
|
-
* declaration of a class.
|
|
274
|
-
*/
|
|
275
|
-
protected getClassSymbolFromOuterDeclaration(declaration: ts.Node): NgccClassSymbol | undefined;
|
|
276
|
-
/**
|
|
277
|
-
* In ES2015, a class may be declared using a variable declaration of the following structures:
|
|
278
|
-
*
|
|
279
|
-
* ```
|
|
280
|
-
* let MyClass = MyClass_1 = class MyClass {};
|
|
281
|
-
* ```
|
|
282
|
-
*
|
|
283
|
-
* or
|
|
284
|
-
*
|
|
285
|
-
* ```
|
|
286
|
-
* let MyClass = MyClass_1 = (() => { class MyClass {} ... return MyClass; })()
|
|
287
|
-
* ```
|
|
288
|
-
*
|
|
289
|
-
* or
|
|
290
|
-
*
|
|
291
|
-
* ```
|
|
292
|
-
* let MyClass = MyClass_1 = (() => { let MyClass = class MyClass {}; ... return MyClass; })()
|
|
293
|
-
* ```
|
|
294
|
-
*
|
|
295
|
-
* This method extracts the `NgccClassSymbol` for `MyClass` when provided with the
|
|
296
|
-
* `class MyClass {}` declaration node. When the `var MyClass` node or any other node is given,
|
|
297
|
-
* this method will return undefined instead.
|
|
298
|
-
*
|
|
299
|
-
* @param declaration the declaration whose symbol we are finding.
|
|
300
|
-
* @returns the symbol for the node or `undefined` if it does not represent an inner declaration
|
|
301
|
-
* of a class.
|
|
302
|
-
*/
|
|
303
|
-
protected getClassSymbolFromInnerDeclaration(declaration: ts.Node): NgccClassSymbol | undefined;
|
|
304
|
-
/**
|
|
305
|
-
* Creates an `NgccClassSymbol` from an outer and inner declaration. If a class only has an outer
|
|
306
|
-
* declaration, the "implementation" symbol of the created `NgccClassSymbol` will be set equal to
|
|
307
|
-
* the "declaration" symbol.
|
|
308
|
-
*
|
|
309
|
-
* @param outerDeclaration The outer declaration node of the class.
|
|
310
|
-
* @param innerDeclaration The inner declaration node of the class, or undefined if no inner
|
|
311
|
-
* declaration is present.
|
|
312
|
-
* @returns the `NgccClassSymbol` representing the class, or undefined if a `ts.Symbol` for any of
|
|
313
|
-
* the declarations could not be resolved.
|
|
314
|
-
*/
|
|
315
|
-
protected createClassSymbol(outerDeclaration: ts.Identifier, innerDeclaration: ts.Node | null): NgccClassSymbol | undefined;
|
|
316
|
-
private getAdjacentSymbol;
|
|
317
|
-
/**
|
|
318
|
-
* Resolve a `ts.Symbol` to its declaration and detect whether it corresponds with a known
|
|
319
|
-
* declaration.
|
|
320
|
-
*/
|
|
321
|
-
protected getDeclarationOfSymbol(symbol: ts.Symbol, originalId: ts.Identifier | null): Declaration | null;
|
|
322
|
-
/**
|
|
323
|
-
* Finds the identifier of the actual class declaration for a potentially aliased declaration of a
|
|
324
|
-
* class.
|
|
325
|
-
*
|
|
326
|
-
* If the given declaration is for an alias of a class, this function will determine an identifier
|
|
327
|
-
* to the original declaration that represents this class.
|
|
328
|
-
*
|
|
329
|
-
* @param declaration The declaration to resolve.
|
|
330
|
-
* @returns The original identifier that the given class declaration resolves to, or `undefined`
|
|
331
|
-
* if the declaration does not represent an aliased class.
|
|
332
|
-
*/
|
|
333
|
-
protected resolveAliasedClassIdentifier(declaration: DeclarationNode): ts.Identifier | null;
|
|
334
|
-
/**
|
|
335
|
-
* Ensures that the source file that `node` is part of has been preprocessed.
|
|
336
|
-
*
|
|
337
|
-
* During preprocessing, all statements in the source file will be visited such that certain
|
|
338
|
-
* processing steps can be done up-front and cached for subsequent usages.
|
|
339
|
-
*
|
|
340
|
-
* @param sourceFile The source file that needs to have gone through preprocessing.
|
|
341
|
-
*/
|
|
342
|
-
protected ensurePreprocessed(sourceFile: ts.SourceFile): void;
|
|
343
|
-
/**
|
|
344
|
-
* Analyzes the given statement to see if it corresponds with a variable declaration like
|
|
345
|
-
* `let MyClass = MyClass_1 = class MyClass {};`. If so, the declaration of `MyClass_1`
|
|
346
|
-
* is associated with the `MyClass` identifier.
|
|
347
|
-
*
|
|
348
|
-
* @param statement The statement that needs to be preprocessed.
|
|
349
|
-
*/
|
|
350
|
-
protected preprocessStatement(statement: ts.Statement): void;
|
|
351
|
-
/**
|
|
352
|
-
* Get the top level statements for a module.
|
|
353
|
-
*
|
|
354
|
-
* In ES5 and ES2015 this is just the top level statements of the file.
|
|
355
|
-
* @param sourceFile The module whose statements we want.
|
|
356
|
-
* @returns An array of top level statements for the given module.
|
|
357
|
-
*/
|
|
358
|
-
protected getModuleStatements(sourceFile: ts.SourceFile): ts.Statement[];
|
|
359
|
-
/**
|
|
360
|
-
* Walk the AST looking for an assignment to the specified symbol.
|
|
361
|
-
* @param node The current node we are searching.
|
|
362
|
-
* @returns an expression that represents the value of the variable, or undefined if none can be
|
|
363
|
-
* found.
|
|
364
|
-
*/
|
|
365
|
-
protected findDecoratedVariableValue(node: ts.Node | undefined, symbol: ts.Symbol): ts.CallExpression | null;
|
|
366
|
-
/**
|
|
367
|
-
* Try to retrieve the symbol of a static property on a class.
|
|
368
|
-
*
|
|
369
|
-
* In some cases, a static property can either be set on the inner (implementation or adjacent)
|
|
370
|
-
* declaration inside the class' IIFE, or it can be set on the outer variable declaration.
|
|
371
|
-
* Therefore, the host checks all places, first looking up the property on the inner symbols, and
|
|
372
|
-
* if the property is not found it will fall back to looking up the property on the outer symbol.
|
|
373
|
-
*
|
|
374
|
-
* @param symbol the class whose property we are interested in.
|
|
375
|
-
* @param propertyName the name of static property.
|
|
376
|
-
* @returns the symbol if it is found or `undefined` if not.
|
|
377
|
-
*/
|
|
378
|
-
protected getStaticProperty(symbol: NgccClassSymbol, propertyName: ts.__String): ts.Symbol | undefined;
|
|
379
|
-
/**
|
|
380
|
-
* This is the main entry-point for obtaining information on the decorators of a given class. This
|
|
381
|
-
* information is computed either from static properties if present, or using `tslib.__decorate`
|
|
382
|
-
* helper calls otherwise. The computed result is cached per class.
|
|
383
|
-
*
|
|
384
|
-
* @param classSymbol the class for which decorators should be acquired.
|
|
385
|
-
* @returns all information of the decorators on the class.
|
|
386
|
-
*/
|
|
387
|
-
protected acquireDecoratorInfo(classSymbol: NgccClassSymbol): DecoratorInfo;
|
|
388
|
-
/**
|
|
389
|
-
* Attempts to compute decorator information from static properties "decorators", "propDecorators"
|
|
390
|
-
* and "ctorParameters" on the class. If neither of these static properties is present the
|
|
391
|
-
* library is likely not compiled using tsickle for usage with Closure compiler, in which case
|
|
392
|
-
* `null` is returned.
|
|
393
|
-
*
|
|
394
|
-
* @param classSymbol The class symbol to compute the decorators information for.
|
|
395
|
-
* @returns All information on the decorators as extracted from static properties, or `null` if
|
|
396
|
-
* none of the static properties exist.
|
|
397
|
-
*/
|
|
398
|
-
protected computeDecoratorInfoFromStaticProperties(classSymbol: NgccClassSymbol): {
|
|
399
|
-
classDecorators: Decorator[] | null;
|
|
400
|
-
memberDecorators: Map<string, Decorator[]> | null;
|
|
401
|
-
constructorParamInfo: ParamInfo[] | null;
|
|
402
|
-
};
|
|
403
|
-
/**
|
|
404
|
-
* Get all class decorators for the given class, where the decorators are declared
|
|
405
|
-
* via a static property. For example:
|
|
406
|
-
*
|
|
407
|
-
* ```
|
|
408
|
-
* class SomeDirective {}
|
|
409
|
-
* SomeDirective.decorators = [
|
|
410
|
-
* { type: Directive, args: [{ selector: '[someDirective]' },] }
|
|
411
|
-
* ];
|
|
412
|
-
* ```
|
|
413
|
-
*
|
|
414
|
-
* @param decoratorsSymbol the property containing the decorators we want to get.
|
|
415
|
-
* @returns an array of decorators or null if none where found.
|
|
416
|
-
*/
|
|
417
|
-
protected getClassDecoratorsFromStaticProperty(decoratorsSymbol: ts.Symbol): Decorator[] | null;
|
|
418
|
-
/**
|
|
419
|
-
* Examine a symbol which should be of a class, and return metadata about its members.
|
|
420
|
-
*
|
|
421
|
-
* @param symbol the `ClassSymbol` representing the class over which to reflect.
|
|
422
|
-
* @returns an array of `ClassMember` metadata representing the members of the class.
|
|
423
|
-
*/
|
|
424
|
-
protected getMembersOfSymbol(symbol: NgccClassSymbol): ClassMember[];
|
|
425
|
-
/**
|
|
426
|
-
* Member decorators may be declared as static properties of the class:
|
|
427
|
-
*
|
|
428
|
-
* ```
|
|
429
|
-
* SomeDirective.propDecorators = {
|
|
430
|
-
* "ngForOf": [{ type: Input },],
|
|
431
|
-
* "ngForTrackBy": [{ type: Input },],
|
|
432
|
-
* "ngForTemplate": [{ type: Input },],
|
|
433
|
-
* };
|
|
434
|
-
* ```
|
|
435
|
-
*
|
|
436
|
-
* @param decoratorsProperty the class whose member decorators we are interested in.
|
|
437
|
-
* @returns a map whose keys are the name of the members and whose values are collections of
|
|
438
|
-
* decorators for the given member.
|
|
439
|
-
*/
|
|
440
|
-
protected getMemberDecoratorsFromStaticProperty(decoratorsProperty: ts.Symbol): Map<string, Decorator[]>;
|
|
441
|
-
/**
|
|
442
|
-
* For a given class symbol, collects all decorator information from tslib helper methods, as
|
|
443
|
-
* generated by TypeScript into emitted JavaScript files.
|
|
444
|
-
*
|
|
445
|
-
* Class decorators are extracted from calls to `tslib.__decorate` that look as follows:
|
|
446
|
-
*
|
|
447
|
-
* ```
|
|
448
|
-
* let SomeDirective = class SomeDirective {}
|
|
449
|
-
* SomeDirective = __decorate([
|
|
450
|
-
* Directive({ selector: '[someDirective]' }),
|
|
451
|
-
* ], SomeDirective);
|
|
452
|
-
* ```
|
|
453
|
-
*
|
|
454
|
-
* The extraction of member decorators is similar, with the distinction that its 2nd and 3rd
|
|
455
|
-
* argument correspond with a "prototype" target and the name of the member to which the
|
|
456
|
-
* decorators apply.
|
|
457
|
-
*
|
|
458
|
-
* ```
|
|
459
|
-
* __decorate([
|
|
460
|
-
* Input(),
|
|
461
|
-
* __metadata("design:type", String)
|
|
462
|
-
* ], SomeDirective.prototype, "input1", void 0);
|
|
463
|
-
* ```
|
|
464
|
-
*
|
|
465
|
-
* @param classSymbol The class symbol for which decorators should be extracted.
|
|
466
|
-
* @returns All information on the decorators of the class.
|
|
467
|
-
*/
|
|
468
|
-
protected computeDecoratorInfoFromHelperCalls(classSymbol: NgccClassSymbol): DecoratorInfo;
|
|
469
|
-
/**
|
|
470
|
-
* Extract the details of an entry within a `__decorate` helper call. For example, given the
|
|
471
|
-
* following code:
|
|
472
|
-
*
|
|
473
|
-
* ```
|
|
474
|
-
* __decorate([
|
|
475
|
-
* Directive({ selector: '[someDirective]' }),
|
|
476
|
-
* tslib_1.__param(2, Inject(INJECTED_TOKEN)),
|
|
477
|
-
* tslib_1.__metadata("design:paramtypes", [ViewContainerRef, TemplateRef, String])
|
|
478
|
-
* ], SomeDirective);
|
|
479
|
-
* ```
|
|
480
|
-
*
|
|
481
|
-
* it can be seen that there are calls to regular decorators (the `Directive`) and calls into
|
|
482
|
-
* `tslib` functions which have been inserted by TypeScript. Therefore, this function classifies
|
|
483
|
-
* a call to correspond with
|
|
484
|
-
* 1. a real decorator like `Directive` above, or
|
|
485
|
-
* 2. a decorated parameter, corresponding with `__param` calls from `tslib`, or
|
|
486
|
-
* 3. the type information of parameters, corresponding with `__metadata` call from `tslib`
|
|
487
|
-
*
|
|
488
|
-
* @param expression the expression that needs to be reflected into a `DecorateHelperEntry`
|
|
489
|
-
* @returns an object that indicates which of the three categories the call represents, together
|
|
490
|
-
* with the reflected information of the call, or null if the call is not a valid decorate call.
|
|
491
|
-
*/
|
|
492
|
-
protected reflectDecorateHelperEntry(expression: ts.Expression): DecorateHelperEntry | null;
|
|
493
|
-
protected reflectDecoratorCall(call: ts.CallExpression): Decorator | null;
|
|
494
|
-
/**
|
|
495
|
-
* Check the given statement to see if it is a call to any of the specified helper functions or
|
|
496
|
-
* null if not found.
|
|
497
|
-
*
|
|
498
|
-
* Matching statements will look like: `tslib_1.__decorate(...);`.
|
|
499
|
-
* @param statement the statement that may contain the call.
|
|
500
|
-
* @param helperNames the names of the helper we are looking for.
|
|
501
|
-
* @returns the node that corresponds to the `__decorate(...)` call or null if the statement
|
|
502
|
-
* does not match.
|
|
503
|
-
*/
|
|
504
|
-
protected getHelperCall(statement: ts.Statement, helperNames: string[]): ts.CallExpression | null;
|
|
505
|
-
/**
|
|
506
|
-
* Reflect over the given array node and extract decorator information from each element.
|
|
507
|
-
*
|
|
508
|
-
* This is used for decorators that are defined in static properties. For example:
|
|
509
|
-
*
|
|
510
|
-
* ```
|
|
511
|
-
* SomeDirective.decorators = [
|
|
512
|
-
* { type: Directive, args: [{ selector: '[someDirective]' },] }
|
|
513
|
-
* ];
|
|
514
|
-
* ```
|
|
515
|
-
*
|
|
516
|
-
* @param decoratorsArray an expression that contains decorator information.
|
|
517
|
-
* @returns an array of decorator info that was reflected from the array node.
|
|
518
|
-
*/
|
|
519
|
-
protected reflectDecorators(decoratorsArray: ts.Expression): Decorator[];
|
|
520
|
-
/**
|
|
521
|
-
* Reflect over a symbol and extract the member information, combining it with the
|
|
522
|
-
* provided decorator information, and whether it is a static member.
|
|
523
|
-
*
|
|
524
|
-
* A single symbol may represent multiple class members in the case of accessors;
|
|
525
|
-
* an equally named getter/setter accessor pair is combined into a single symbol.
|
|
526
|
-
* When the symbol is recognized as representing an accessor, its declarations are
|
|
527
|
-
* analyzed such that both the setter and getter accessor are returned as separate
|
|
528
|
-
* class members.
|
|
529
|
-
*
|
|
530
|
-
* One difference wrt the TypeScript host is that in ES2015, we cannot see which
|
|
531
|
-
* accessor originally had any decorators applied to them, as decorators are applied
|
|
532
|
-
* to the property descriptor in general, not a specific accessor. If an accessor
|
|
533
|
-
* has both a setter and getter, any decorators are only attached to the setter member.
|
|
534
|
-
*
|
|
535
|
-
* @param symbol the symbol for the member to reflect over.
|
|
536
|
-
* @param decorators an array of decorators associated with the member.
|
|
537
|
-
* @param isStatic true if this member is static, false if it is an instance property.
|
|
538
|
-
* @returns the reflected member information, or null if the symbol is not a member.
|
|
539
|
-
*/
|
|
540
|
-
protected reflectMembers(symbol: ts.Symbol, decorators?: Decorator[], isStatic?: boolean): ClassMember[] | null;
|
|
541
|
-
/**
|
|
542
|
-
* Reflect over a symbol and extract the member information, combining it with the
|
|
543
|
-
* provided decorator information, and whether it is a static member.
|
|
544
|
-
* @param node the declaration node for the member to reflect over.
|
|
545
|
-
* @param kind the assumed kind of the member, may become more accurate during reflection.
|
|
546
|
-
* @param decorators an array of decorators associated with the member.
|
|
547
|
-
* @param isStatic true if this member is static, false if it is an instance property.
|
|
548
|
-
* @returns the reflected member information, or null if the symbol is not a member.
|
|
549
|
-
*/
|
|
550
|
-
protected reflectMember(node: ts.Declaration, kind: ClassMemberKind | null, decorators?: Decorator[], isStatic?: boolean): ClassMember | null;
|
|
551
|
-
/**
|
|
552
|
-
* Find the declarations of the constructor parameters of a class identified by its symbol.
|
|
553
|
-
* @param classSymbol the class whose parameters we want to find.
|
|
554
|
-
* @returns an array of `ts.ParameterDeclaration` objects representing each of the parameters in
|
|
555
|
-
* the class's constructor or null if there is no constructor.
|
|
556
|
-
*/
|
|
557
|
-
protected getConstructorParameterDeclarations(classSymbol: NgccClassSymbol): ts.ParameterDeclaration[] | null;
|
|
558
|
-
/**
|
|
559
|
-
* Get the parameter decorators of a class constructor.
|
|
560
|
-
*
|
|
561
|
-
* @param classSymbol the class whose parameter info we want to get.
|
|
562
|
-
* @param parameterNodes the array of TypeScript parameter nodes for this class's constructor.
|
|
563
|
-
* @returns an array of constructor parameter info objects.
|
|
564
|
-
*/
|
|
565
|
-
protected getConstructorParamInfo(classSymbol: NgccClassSymbol, parameterNodes: ts.ParameterDeclaration[]): CtorParameter[];
|
|
566
|
-
/**
|
|
567
|
-
* Compute the `TypeValueReference` for the given `typeExpression`.
|
|
568
|
-
*
|
|
569
|
-
* Although `typeExpression` is a valid `ts.Expression` that could be emitted directly into the
|
|
570
|
-
* generated code, ngcc still needs to resolve the declaration and create an `IMPORTED` type
|
|
571
|
-
* value reference as the compiler has specialized handling for some symbols, for example
|
|
572
|
-
* `ChangeDetectorRef` from `@angular/core`. Such an `IMPORTED` type value reference will result
|
|
573
|
-
* in a newly generated namespace import, instead of emitting the original `typeExpression` as is.
|
|
574
|
-
*/
|
|
575
|
-
private typeToValue;
|
|
576
|
-
/**
|
|
577
|
-
* Determines where the `expression` is imported from.
|
|
578
|
-
*
|
|
579
|
-
* @param expression the expression to determine the import details for.
|
|
580
|
-
* @returns the `Import` for the expression, or `null` if the expression is not imported or the
|
|
581
|
-
* expression syntax is not supported.
|
|
582
|
-
*/
|
|
583
|
-
private getImportOfExpression;
|
|
584
|
-
/**
|
|
585
|
-
* Get the parameter type and decorators for the constructor of a class,
|
|
586
|
-
* where the information is stored on a static property of the class.
|
|
587
|
-
*
|
|
588
|
-
* Note that in ESM2015, the property is defined an array, or by an arrow function that returns
|
|
589
|
-
* an array, of decorator and type information.
|
|
590
|
-
*
|
|
591
|
-
* For example,
|
|
592
|
-
*
|
|
593
|
-
* ```
|
|
594
|
-
* SomeDirective.ctorParameters = () => [
|
|
595
|
-
* {type: ViewContainerRef},
|
|
596
|
-
* {type: TemplateRef},
|
|
597
|
-
* {type: undefined, decorators: [{ type: Inject, args: [INJECTED_TOKEN]}]},
|
|
598
|
-
* ];
|
|
599
|
-
* ```
|
|
600
|
-
*
|
|
601
|
-
* or
|
|
602
|
-
*
|
|
603
|
-
* ```
|
|
604
|
-
* SomeDirective.ctorParameters = [
|
|
605
|
-
* {type: ViewContainerRef},
|
|
606
|
-
* {type: TemplateRef},
|
|
607
|
-
* {type: undefined, decorators: [{type: Inject, args: [INJECTED_TOKEN]}]},
|
|
608
|
-
* ];
|
|
609
|
-
* ```
|
|
610
|
-
*
|
|
611
|
-
* @param paramDecoratorsProperty the property that holds the parameter info we want to get.
|
|
612
|
-
* @returns an array of objects containing the type and decorators for each parameter.
|
|
613
|
-
*/
|
|
614
|
-
protected getParamInfoFromStaticProperty(paramDecoratorsProperty: ts.Symbol): ParamInfo[] | null;
|
|
615
|
-
/**
|
|
616
|
-
* Search statements related to the given class for calls to the specified helper.
|
|
617
|
-
* @param classSymbol the class whose helper calls we are interested in.
|
|
618
|
-
* @param helperNames the names of the helpers (e.g. `__decorate`) whose calls we are interested
|
|
619
|
-
* in.
|
|
620
|
-
* @returns an array of CallExpression nodes for each matching helper call.
|
|
621
|
-
*/
|
|
622
|
-
protected getHelperCallsForClass(classSymbol: NgccClassSymbol, helperNames: string[]): ts.CallExpression[];
|
|
623
|
-
/**
|
|
624
|
-
* Find statements related to the given class that may contain calls to a helper.
|
|
625
|
-
*
|
|
626
|
-
* In ESM2015 code the helper calls are in the top level module, so we have to consider
|
|
627
|
-
* all the statements in the module.
|
|
628
|
-
*
|
|
629
|
-
* @param classSymbol the class whose helper calls we are interested in.
|
|
630
|
-
* @returns an array of statements that may contain helper calls.
|
|
631
|
-
*/
|
|
632
|
-
protected getStatementsForClass(classSymbol: NgccClassSymbol): ts.Statement[];
|
|
633
|
-
/**
|
|
634
|
-
* Test whether a decorator was imported from `@angular/core`.
|
|
635
|
-
*
|
|
636
|
-
* Is the decorator:
|
|
637
|
-
* * externally imported from `@angular/core`?
|
|
638
|
-
* * the current hosted program is actually `@angular/core` and
|
|
639
|
-
* - relatively internally imported; or
|
|
640
|
-
* - not imported, from the current file.
|
|
641
|
-
*
|
|
642
|
-
* @param decorator the decorator to test.
|
|
643
|
-
*/
|
|
644
|
-
protected isFromCore(decorator: Decorator): boolean;
|
|
645
|
-
/**
|
|
646
|
-
* Create a mapping between the public exports in a src program and the public exports of a dts
|
|
647
|
-
* program.
|
|
648
|
-
*
|
|
649
|
-
* @param src the program bundle containing the source files.
|
|
650
|
-
* @param dts the program bundle containing the typings files.
|
|
651
|
-
* @returns a map of source declarations to typings declarations.
|
|
652
|
-
*/
|
|
653
|
-
protected computePublicDtsDeclarationMap(src: BundleProgram, dts: BundleProgram): Map<DeclarationNode, ts.Declaration>;
|
|
654
|
-
/**
|
|
655
|
-
* Create a mapping between the "private" exports in a src program and the "private" exports of a
|
|
656
|
-
* dts program. These exports may be exported from individual files in the src or dts programs,
|
|
657
|
-
* but not exported from the root file (i.e publicly from the entry-point).
|
|
658
|
-
*
|
|
659
|
-
* This mapping is a "best guess" since we cannot guarantee that two declarations that happen to
|
|
660
|
-
* be exported from a file with the same name are actually equivalent. But this is a reasonable
|
|
661
|
-
* estimate for the purposes of ngcc.
|
|
662
|
-
*
|
|
663
|
-
* @param src the program bundle containing the source files.
|
|
664
|
-
* @param dts the program bundle containing the typings files.
|
|
665
|
-
* @returns a map of source declarations to typings declarations.
|
|
666
|
-
*/
|
|
667
|
-
protected computePrivateDtsDeclarationMap(src: BundleProgram, dts: BundleProgram): Map<DeclarationNode, ts.Declaration>;
|
|
668
|
-
/**
|
|
669
|
-
* Collect mappings between names of exported declarations in a file and its actual declaration.
|
|
670
|
-
*
|
|
671
|
-
* Any new mappings are added to the `dtsDeclarationMap`.
|
|
672
|
-
*/
|
|
673
|
-
protected collectDtsExportedDeclarations(dtsDeclarationMap: Map<string, ts.Declaration>, srcFile: ts.SourceFile, checker: ts.TypeChecker): void;
|
|
674
|
-
protected collectSrcExportedDeclarations(declarationMap: Map<DeclarationNode, ts.Declaration>, dtsDeclarationMap: Map<string, ts.Declaration>, srcFile: ts.SourceFile): void;
|
|
675
|
-
protected getDeclarationOfExpression(expression: ts.Expression): Declaration | null;
|
|
676
|
-
/** Checks if the specified declaration resolves to the known JavaScript global `Object`. */
|
|
677
|
-
protected isJavaScriptObjectDeclaration(decl: Declaration): boolean;
|
|
678
|
-
/**
|
|
679
|
-
* In JavaScript, enum declarations are emitted as a regular variable declaration followed by an
|
|
680
|
-
* IIFE in which the enum members are assigned.
|
|
681
|
-
*
|
|
682
|
-
* export var Enum;
|
|
683
|
-
* (function (Enum) {
|
|
684
|
-
* Enum["a"] = "A";
|
|
685
|
-
* Enum["b"] = "B";
|
|
686
|
-
* })(Enum || (Enum = {}));
|
|
687
|
-
*
|
|
688
|
-
* @param declaration A variable declaration that may represent an enum
|
|
689
|
-
* @returns An array of enum members if the variable declaration is followed by an IIFE that
|
|
690
|
-
* declares the enum members, or null otherwise.
|
|
691
|
-
*/
|
|
692
|
-
protected resolveEnumMembers(declaration: ts.VariableDeclaration): EnumMember[] | null;
|
|
693
|
-
/**
|
|
694
|
-
* Attempts to extract all `EnumMember`s from a function that is according to the JavaScript emit
|
|
695
|
-
* format for enums:
|
|
696
|
-
*
|
|
697
|
-
* function (Enum) {
|
|
698
|
-
* Enum["MemberA"] = "a";
|
|
699
|
-
* Enum["MemberB"] = "b";
|
|
700
|
-
* }
|
|
701
|
-
*
|
|
702
|
-
* @param fn The function expression that is assumed to contain enum members.
|
|
703
|
-
* @returns All enum members if the function is according to the correct syntax, null otherwise.
|
|
704
|
-
*/
|
|
705
|
-
private reflectEnumMembers;
|
|
706
|
-
/**
|
|
707
|
-
* Attempts to extract a single `EnumMember` from a statement in the following syntax:
|
|
708
|
-
*
|
|
709
|
-
* Enum["MemberA"] = "a";
|
|
710
|
-
*
|
|
711
|
-
* or, for enum member with numeric values:
|
|
712
|
-
*
|
|
713
|
-
* Enum[Enum["MemberA"] = 0] = "MemberA";
|
|
714
|
-
*
|
|
715
|
-
* @param enumName The identifier of the enum that the members should be set on.
|
|
716
|
-
* @param statement The statement to inspect.
|
|
717
|
-
* @returns An `EnumMember` if the statement is according to the expected syntax, null otherwise.
|
|
718
|
-
*/
|
|
719
|
-
protected reflectEnumMember(enumName: ts.Identifier, statement: ts.Statement): EnumMember | null;
|
|
720
|
-
private getAdjacentNameOfClassSymbol;
|
|
721
|
-
}
|
|
722
|
-
/**
|
|
723
|
-
* An enum member assignment that looks like `Enum[X] = Y;`.
|
|
724
|
-
*/
|
|
725
|
-
export type EnumMemberAssignment = ts.BinaryExpression & {
|
|
726
|
-
left: ts.ElementAccessExpression;
|
|
727
|
-
};
|
|
728
|
-
export type ParamInfo = {
|
|
729
|
-
decorators: Decorator[] | null;
|
|
730
|
-
typeExpression: ts.Expression | null;
|
|
731
|
-
};
|
|
732
|
-
/**
|
|
733
|
-
* Represents a call to `tslib.__metadata` as present in `tslib.__decorate` calls. This is a
|
|
734
|
-
* synthetic decorator inserted by TypeScript that contains reflection information about the
|
|
735
|
-
* target of the decorator, i.e. the class or property.
|
|
736
|
-
*/
|
|
737
|
-
export interface ParameterTypes {
|
|
738
|
-
type: 'params';
|
|
739
|
-
types: ts.Expression[];
|
|
740
|
-
}
|
|
741
|
-
/**
|
|
742
|
-
* Represents a call to `tslib.__param` as present in `tslib.__decorate` calls. This contains
|
|
743
|
-
* information on any decorators were applied to a certain parameter.
|
|
744
|
-
*/
|
|
745
|
-
export interface ParameterDecorators {
|
|
746
|
-
type: 'param:decorators';
|
|
747
|
-
index: number;
|
|
748
|
-
decorator: Decorator;
|
|
749
|
-
}
|
|
750
|
-
/**
|
|
751
|
-
* Represents a call to a decorator as it was present in the original source code, as present in
|
|
752
|
-
* `tslib.__decorate` calls.
|
|
753
|
-
*/
|
|
754
|
-
export interface DecoratorCall {
|
|
755
|
-
type: 'decorator';
|
|
756
|
-
decorator: Decorator;
|
|
757
|
-
}
|
|
758
|
-
/**
|
|
759
|
-
* Represents the different kinds of decorate helpers that may be present as first argument to
|
|
760
|
-
* `tslib.__decorate`, as follows:
|
|
761
|
-
*
|
|
762
|
-
* ```
|
|
763
|
-
* __decorate([
|
|
764
|
-
* Directive({ selector: '[someDirective]' }),
|
|
765
|
-
* tslib_1.__param(2, Inject(INJECTED_TOKEN)),
|
|
766
|
-
* tslib_1.__metadata("design:paramtypes", [ViewContainerRef, TemplateRef, String])
|
|
767
|
-
* ], SomeDirective);
|
|
768
|
-
* ```
|
|
769
|
-
*/
|
|
770
|
-
export type DecorateHelperEntry = ParameterTypes | ParameterDecorators | DecoratorCall;
|
|
771
|
-
/**
|
|
772
|
-
* The recorded decorator information of a single class. This information is cached in the host.
|
|
773
|
-
*/
|
|
774
|
-
interface DecoratorInfo {
|
|
775
|
-
/**
|
|
776
|
-
* All decorators that were present on the class. If no decorators were present, this is `null`
|
|
777
|
-
*/
|
|
778
|
-
classDecorators: Decorator[] | null;
|
|
779
|
-
/**
|
|
780
|
-
* All decorators per member of the class they were present on.
|
|
781
|
-
*/
|
|
782
|
-
memberDecorators: Map<string, Decorator[]>;
|
|
783
|
-
/**
|
|
784
|
-
* Represents the constructor parameter information, such as the type of a parameter and all
|
|
785
|
-
* decorators for a certain parameter. Indices in this array correspond with the parameter's
|
|
786
|
-
* index in the constructor. Note that this array may be sparse, i.e. certain constructor
|
|
787
|
-
* parameters may not have any info recorded.
|
|
788
|
-
*/
|
|
789
|
-
constructorParamInfo: ParamInfo[];
|
|
790
|
-
}
|
|
791
|
-
/**
|
|
792
|
-
* A statement node that represents an assignment.
|
|
793
|
-
*/
|
|
794
|
-
export type AssignmentStatement = ts.ExpressionStatement & {
|
|
795
|
-
expression: {
|
|
796
|
-
left: ts.Identifier;
|
|
797
|
-
right: ts.Expression;
|
|
798
|
-
};
|
|
799
|
-
};
|
|
800
|
-
/**
|
|
801
|
-
* Test whether a statement node is an assignment statement.
|
|
802
|
-
* @param statement the statement to test.
|
|
803
|
-
*/
|
|
804
|
-
export declare function isAssignmentStatement(statement: ts.Statement): statement is AssignmentStatement;
|
|
805
|
-
/**
|
|
806
|
-
* Parse the `expression` that is believed to be an IIFE and return the AST node that corresponds to
|
|
807
|
-
* the body of the IIFE.
|
|
808
|
-
*
|
|
809
|
-
* The expression may be wrapped in parentheses, which are stripped off.
|
|
810
|
-
*
|
|
811
|
-
* If the IIFE is an arrow function then its body could be a `ts.Expression` rather than a
|
|
812
|
-
* `ts.FunctionBody`.
|
|
813
|
-
*
|
|
814
|
-
* @param expression the expression to parse.
|
|
815
|
-
* @returns the `ts.Expression` or `ts.FunctionBody` that holds the body of the IIFE or `undefined`
|
|
816
|
-
* if the `expression` did not have the correct shape.
|
|
817
|
-
*/
|
|
818
|
-
export declare function getIifeBody(expression: ts.Expression): ts.ConciseBody | undefined;
|
|
819
|
-
/**
|
|
820
|
-
* Returns true if the `node` is an assignment of the form `a = b`.
|
|
821
|
-
*
|
|
822
|
-
* @param node The AST node to check.
|
|
823
|
-
*/
|
|
824
|
-
export declare function isAssignment(node: ts.Node): node is ts.AssignmentExpression<ts.EqualsToken>;
|
|
825
|
-
/**
|
|
826
|
-
* Tests whether the provided call expression targets a class, by verifying its arguments are
|
|
827
|
-
* according to the following form:
|
|
828
|
-
*
|
|
829
|
-
* ```
|
|
830
|
-
* __decorate([], SomeDirective);
|
|
831
|
-
* ```
|
|
832
|
-
*
|
|
833
|
-
* @param call the call expression that is tested to represent a class decorator call.
|
|
834
|
-
* @param matches predicate function to test whether the call is associated with the desired class.
|
|
835
|
-
*/
|
|
836
|
-
export declare function isClassDecorateCall(call: ts.CallExpression, matches: (identifier: ts.Identifier) => boolean): call is ts.CallExpression & {
|
|
837
|
-
arguments: [ts.ArrayLiteralExpression, ts.Expression];
|
|
838
|
-
};
|
|
839
|
-
/**
|
|
840
|
-
* Tests whether the provided call expression targets a member of the class, by verifying its
|
|
841
|
-
* arguments are according to the following form:
|
|
842
|
-
*
|
|
843
|
-
* ```
|
|
844
|
-
* __decorate([], SomeDirective.prototype, "member", void 0);
|
|
845
|
-
* ```
|
|
846
|
-
*
|
|
847
|
-
* @param call the call expression that is tested to represent a member decorator call.
|
|
848
|
-
* @param matches predicate function to test whether the call is associated with the desired class.
|
|
849
|
-
*/
|
|
850
|
-
export declare function isMemberDecorateCall(call: ts.CallExpression, matches: (identifier: ts.Identifier) => boolean): call is ts.CallExpression & {
|
|
851
|
-
arguments: [ts.ArrayLiteralExpression, ts.StringLiteral, ts.StringLiteral];
|
|
852
|
-
};
|
|
853
|
-
/**
|
|
854
|
-
* Helper method to extract the value of a property given the property's "symbol",
|
|
855
|
-
* which is actually the symbol of the identifier of the property.
|
|
856
|
-
*/
|
|
857
|
-
export declare function getPropertyValueFromSymbol(propSymbol: ts.Symbol): ts.Expression | undefined;
|
|
858
|
-
type InitializedVariableClassDeclaration = ClassDeclaration<ts.VariableDeclaration> & {
|
|
859
|
-
initializer: ts.Expression;
|
|
860
|
-
};
|
|
861
|
-
/**
|
|
862
|
-
* Handle a variable declaration of the form
|
|
863
|
-
*
|
|
864
|
-
* ```
|
|
865
|
-
* var MyClass = alias1 = alias2 = <<declaration>>
|
|
866
|
-
* ```
|
|
867
|
-
*
|
|
868
|
-
* @param node the LHS of a variable declaration.
|
|
869
|
-
* @returns the original AST node or the RHS of a series of assignments in a variable
|
|
870
|
-
* declaration.
|
|
871
|
-
*/
|
|
872
|
-
export declare function skipClassAliases(node: InitializedVariableClassDeclaration): ts.Expression;
|
|
873
|
-
/**
|
|
874
|
-
* This expression could either be a class expression
|
|
875
|
-
*
|
|
876
|
-
* ```
|
|
877
|
-
* class MyClass {};
|
|
878
|
-
* ```
|
|
879
|
-
*
|
|
880
|
-
* or an IIFE wrapped class expression
|
|
881
|
-
*
|
|
882
|
-
* ```
|
|
883
|
-
* (() => {
|
|
884
|
-
* class MyClass {}
|
|
885
|
-
* ...
|
|
886
|
-
* return MyClass;
|
|
887
|
-
* })()
|
|
888
|
-
* ```
|
|
889
|
-
*
|
|
890
|
-
* or an IIFE wrapped aliased class expression
|
|
891
|
-
*
|
|
892
|
-
* ```
|
|
893
|
-
* (() => {
|
|
894
|
-
* let MyClass = class MyClass {}
|
|
895
|
-
* ...
|
|
896
|
-
* return MyClass;
|
|
897
|
-
* })()
|
|
898
|
-
* ```
|
|
899
|
-
*
|
|
900
|
-
* or an IFFE wrapped ES5 class function
|
|
901
|
-
*
|
|
902
|
-
* ```
|
|
903
|
-
* (function () {
|
|
904
|
-
* function MyClass() {}
|
|
905
|
-
* ...
|
|
906
|
-
* return MyClass
|
|
907
|
-
* })()
|
|
908
|
-
* ```
|
|
909
|
-
*
|
|
910
|
-
* @param expression the node that represents the class whose declaration we are finding.
|
|
911
|
-
* @returns the declaration of the class or `null` if it is not a "class".
|
|
912
|
-
*/
|
|
913
|
-
export declare function getInnerClassDeclaration(expression: ts.Expression): ClassDeclaration<ts.ClassExpression | ts.ClassDeclaration | ts.FunctionDeclaration> | null;
|
|
914
|
-
/**
|
|
915
|
-
* Find the statement that contains the given node
|
|
916
|
-
* @param node a node whose containing statement we wish to find
|
|
917
|
-
*/
|
|
918
|
-
export declare function getContainingStatement(node: ts.Node): ts.Statement;
|
|
919
|
-
/**
|
|
920
|
-
* Get a node that represents the actual (outer) declaration of a class from its implementation.
|
|
921
|
-
*
|
|
922
|
-
* Sometimes, the implementation of a class is an expression that is hidden inside an IIFE and
|
|
923
|
-
* assigned to a variable outside the IIFE, which is what the rest of the program interacts with.
|
|
924
|
-
* For example,
|
|
925
|
-
*
|
|
926
|
-
* ```
|
|
927
|
-
* OuterNode = Alias = (function() { function InnerNode() {} return InnerNode; })();
|
|
928
|
-
* ```
|
|
929
|
-
*
|
|
930
|
-
* @param node a node that could be the implementation inside an IIFE.
|
|
931
|
-
* @returns a node that represents the outer declaration, or `null` if it is does not match the IIFE
|
|
932
|
-
* format shown above.
|
|
933
|
-
*/
|
|
934
|
-
export declare function getOuterNodeFromInnerDeclaration(node: ts.Node): ts.Node | null;
|
|
935
|
-
export {};
|