static-injector 1.0.8

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.
Files changed (146) hide show
  1. package/import/commonjs/index.js +1248 -0
  2. package/import/es2015/decorator/injectable.js +14 -0
  3. package/import/es2015/decorator/interface/provider.js +8 -0
  4. package/import/es2015/di/forward_ref.js +53 -0
  5. package/import/es2015/di/inject_switch.js +31 -0
  6. package/import/es2015/di/injection_token.js +71 -0
  7. package/import/es2015/di/injector.js +63 -0
  8. package/import/es2015/di/injector_compatibility.js +172 -0
  9. package/import/es2015/di/injector_marker.js +8 -0
  10. package/import/es2015/di/injector_token.js +21 -0
  11. package/import/es2015/di/interface/defs.js +72 -0
  12. package/import/es2015/di/interface/injector.js +25 -0
  13. package/import/es2015/di/interface/provider.js +8 -0
  14. package/import/es2015/di/metadata.js +49 -0
  15. package/import/es2015/di/null_injector.js +19 -0
  16. package/import/es2015/di/provider_token.js +8 -0
  17. package/import/es2015/di/r3_injector.js +382 -0
  18. package/import/es2015/di/scope.js +14 -0
  19. package/import/es2015/index.js +11 -0
  20. package/import/es2015/interface/lifecycle_hooks.js +8 -0
  21. package/import/es2015/interface/type.js +8 -0
  22. package/import/es2015/render3/definition_factory.js +15 -0
  23. package/import/es2015/render3/error_code.js +29 -0
  24. package/import/es2015/render3/errors_di.js +14 -0
  25. package/import/es2015/render3/fields.js +11 -0
  26. package/import/es2015/render3/instructions/di.js +23 -0
  27. package/import/es2015/render3/util/stringify_utils.js +37 -0
  28. package/import/es2015/util/array_utils.js +17 -0
  29. package/import/es2015/util/closure.js +19 -0
  30. package/import/es2015/util/decorators.js +30 -0
  31. package/import/es2015/util/empty.js +14 -0
  32. package/import/es2015/util/property.js +15 -0
  33. package/import/es2015/util/stringify.js +30 -0
  34. package/import/fesm2015/index.js +1211 -0
  35. package/import/typings/decorator/injectable.d.ts +82 -0
  36. package/import/typings/decorator/interface/provider.d.ts +312 -0
  37. package/import/typings/di/forward_ref.d.ts +49 -0
  38. package/import/typings/di/inject_switch.d.ts +17 -0
  39. package/import/typings/di/injection_token.d.ts +57 -0
  40. package/import/typings/di/injector.d.ts +76 -0
  41. package/import/typings/di/injector_compatibility.d.ts +77 -0
  42. package/import/typings/di/injector_marker.d.ts +23 -0
  43. package/import/typings/di/injector_token.d.ts +18 -0
  44. package/import/typings/di/interface/defs.d.ts +155 -0
  45. package/import/typings/di/interface/injector.d.ts +48 -0
  46. package/import/typings/di/interface/provider.d.ts +312 -0
  47. package/import/typings/di/metadata.d.ts +176 -0
  48. package/import/typings/di/null_injector.d.ts +11 -0
  49. package/import/typings/di/provider_token.d.ts +17 -0
  50. package/import/typings/di/r3_injector.d.ts +92 -0
  51. package/import/typings/di/scope.d.ts +14 -0
  52. package/import/typings/index.d.ts +11 -0
  53. package/import/typings/interface/lifecycle_hooks.d.ts +28 -0
  54. package/import/typings/interface/type.d.ts +21 -0
  55. package/import/typings/render3/definition_factory.d.ts +24 -0
  56. package/import/typings/render3/error_code.d.ts +24 -0
  57. package/import/typings/render3/errors_di.d.ts +2 -0
  58. package/import/typings/render3/fields.d.ts +8 -0
  59. package/import/typings/render3/instructions/di.d.ts +20 -0
  60. package/import/typings/render3/util/stringify_utils.d.ts +20 -0
  61. package/import/typings/util/array_utils.d.ts +10 -0
  62. package/import/typings/util/closure.d.ts +17 -0
  63. package/import/typings/util/decorators.d.ts +27 -0
  64. package/import/typings/util/empty.d.ts +14 -0
  65. package/import/typings/util/property.d.ts +8 -0
  66. package/import/typings/util/stringify.d.ts +8 -0
  67. package/package.json +34 -0
  68. package/readme.md +27 -0
  69. package/transform/compiler/index.d.ts +5 -0
  70. package/transform/compiler/index.js +17 -0
  71. package/transform/compiler/src/core.d.ts +19 -0
  72. package/transform/compiler/src/core.js +9 -0
  73. package/transform/compiler/src/injectable_compiler_2.d.ts +53 -0
  74. package/transform/compiler/src/injectable_compiler_2.js +159 -0
  75. package/transform/compiler/src/output/output_ast.d.ts +534 -0
  76. package/transform/compiler/src/output/output_ast.js +986 -0
  77. package/transform/compiler/src/parse_util.d.ts +50 -0
  78. package/transform/compiler/src/parse_util.js +61 -0
  79. package/transform/compiler/src/render3/partial/api.d.ts +166 -0
  80. package/transform/compiler/src/render3/partial/api.js +11 -0
  81. package/transform/compiler/src/render3/partial/util.d.ts +16 -0
  82. package/transform/compiler/src/render3/partial/util.js +44 -0
  83. package/transform/compiler/src/render3/r3_factory.d.ts +97 -0
  84. package/transform/compiler/src/render3/r3_factory.js +239 -0
  85. package/transform/compiler/src/render3/r3_identifiers.d.ts +20 -0
  86. package/transform/compiler/src/render3/r3_identifiers.js +51 -0
  87. package/transform/compiler/src/render3/util.d.ts +21 -0
  88. package/transform/compiler/src/render3/util.js +41 -0
  89. package/transform/compiler/src/render3/view/util.d.ts +30 -0
  90. package/transform/compiler/src/render3/view/util.js +57 -0
  91. package/transform/compiler-cli/src/ngtsc/annotations/src/factory.d.ts +11 -0
  92. package/transform/compiler-cli/src/ngtsc/annotations/src/factory.js +21 -0
  93. package/transform/compiler-cli/src/ngtsc/annotations/src/injectable.d.ts +42 -0
  94. package/transform/compiler-cli/src/ngtsc/annotations/src/injectable.js +278 -0
  95. package/transform/compiler-cli/src/ngtsc/annotations/src/util.d.ts +91 -0
  96. package/transform/compiler-cli/src/ngtsc/annotations/src/util.js +370 -0
  97. package/transform/compiler-cli/src/ngtsc/diagnostics/error.d.ts +24 -0
  98. package/transform/compiler-cli/src/ngtsc/diagnostics/error.js +76 -0
  99. package/transform/compiler-cli/src/ngtsc/diagnostics/error_code.d.ts +188 -0
  100. package/transform/compiler-cli/src/ngtsc/diagnostics/error_code.js +206 -0
  101. package/transform/compiler-cli/src/ngtsc/diagnostics/index.d.ts +2 -0
  102. package/transform/compiler-cli/src/ngtsc/diagnostics/index.js +14 -0
  103. package/transform/compiler-cli/src/ngtsc/imports/index.d.ts +1 -0
  104. package/transform/compiler-cli/src/ngtsc/imports/index.js +13 -0
  105. package/transform/compiler-cli/src/ngtsc/imports/src/core.d.ts +36 -0
  106. package/transform/compiler-cli/src/ngtsc/imports/src/core.js +25 -0
  107. package/transform/compiler-cli/src/ngtsc/reflection/index.d.ts +3 -0
  108. package/transform/compiler-cli/src/ngtsc/reflection/index.js +15 -0
  109. package/transform/compiler-cli/src/ngtsc/reflection/src/host.d.ts +667 -0
  110. package/transform/compiler-cli/src/ngtsc/reflection/src/host.js +98 -0
  111. package/transform/compiler-cli/src/ngtsc/reflection/src/type_to_value.d.ts +24 -0
  112. package/transform/compiler-cli/src/ngtsc/reflection/src/type_to_value.js +271 -0
  113. package/transform/compiler-cli/src/ngtsc/reflection/src/typescript.d.ts +50 -0
  114. package/transform/compiler-cli/src/ngtsc/reflection/src/typescript.js +396 -0
  115. package/transform/compiler-cli/src/ngtsc/reflection/src/util.d.ts +12 -0
  116. package/transform/compiler-cli/src/ngtsc/reflection/src/util.js +45 -0
  117. package/transform/compiler-cli/src/ngtsc/transform/index.d.ts +2 -0
  118. package/transform/compiler-cli/src/ngtsc/transform/index.js +14 -0
  119. package/transform/compiler-cli/src/ngtsc/transform/src/api.d.ts +115 -0
  120. package/transform/compiler-cli/src/ngtsc/transform/src/api.js +30 -0
  121. package/transform/compiler-cli/src/ngtsc/transform/src/utils.d.ts +15 -0
  122. package/transform/compiler-cli/src/ngtsc/transform/src/utils.js +84 -0
  123. package/transform/compiler-cli/src/ngtsc/translator/index.d.ts +5 -0
  124. package/transform/compiler-cli/src/ngtsc/translator/index.js +17 -0
  125. package/transform/compiler-cli/src/ngtsc/translator/src/api/ast_factory.d.ts +274 -0
  126. package/transform/compiler-cli/src/ngtsc/translator/src/api/ast_factory.js +9 -0
  127. package/transform/compiler-cli/src/ngtsc/translator/src/api/import_generator.d.ts +27 -0
  128. package/transform/compiler-cli/src/ngtsc/translator/src/api/import_generator.js +9 -0
  129. package/transform/compiler-cli/src/ngtsc/translator/src/context.d.ts +18 -0
  130. package/transform/compiler-cli/src/ngtsc/translator/src/context.js +27 -0
  131. package/transform/compiler-cli/src/ngtsc/translator/src/import_manager.d.ts +29 -0
  132. package/transform/compiler-cli/src/ngtsc/translator/src/import_manager.js +70 -0
  133. package/transform/compiler-cli/src/ngtsc/translator/src/translator.d.ts +58 -0
  134. package/transform/compiler-cli/src/ngtsc/translator/src/translator.js +270 -0
  135. package/transform/compiler-cli/src/ngtsc/translator/src/typescript_ast_factory.d.ts +54 -0
  136. package/transform/compiler-cli/src/ngtsc/translator/src/typescript_ast_factory.js +245 -0
  137. package/transform/compiler-cli/src/ngtsc/translator/src/typescript_translator.d.ts +13 -0
  138. package/transform/compiler-cli/src/ngtsc/translator/src/typescript_translator.js +21 -0
  139. package/transform/compiler-cli/src/ngtsc/util/src/typescript.d.ts +11 -0
  140. package/transform/compiler-cli/src/ngtsc/util/src/typescript.js +39 -0
  141. package/transform/index.d.ts +1 -0
  142. package/transform/index.js +13 -0
  143. package/transform/injectable-transform.d.ts +41 -0
  144. package/transform/injectable-transform.js +195 -0
  145. package/transform/node-Iteration.d.ts +2 -0
  146. package/transform/node-Iteration.js +12 -0
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ /**
3
+ * @license
4
+ * Copyright Google LLC All Rights Reserved.
5
+ *
6
+ * Use of this source code is governed by an MIT-style license that can be
7
+ * found in the LICENSE file at https://angular.io/license
8
+ */
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.NoopImportRewriter = void 0;
11
+ /**
12
+ * `ImportRewriter` that does no rewriting.
13
+ */
14
+ class NoopImportRewriter {
15
+ shouldImportSymbol(symbol, specifier) {
16
+ return true;
17
+ }
18
+ rewriteSymbol(symbol, specifier) {
19
+ return symbol;
20
+ }
21
+ rewriteSpecifier(specifier, inContextOfFile) {
22
+ return specifier;
23
+ }
24
+ }
25
+ exports.NoopImportRewriter = NoopImportRewriter;
@@ -0,0 +1,3 @@
1
+ export * from "./src/host";
2
+ export * from "./src/typescript";
3
+ export * from "./src/util";
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ }) : (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ o[k2] = m[k];
8
+ }));
9
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
10
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
11
+ };
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ __exportStar(require("./src/host"), exports);
14
+ __exportStar(require("./src/typescript"), exports);
15
+ __exportStar(require("./src/util"), exports);
@@ -0,0 +1,667 @@
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 * as ts from 'typescript';
9
+ /**
10
+ * Metadata extracted from an instance of a decorator on another declaration, or synthesized from
11
+ * other information about a class.
12
+ */
13
+ export declare type Decorator = ConcreteDecorator | SyntheticDecorator;
14
+ export interface BaseDecorator {
15
+ /**
16
+ * Name by which the decorator was invoked in the user's code.
17
+ *
18
+ * This is distinct from the name by which the decorator was imported (though in practice they
19
+ * will usually be the same).
20
+ */
21
+ name: string;
22
+ /**
23
+ * Identifier which refers to the decorator in the user's code.
24
+ */
25
+ identifier: DecoratorIdentifier | null;
26
+ /**
27
+ * `Import` by which the decorator was brought into the module in which it was invoked, or `null`
28
+ * if the decorator was declared in the same module and not imported.
29
+ */
30
+ import: Import | null;
31
+ /**
32
+ * TypeScript reference to the decorator itself, or `null` if the decorator is synthesized (e.g.
33
+ * in ngcc).
34
+ */
35
+ node: ts.Node | null;
36
+ /**
37
+ * Arguments of the invocation of the decorator, if the decorator is invoked, or `null`
38
+ * otherwise.
39
+ */
40
+ args: ts.Expression[] | null;
41
+ }
42
+ /**
43
+ * Metadata extracted from an instance of a decorator on another declaration, which was actually
44
+ * present in a file.
45
+ *
46
+ * Concrete decorators always have an `identifier` and a `node`.
47
+ */
48
+ export interface ConcreteDecorator extends BaseDecorator {
49
+ identifier: DecoratorIdentifier;
50
+ node: ts.Node;
51
+ }
52
+ /**
53
+ * Synthetic decorators never have an `identifier` or a `node`, but know the node for which they
54
+ * were synthesized.
55
+ */
56
+ export interface SyntheticDecorator extends BaseDecorator {
57
+ identifier: null;
58
+ node: null;
59
+ /**
60
+ * The `ts.Node` for which this decorator was created.
61
+ */
62
+ synthesizedFor: ts.Node;
63
+ }
64
+ export declare const Decorator: {
65
+ nodeForError: (decorator: Decorator) => ts.Node;
66
+ };
67
+ /**
68
+ * A decorator is identified by either a simple identifier (e.g. `Decorator`) or, in some cases,
69
+ * a namespaced property access (e.g. `core.Decorator`).
70
+ */
71
+ export declare type DecoratorIdentifier = ts.Identifier | NamespacedIdentifier;
72
+ export declare type NamespacedIdentifier = ts.PropertyAccessExpression & {
73
+ expression: ts.Identifier;
74
+ name: ts.Identifier;
75
+ };
76
+ /** 装饰器可能是 Injectable或者xx.Injectable */
77
+ export declare function isDecoratorIdentifier(exp: ts.Expression): exp is DecoratorIdentifier;
78
+ /**
79
+ * The `ts.Declaration` of a "class".
80
+ *
81
+ * Classes are represented differently in different code formats:
82
+ * - In TS code, they are typically defined using the `class` keyword.
83
+ * - In ES2015 code, they are usually defined using the `class` keyword, but they can also be
84
+ * variable declarations, which are initialized to a class expression (e.g.
85
+ * `let Foo = Foo1 = class Foo {}`).
86
+ * - In ES5 code, they are typically defined as variable declarations being assigned the return
87
+ * value of an IIFE. The actual "class" is implemented as a constructor function inside the IIFE,
88
+ * but the outer variable declaration represents the "class" to the rest of the program.
89
+ *
90
+ * For `ReflectionHost` purposes, a class declaration should always have a `name` identifier,
91
+ * because we need to be able to reference it in other parts of the program.
92
+ */
93
+ export declare type ClassDeclaration<T extends DeclarationNode = DeclarationNode> = T & {
94
+ name: ts.Identifier;
95
+ };
96
+ /**
97
+ * An enumeration of possible kinds of class members.
98
+ */
99
+ export declare enum ClassMemberKind {
100
+ Constructor = 0,
101
+ Getter = 1,
102
+ Setter = 2,
103
+ Property = 3,
104
+ Method = 4
105
+ }
106
+ /**
107
+ * A member of a class, such as a property, method, or constructor.
108
+ */
109
+ export interface ClassMember {
110
+ /**
111
+ * TypeScript reference to the class member itself, or null if it is not applicable.
112
+ */
113
+ node: ts.Node | null;
114
+ /**
115
+ * Indication of which type of member this is (property, method, etc).
116
+ */
117
+ kind: ClassMemberKind;
118
+ /**
119
+ * TypeScript `ts.TypeNode` representing the type of the member, or `null` if not present or
120
+ * applicable.
121
+ */
122
+ type: ts.TypeNode | null;
123
+ /**
124
+ * Name of the class member.
125
+ */
126
+ name: string;
127
+ /**
128
+ * TypeScript `ts.Identifier` or `ts.StringLiteral` representing the name of the member, or `null`
129
+ * if no such node is present.
130
+ *
131
+ * The `nameNode` is useful in writing references to this member that will be correctly source-
132
+ * mapped back to the original file.
133
+ */
134
+ nameNode: ts.Identifier | ts.StringLiteral | null;
135
+ /**
136
+ * TypeScript `ts.Expression` which represents the value of the member.
137
+ *
138
+ * If the member is a property, this will be the property initializer if there is one, or null
139
+ * otherwise.
140
+ */
141
+ value: ts.Expression | null;
142
+ /**
143
+ * TypeScript `ts.Declaration` which represents the implementation of the member.
144
+ *
145
+ * In TypeScript code this is identical to the node, but in downleveled code this should always be
146
+ * the Declaration which actually represents the member's runtime value.
147
+ *
148
+ * For example, the TS code:
149
+ *
150
+ * ```
151
+ * class Clazz {
152
+ * static get property(): string {
153
+ * return 'value';
154
+ * }
155
+ * }
156
+ * ```
157
+ *
158
+ * Downlevels to:
159
+ *
160
+ * ```
161
+ * var Clazz = (function () {
162
+ * function Clazz() {
163
+ * }
164
+ * Object.defineProperty(Clazz, "property", {
165
+ * get: function () {
166
+ * return 'value';
167
+ * },
168
+ * enumerable: true,
169
+ * configurable: true
170
+ * });
171
+ * return Clazz;
172
+ * }());
173
+ * ```
174
+ *
175
+ * In this example, for the property "property", the node would be the entire
176
+ * Object.defineProperty ExpressionStatement, but the implementation would be this
177
+ * FunctionDeclaration:
178
+ *
179
+ * ```
180
+ * function () {
181
+ * return 'value';
182
+ * },
183
+ * ```
184
+ */
185
+ implementation: ts.Declaration | null;
186
+ /**
187
+ * Whether the member is static or not.
188
+ */
189
+ isStatic: boolean;
190
+ /**
191
+ * Any `Decorator`s which are present on the member, or `null` if none are present.
192
+ */
193
+ decorators: Decorator[] | null;
194
+ }
195
+ export declare const enum TypeValueReferenceKind {
196
+ LOCAL = 0,
197
+ IMPORTED = 1,
198
+ UNAVAILABLE = 2
199
+ }
200
+ /**
201
+ * A type reference that refers to any type via a `ts.Expression` that's valid within the local file
202
+ * where the type was referenced.
203
+ */
204
+ export interface LocalTypeValueReference {
205
+ kind: TypeValueReferenceKind.LOCAL;
206
+ /**
207
+ * The synthesized expression to reference the type in a value position.
208
+ */
209
+ expression: ts.Expression;
210
+ /**
211
+ * If the type originates from a default import, the import statement is captured here to be able
212
+ * to track its usages, preventing the import from being elided if it was originally only used in
213
+ * a type-position. See `DefaultImportTracker` for details.
214
+ */
215
+ defaultImportStatement: ts.ImportDeclaration | null;
216
+ }
217
+ /**
218
+ * A reference that refers to a type that was imported, and gives the symbol `name` and the
219
+ * `moduleName` of the import. Note that this `moduleName` may be a relative path, and thus is
220
+ * likely only valid within the context of the file which contained the original type reference.
221
+ */
222
+ export interface ImportedTypeValueReference {
223
+ kind: TypeValueReferenceKind.IMPORTED;
224
+ /**
225
+ * The module specifier from which the `importedName` symbol should be imported.
226
+ */
227
+ moduleName: string;
228
+ /**
229
+ * The name of the top-level symbol that is imported from `moduleName`. If `nestedPath` is also
230
+ * present, a nested object is being referenced from the top-level symbol.
231
+ */
232
+ importedName: string;
233
+ /**
234
+ * If present, represents the symbol names that are referenced from the top-level import.
235
+ * When `null` or empty, the `importedName` itself is the symbol being referenced.
236
+ */
237
+ nestedPath: string[] | null;
238
+ valueDeclaration: DeclarationNode;
239
+ }
240
+ /**
241
+ * A representation for a type value reference that is used when no value is available. This can
242
+ * occur due to various reasons, which is indicated in the `reason` field.
243
+ */
244
+ export interface UnavailableTypeValueReference {
245
+ kind: TypeValueReferenceKind.UNAVAILABLE;
246
+ /**
247
+ * The reason why no value reference could be determined for a type.
248
+ */
249
+ reason: UnavailableValue;
250
+ }
251
+ /**
252
+ * The various reasons why the compiler may be unable to synthesize a value from a type reference.
253
+ */
254
+ export declare const enum ValueUnavailableKind {
255
+ /**
256
+ * No type node was available.
257
+ */
258
+ MISSING_TYPE = 0,
259
+ /**
260
+ * The type does not have a value declaration, e.g. an interface.
261
+ */
262
+ NO_VALUE_DECLARATION = 1,
263
+ /**
264
+ * The type is imported using a type-only imports, so it is not suitable to be used in a
265
+ * value-position.
266
+ */
267
+ TYPE_ONLY_IMPORT = 2,
268
+ /**
269
+ * The type reference could not be resolved to a declaration.
270
+ */
271
+ UNKNOWN_REFERENCE = 3,
272
+ /**
273
+ * The type corresponds with a namespace.
274
+ */
275
+ NAMESPACE = 4,
276
+ /**
277
+ * The type is not supported in the compiler, for example union types.
278
+ */
279
+ UNSUPPORTED = 5
280
+ }
281
+ export interface UnsupportedType {
282
+ kind: ValueUnavailableKind.UNSUPPORTED;
283
+ typeNode: ts.TypeNode;
284
+ }
285
+ export interface NoValueDeclaration {
286
+ kind: ValueUnavailableKind.NO_VALUE_DECLARATION;
287
+ typeNode: ts.TypeNode;
288
+ decl: ts.Declaration | null;
289
+ }
290
+ export interface TypeOnlyImport {
291
+ kind: ValueUnavailableKind.TYPE_ONLY_IMPORT;
292
+ typeNode: ts.TypeNode;
293
+ importClause: ts.ImportClause;
294
+ }
295
+ export interface NamespaceImport {
296
+ kind: ValueUnavailableKind.NAMESPACE;
297
+ typeNode: ts.TypeNode;
298
+ importClause: ts.ImportClause;
299
+ }
300
+ export interface UnknownReference {
301
+ kind: ValueUnavailableKind.UNKNOWN_REFERENCE;
302
+ typeNode: ts.TypeNode;
303
+ }
304
+ export interface MissingType {
305
+ kind: ValueUnavailableKind.MISSING_TYPE;
306
+ }
307
+ /**
308
+ * The various reasons why a type node may not be referred to as a value.
309
+ */
310
+ export declare type UnavailableValue = UnsupportedType | NoValueDeclaration | TypeOnlyImport | NamespaceImport | UnknownReference | MissingType;
311
+ /**
312
+ * A reference to a value that originated from a type position.
313
+ *
314
+ * For example, a constructor parameter could be declared as `foo: Foo`. A `TypeValueReference`
315
+ * extracted from this would refer to the value of the class `Foo` (assuming it was actually a
316
+ * type).
317
+ *
318
+ * See the individual types for additional information.
319
+ */
320
+ export declare type TypeValueReference = LocalTypeValueReference | ImportedTypeValueReference | UnavailableTypeValueReference;
321
+ /**
322
+ * A parameter to a constructor.
323
+ */
324
+ export interface CtorParameter {
325
+ /**
326
+ * Name of the parameter, if available.
327
+ *
328
+ * Some parameters don't have a simple string name (for example, parameters which are destructured
329
+ * into multiple variables). In these cases, `name` can be `null`.
330
+ */
331
+ name: string | null;
332
+ /**
333
+ * TypeScript `ts.BindingName` representing the name of the parameter.
334
+ *
335
+ * The `nameNode` is useful in writing references to this member that will be correctly source-
336
+ * mapped back to the original file.
337
+ */
338
+ nameNode: ts.BindingName;
339
+ /**
340
+ * Reference to the value of the parameter's type annotation, if it's possible to refer to the
341
+ * parameter's type as a value.
342
+ *
343
+ * This can either be a reference to a local value, a reference to an imported value, or no
344
+ * value if no is present or cannot be represented as an expression.
345
+ */
346
+ typeValueReference: TypeValueReference;
347
+ /**
348
+ * TypeScript `ts.TypeNode` representing the type node found in the type position.
349
+ *
350
+ * This field can be used for diagnostics reporting if `typeValueReference` is `null`.
351
+ *
352
+ * Can be null, if the param has no type declared.
353
+ */
354
+ typeNode: ts.TypeNode | null;
355
+ /**
356
+ * Any `Decorator`s which are present on the parameter, or `null` if none are present.
357
+ */
358
+ decorators: Decorator[] | null;
359
+ }
360
+ /**
361
+ * Definition of a function or method, including its body if present and any parameters.
362
+ *
363
+ * In TypeScript code this metadata will be a simple reflection of the declarations in the node
364
+ * itself. In ES5 code this can be more complicated, as the default values for parameters may
365
+ * be extracted from certain body statements.
366
+ */
367
+ export interface FunctionDefinition {
368
+ /**
369
+ * A reference to the node which declares the function.
370
+ */
371
+ node: ts.MethodDeclaration | ts.FunctionDeclaration | ts.FunctionExpression | ts.VariableDeclaration;
372
+ /**
373
+ * Statements of the function body, if a body is present, or null if no body is present or the
374
+ * function is identified to represent a tslib helper function, in which case `helper` will
375
+ * indicate which helper this function represents.
376
+ *
377
+ * This list may have been filtered to exclude statements which perform parameter default value
378
+ * initialization.
379
+ */
380
+ body: ts.Statement[] | null;
381
+ /**
382
+ * Metadata regarding the function's parameters, including possible default value expressions.
383
+ */
384
+ parameters: Parameter[];
385
+ }
386
+ /**
387
+ * Possible declarations of known values, such as built-in objects/functions or TypeScript helpers.
388
+ */
389
+ export declare enum KnownDeclaration {
390
+ /**
391
+ * Indicates the JavaScript global `Object` class.
392
+ */
393
+ JsGlobalObject = 0,
394
+ /**
395
+ * Indicates the `__assign` TypeScript helper function.
396
+ */
397
+ TsHelperAssign = 1,
398
+ /**
399
+ * Indicates the `__spread` TypeScript helper function.
400
+ */
401
+ TsHelperSpread = 2,
402
+ /**
403
+ * Indicates the `__spreadArrays` TypeScript helper function.
404
+ */
405
+ TsHelperSpreadArrays = 3,
406
+ /**
407
+ * Indicates the `__spreadArray` TypeScript helper function.
408
+ */
409
+ TsHelperSpreadArray = 4,
410
+ /**
411
+ * Indicates the `__read` TypeScript helper function.
412
+ */
413
+ TsHelperRead = 5
414
+ }
415
+ /**
416
+ * A parameter to a function or method.
417
+ */
418
+ export interface Parameter {
419
+ /**
420
+ * Name of the parameter, if available.
421
+ */
422
+ name: string | null;
423
+ /**
424
+ * Declaration which created this parameter.
425
+ */
426
+ node: ts.ParameterDeclaration;
427
+ /**
428
+ * Expression which represents the default value of the parameter, if any.
429
+ */
430
+ initializer: ts.Expression | null;
431
+ }
432
+ /**
433
+ * The source of an imported symbol, including the original symbol name and the module from which it
434
+ * was imported.
435
+ */
436
+ export interface Import {
437
+ /**
438
+ * The name of the imported symbol under which it was exported (not imported).
439
+ */
440
+ name: string;
441
+ /**
442
+ * The module from which the symbol was imported.
443
+ *
444
+ * This could either be an absolute module name (static-injector for example) or a relative path.
445
+ */
446
+ from: string;
447
+ }
448
+ /**
449
+ * A single enum member extracted from JavaScript when no `ts.EnumDeclaration` is available.
450
+ */
451
+ export interface EnumMember {
452
+ /**
453
+ * The name of the enum member.
454
+ */
455
+ name: ts.PropertyName;
456
+ /**
457
+ * The initializer expression of the enum member. Unlike in TypeScript, this is always available
458
+ * in emitted JavaScript.
459
+ */
460
+ initializer: ts.Expression;
461
+ }
462
+ /**
463
+ * A type that is used to identify a declaration.
464
+ *
465
+ * Declarations are normally `ts.Declaration` types such as variable declarations, class
466
+ * declarations, function declarations etc.
467
+ * But in some cases there is no `ts.Declaration` that can be used for a declaration, such
468
+ * as when they are declared inline as part of an exported expression. Then we must use a
469
+ * `ts.Expression` as the declaration.
470
+ * An example of this is `exports.someVar = 42` where the declaration expression would be
471
+ * `exports.someVar`.
472
+ */
473
+ export declare type DeclarationNode = ts.Declaration | ts.Expression;
474
+ /**
475
+ * The type of a Declaration - whether its node is concrete (ts.Declaration) or inline
476
+ * (ts.Expression). See `ConcreteDeclaration`, `InlineDeclaration` and `DeclarationNode` for more
477
+ * information about this.
478
+ */
479
+ export declare const enum DeclarationKind {
480
+ Concrete = 0,
481
+ Inline = 1
482
+ }
483
+ /**
484
+ * Base type for all `Declaration`s.
485
+ */
486
+ export interface BaseDeclaration<T extends DeclarationNode> {
487
+ /**
488
+ * The type of the underlying `node`.
489
+ */
490
+ kind: DeclarationKind;
491
+ /**
492
+ * The absolute module path from which the symbol was imported into the application, if the symbol
493
+ * was imported via an absolute module (even through a chain of re-exports). If the symbol is part
494
+ * of the application and was not imported from an absolute path, this will be `null`.
495
+ */
496
+ viaModule: string | null;
497
+ /**
498
+ * TypeScript reference to the declaration itself, if one exists.
499
+ */
500
+ node: T;
501
+ /**
502
+ * If set, describes the type of the known declaration this declaration resolves to.
503
+ */
504
+ known: KnownDeclaration | null;
505
+ }
506
+ /**
507
+ * Returns true if the `decl` is a `ConcreteDeclaration` (ie. that its `node` property is a
508
+ * `ts.Declaration`).
509
+ */
510
+ export declare function isConcreteDeclaration(decl: Declaration): decl is ConcreteDeclaration;
511
+ export interface ConcreteDeclaration<T extends ts.Declaration = ts.Declaration> extends BaseDeclaration<T> {
512
+ kind: DeclarationKind.Concrete;
513
+ /**
514
+ * Optionally represents a special identity of the declaration, or `null` if the declaration
515
+ * does not have a special identity.
516
+ */
517
+ identity: SpecialDeclarationIdentity | null;
518
+ }
519
+ export declare type SpecialDeclarationIdentity = DownleveledEnum;
520
+ export declare const enum SpecialDeclarationKind {
521
+ DownleveledEnum = 0
522
+ }
523
+ /**
524
+ * A special declaration identity that represents an enum. This is used in downleveled forms where
525
+ * a `ts.EnumDeclaration` is emitted in an alternative form, e.g. an IIFE call that declares all
526
+ * members.
527
+ */
528
+ export interface DownleveledEnum {
529
+ kind: SpecialDeclarationKind.DownleveledEnum;
530
+ enumMembers: EnumMember[];
531
+ }
532
+ /**
533
+ * A declaration that does not have an associated TypeScript `ts.Declaration`.
534
+ *
535
+ * This can occur in some downlevelings when an `export const VAR = ...;` (a `ts.Declaration`) is
536
+ * transpiled to an assignment statement (e.g. `exports.VAR = ...;`). There is no `ts.Declaration`
537
+ * associated with `VAR` in that case, only an expression.
538
+ */
539
+ export interface InlineDeclaration extends BaseDeclaration<Exclude<DeclarationNode, ts.Declaration>> {
540
+ kind: DeclarationKind.Inline;
541
+ implementation?: DeclarationNode;
542
+ }
543
+ /**
544
+ * The declaration of a symbol, along with information about how it was imported into the
545
+ * application.
546
+ */
547
+ export declare type Declaration<T extends ts.Declaration = ts.Declaration> = ConcreteDeclaration<T> | InlineDeclaration;
548
+ /**
549
+ * Abstracts reflection operations on a TypeScript AST.
550
+ *
551
+ * Depending on the format of the code being interpreted, different concepts are represented
552
+ * with different syntactical structures. The `ReflectionHost` abstracts over those differences and
553
+ * presents a single API by which the compiler can query specific information about the AST.
554
+ *
555
+ * All operations on the `ReflectionHost` require the use of TypeScript `ts.Node`s with binding
556
+ * information already available (that is, nodes that come from a `ts.Program` that has been
557
+ * type-checked, and are not synthetically created).
558
+ */
559
+ export interface ReflectionHost {
560
+ /**
561
+ * Examine a declaration (for example, of a class or function) and return metadata about any
562
+ * decorators present on the declaration.
563
+ *
564
+ * @param declaration a TypeScript `ts.Declaration` node representing the class or function over
565
+ * which to reflect. For example, if the intent is to reflect the decorators of a class and the
566
+ * source is in ES6 format, this will be a `ts.ClassDeclaration` node. If the source is in ES5
567
+ * format, this might be a `ts.VariableDeclaration` as classes in ES5 are represented as the
568
+ * result of an IIFE execution.
569
+ *
570
+ * @returns an array of `Decorator` metadata if decorators are present on the declaration, or
571
+ * `null` if either no decorators were present or if the declaration is not of a decoratable type.
572
+ */
573
+ getDecoratorsOfDeclaration(declaration: DeclarationNode): Decorator[] | null;
574
+ /**
575
+ * Examine a declaration which should be of a class, and return metadata about the members of the
576
+ * class.
577
+ *
578
+ * @param clazz a `ClassDeclaration` representing the class over which to reflect.
579
+ *
580
+ * @returns an array of `ClassMember` metadata representing the members of the class.
581
+ *
582
+ * @throws if `declaration` does not resolve to a class declaration.
583
+ */
584
+ getMembersOfClass(clazz: ClassDeclaration): ClassMember[];
585
+ /**
586
+ * Reflect over the constructor of a class and return metadata about its parameters.
587
+ *
588
+ * This method only looks at the constructor of a class directly and not at any inherited
589
+ * constructors.
590
+ *
591
+ * @param clazz a `ClassDeclaration` representing the class over which to reflect.
592
+ *
593
+ * @returns an array of `Parameter` metadata representing the parameters of the constructor, if
594
+ * a constructor exists. If the constructor exists and has 0 parameters, this array will be empty.
595
+ * If the class has no constructor, this method returns `null`.
596
+ */
597
+ getConstructorParameters(clazz: ClassDeclaration): CtorParameter[] | null;
598
+ /**
599
+ * Determine if an identifier was imported from another module and return `Import` metadata
600
+ * describing its origin.
601
+ *
602
+ * @param id a TypeScript `ts.Identifer` to reflect.
603
+ *
604
+ * @returns metadata about the `Import` if the identifier was imported from another module, or
605
+ * `null` if the identifier doesn't resolve to an import but instead is locally defined.
606
+ */
607
+ getImportOfIdentifier(id: ts.Identifier): Import | null;
608
+ /**
609
+ * Check whether the given node actually represents a class.
610
+ */
611
+ isClass(node: ts.Node): node is ClassDeclaration;
612
+ /**
613
+ * Determines whether the given declaration, which should be a class, has a base class.
614
+ *
615
+ * @param clazz a `ClassDeclaration` representing the class over which to reflect.
616
+ */
617
+ hasBaseClass(clazz: ClassDeclaration): boolean;
618
+ /**
619
+ * Get an expression representing the base class (if any) of the given `clazz`.
620
+ *
621
+ * This expression is most commonly an Identifier, but is possible to inherit from a more dynamic
622
+ * expression.
623
+ *
624
+ * @param clazz the class whose base we want to get.
625
+ */
626
+ getBaseClassExpression(clazz: ClassDeclaration): ts.Expression | null;
627
+ /**
628
+ * Get the number of generic type parameters of a given class.
629
+ *
630
+ * @param clazz a `ClassDeclaration` representing the class over which to reflect.
631
+ *
632
+ * @returns the number of type parameters of the class, if known, or `null` if the declaration
633
+ * is not a class or has an unknown number of type parameters.
634
+ */
635
+ getGenericArityOfClass(clazz: ClassDeclaration): number | null;
636
+ /**
637
+ * Take an exported declaration (maybe a class down-leveled to a variable) and look up the
638
+ * declaration of its type in a separate .d.ts tree.
639
+ *
640
+ * This function is allowed to return `null` if the current compilation unit does not have a
641
+ * separate .d.ts tree. When compiling TypeScript code this is always the case, since .d.ts files
642
+ * are produced only during the emit of such a compilation. When compiling .js code, however,
643
+ * there is frequently a parallel .d.ts tree which this method exposes.
644
+ *
645
+ * Note that the `ts.Declaration` returned from this function may not be from the same
646
+ * `ts.Program` as the input declaration.
647
+ */
648
+ getDtsDeclaration(declaration: DeclarationNode): ts.Declaration | null;
649
+ /**
650
+ * Get a `ts.Identifier` for a given `ClassDeclaration` which can be used to refer to the class
651
+ * within its definition (such as in static fields).
652
+ *
653
+ * This can differ from `clazz.name` when ngcc runs over ES5 code, since the class may have a
654
+ * different name within its IIFE wrapper than it does externally.
655
+ */
656
+ getInternalNameOfClass(clazz: ClassDeclaration): ts.Identifier;
657
+ /**
658
+ * Get a `ts.Identifier` for a given `ClassDeclaration` which can be used to refer to the class
659
+ * from statements that are "adjacent", and conceptually tightly bound, to the class but not
660
+ * actually inside it.
661
+ *
662
+ * Similar to `getInternalNameOfClass()`, this name can differ from `clazz.name` when ngcc runs
663
+ * over ES5 code, since these "adjacent" statements need to exist in the IIFE where the class may
664
+ * have a different name than it does externally.
665
+ */
666
+ getAdjacentNameOfClass(clazz: ClassDeclaration): ts.Identifier;
667
+ }