static-injector 4.0.2 → 5.0.0-alpha.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.
Files changed (179) hide show
  1. package/{import/commonjs → commonjs}/index.js +29 -197
  2. package/{import/es2022 → es2022}/di/interface/defs.js +5 -1
  3. package/{import/es2022 → es2022}/index.js +0 -1
  4. package/{transform/compiler/index.d.ts → es2022/interface/lifecycle_hooks.js} +1 -1
  5. package/{transform/compiler-cli/src/ngtsc/translator/src/api/ast_factory.js → es2022/render3/definition_factory.js} +3 -2
  6. package/es2022/util/decorators.js +31 -0
  7. package/{import/fesm2022 → fesm2022}/index.js +30 -196
  8. package/package.json +17 -14
  9. package/readme.md +32 -12
  10. package/{import/typings → typings}/di/injectable.d.ts +0 -7
  11. package/{import/typings → typings}/index.d.ts +0 -1
  12. package/import/es2022/di/injectable.js +0 -14
  13. package/import/es2022/error_details_base_url.js +0 -19
  14. package/import/es2022/render3/definition_factory.js +0 -14
  15. package/import/es2022/render3/di.js +0 -49
  16. package/import/es2022/render3/error_code.js +0 -30
  17. package/import/es2022/util/array_utils.js +0 -17
  18. package/import/es2022/util/decorators.js +0 -53
  19. package/import/typings/error_details_base_url.d.ts +0 -19
  20. package/import/typings/render3/di.d.ts +0 -12
  21. package/import/typings/render3/error_code.d.ts +0 -24
  22. package/import/typings/util/array_utils.d.ts +0 -25
  23. package/transform/compiler/compiler.d.ts +0 -8
  24. package/transform/compiler/compiler.js +0 -28
  25. package/transform/compiler/index.js +0 -28
  26. package/transform/compiler/public_api.d.ts +0 -13
  27. package/transform/compiler/public_api.js +0 -30
  28. package/transform/compiler/src/compiler.d.ts +0 -5
  29. package/transform/compiler/src/compiler.js +0 -21
  30. package/transform/compiler/src/core.d.ts +0 -25
  31. package/transform/compiler/src/core.js +0 -22
  32. package/transform/compiler/src/injectable_compiler_2.d.ts +0 -23
  33. package/transform/compiler/src/injectable_compiler_2.js +0 -171
  34. package/transform/compiler/src/output/output_ast.d.ts +0 -512
  35. package/transform/compiler/src/output/output_ast.js +0 -1109
  36. package/transform/compiler/src/parse_util.d.ts +0 -50
  37. package/transform/compiler/src/parse_util.js +0 -71
  38. package/transform/compiler/src/render3/partial/api.d.ts +0 -171
  39. package/transform/compiler/src/render3/partial/api.js +0 -18
  40. package/transform/compiler/src/render3/r3_factory.d.ts +0 -82
  41. package/transform/compiler/src/render3/r3_factory.js +0 -225
  42. package/transform/compiler/src/render3/r3_identifiers.d.ts +0 -20
  43. package/transform/compiler/src/render3/r3_identifiers.js +0 -55
  44. package/transform/compiler/src/render3/util.d.ts +0 -85
  45. package/transform/compiler/src/render3/util.js +0 -82
  46. package/transform/compiler/src/render3/view/util.d.ts +0 -24
  47. package/transform/compiler/src/render3/view/util.js +0 -59
  48. package/transform/compiler-cli/src/ngtsc/annotations/common/index.d.ts +0 -3
  49. package/transform/compiler-cli/src/ngtsc/annotations/common/index.js +0 -19
  50. package/transform/compiler-cli/src/ngtsc/annotations/common/src/di.d.ts +0 -37
  51. package/transform/compiler-cli/src/ngtsc/annotations/common/src/di.js +0 -195
  52. package/transform/compiler-cli/src/ngtsc/annotations/common/src/factory.d.ts +0 -11
  53. package/transform/compiler-cli/src/ngtsc/annotations/common/src/factory.js +0 -22
  54. package/transform/compiler-cli/src/ngtsc/annotations/common/src/util.d.ts +0 -64
  55. package/transform/compiler-cli/src/ngtsc/annotations/common/src/util.js +0 -189
  56. package/transform/compiler-cli/src/ngtsc/annotations/src/injectable.d.ts +0 -43
  57. package/transform/compiler-cli/src/ngtsc/annotations/src/injectable.js +0 -277
  58. package/transform/compiler-cli/src/ngtsc/diagnostics/error.d.ts +0 -24
  59. package/transform/compiler-cli/src/ngtsc/diagnostics/error.js +0 -84
  60. package/transform/compiler-cli/src/ngtsc/diagnostics/error_code.d.ts +0 -188
  61. package/transform/compiler-cli/src/ngtsc/diagnostics/error_code.js +0 -206
  62. package/transform/compiler-cli/src/ngtsc/diagnostics/index.d.ts +0 -2
  63. package/transform/compiler-cli/src/ngtsc/diagnostics/index.js +0 -18
  64. package/transform/compiler-cli/src/ngtsc/imports/index.d.ts +0 -1
  65. package/transform/compiler-cli/src/ngtsc/imports/index.js +0 -17
  66. package/transform/compiler-cli/src/ngtsc/imports/src/core.d.ts +0 -36
  67. package/transform/compiler-cli/src/ngtsc/imports/src/core.js +0 -25
  68. package/transform/compiler-cli/src/ngtsc/imports/src/default.d.ts +0 -19
  69. package/transform/compiler-cli/src/ngtsc/imports/src/default.js +0 -27
  70. package/transform/compiler-cli/src/ngtsc/reflection/index.d.ts +0 -3
  71. package/transform/compiler-cli/src/ngtsc/reflection/index.js +0 -19
  72. package/transform/compiler-cli/src/ngtsc/reflection/src/host.d.ts +0 -522
  73. package/transform/compiler-cli/src/ngtsc/reflection/src/host.js +0 -34
  74. package/transform/compiler-cli/src/ngtsc/reflection/src/type_to_value.d.ts +0 -25
  75. package/transform/compiler-cli/src/ngtsc/reflection/src/type_to_value.js +0 -271
  76. package/transform/compiler-cli/src/ngtsc/reflection/src/typescript.d.ts +0 -53
  77. package/transform/compiler-cli/src/ngtsc/reflection/src/typescript.js +0 -393
  78. package/transform/compiler-cli/src/ngtsc/reflection/src/util.d.ts +0 -12
  79. package/transform/compiler-cli/src/ngtsc/reflection/src/util.js +0 -29
  80. package/transform/compiler-cli/src/ngtsc/transform/index.d.ts +0 -2
  81. package/transform/compiler-cli/src/ngtsc/transform/index.js +0 -18
  82. package/transform/compiler-cli/src/ngtsc/transform/src/api.d.ts +0 -115
  83. package/transform/compiler-cli/src/ngtsc/transform/src/api.js +0 -29
  84. package/transform/compiler-cli/src/ngtsc/transform/src/utils.d.ts +0 -15
  85. package/transform/compiler-cli/src/ngtsc/transform/src/utils.js +0 -79
  86. package/transform/compiler-cli/src/ngtsc/translator/index.d.ts +0 -5
  87. package/transform/compiler-cli/src/ngtsc/translator/index.js +0 -21
  88. package/transform/compiler-cli/src/ngtsc/translator/src/api/ast_factory.d.ts +0 -289
  89. package/transform/compiler-cli/src/ngtsc/translator/src/api/import_generator.d.ts +0 -27
  90. package/transform/compiler-cli/src/ngtsc/translator/src/api/import_generator.js +0 -9
  91. package/transform/compiler-cli/src/ngtsc/translator/src/context.d.ts +0 -18
  92. package/transform/compiler-cli/src/ngtsc/translator/src/context.js +0 -28
  93. package/transform/compiler-cli/src/ngtsc/translator/src/import_manager.d.ts +0 -47
  94. package/transform/compiler-cli/src/ngtsc/translator/src/import_manager.js +0 -66
  95. package/transform/compiler-cli/src/ngtsc/translator/src/translator.d.ts +0 -56
  96. package/transform/compiler-cli/src/ngtsc/translator/src/translator.js +0 -270
  97. package/transform/compiler-cli/src/ngtsc/translator/src/ts_util.d.ts +0 -12
  98. package/transform/compiler-cli/src/ngtsc/translator/src/ts_util.js +0 -27
  99. package/transform/compiler-cli/src/ngtsc/translator/src/typescript_ast_factory.d.ts +0 -53
  100. package/transform/compiler-cli/src/ngtsc/translator/src/typescript_ast_factory.js +0 -250
  101. package/transform/compiler-cli/src/ngtsc/translator/src/typescript_translator.d.ts +0 -13
  102. package/transform/compiler-cli/src/ngtsc/translator/src/typescript_translator.js +0 -21
  103. package/transform/compiler-cli/src/ngtsc/ts_compatibility/index.d.ts +0 -8
  104. package/transform/compiler-cli/src/ngtsc/ts_compatibility/index.js +0 -24
  105. package/transform/compiler-cli/src/ngtsc/ts_compatibility/src/ts_cross_version_utils.d.ts +0 -45
  106. package/transform/compiler-cli/src/ngtsc/ts_compatibility/src/ts_cross_version_utils.js +0 -86
  107. package/transform/compiler-cli/src/ngtsc/util/src/typescript.d.ts +0 -4
  108. package/transform/compiler-cli/src/ngtsc/util/src/typescript.js +0 -16
  109. package/transform/index.d.ts +0 -1
  110. package/transform/index.js +0 -17
  111. package/transform/injectable-transform.d.ts +0 -41
  112. package/transform/injectable-transform.js +0 -245
  113. package/transform/node-Iteration.d.ts +0 -2
  114. package/transform/node-Iteration.js +0 -12
  115. /package/{import/es2022 → es2022}/di/create_injector.js +0 -0
  116. /package/{import/es2022 → es2022}/di/forward_ref.js +0 -0
  117. /package/{import/es2022 → es2022}/di/index.js +0 -0
  118. /package/{import/es2022 → es2022}/di/initializer_token.js +0 -0
  119. /package/{import/es2022 → es2022}/di/inject_switch.js +0 -0
  120. /package/{import/es2022/di/injector_marker.js → es2022/di/injectable.js} +0 -0
  121. /package/{import/es2022 → es2022}/di/injection_token.js +0 -0
  122. /package/{import/es2022 → es2022}/di/injector.js +0 -0
  123. /package/{import/es2022 → es2022}/di/injector_compatibility.js +0 -0
  124. /package/{import/es2022/di/provider_token.js → es2022/di/injector_marker.js} +0 -0
  125. /package/{import/es2022 → es2022}/di/injector_token.js +0 -0
  126. /package/{import/es2022 → es2022}/di/interface/injector.js +0 -0
  127. /package/{import/es2022 → es2022}/di/interface/provider.js +0 -0
  128. /package/{import/es2022 → es2022}/di/internal_tokens.js +0 -0
  129. /package/{import/es2022 → es2022}/di/metadata.js +0 -0
  130. /package/{import/es2022 → es2022}/di/null_injector.js +0 -0
  131. /package/{import/es2022 → es2022}/di/provider_collection.js +0 -0
  132. /package/{import/es2022/interface/lifecycle_hooks.js → es2022/di/provider_token.js} +0 -0
  133. /package/{import/es2022 → es2022}/di/r3_injector.js +0 -0
  134. /package/{import/es2022 → es2022}/di/scope.js +0 -0
  135. /package/{import/es2022 → es2022}/di.js +0 -0
  136. /package/{import/es2022 → es2022}/errors.js +0 -0
  137. /package/{import/es2022 → es2022}/interface/type.js +0 -0
  138. /package/{import/es2022 → es2022}/render3/errors_di.js +0 -0
  139. /package/{import/es2022 → es2022}/render3/fields.js +0 -0
  140. /package/{import/es2022 → es2022}/render3/instructions/di.js +0 -0
  141. /package/{import/es2022 → es2022}/render3/util/stringify_utils.js +0 -0
  142. /package/{import/es2022 → es2022}/util/closure.js +0 -0
  143. /package/{import/es2022 → es2022}/util/empty.js +0 -0
  144. /package/{import/es2022 → es2022}/util/property.js +0 -0
  145. /package/{import/es2022 → es2022}/util/stringify.js +0 -0
  146. /package/{import/typings → typings}/di/create_injector.d.ts +0 -0
  147. /package/{import/typings → typings}/di/forward_ref.d.ts +0 -0
  148. /package/{import/typings → typings}/di/index.d.ts +0 -0
  149. /package/{import/typings → typings}/di/initializer_token.d.ts +0 -0
  150. /package/{import/typings → typings}/di/inject_switch.d.ts +0 -0
  151. /package/{import/typings → typings}/di/injection_token.d.ts +0 -0
  152. /package/{import/typings → typings}/di/injector.d.ts +0 -0
  153. /package/{import/typings → typings}/di/injector_compatibility.d.ts +0 -0
  154. /package/{import/typings → typings}/di/injector_marker.d.ts +0 -0
  155. /package/{import/typings → typings}/di/injector_token.d.ts +0 -0
  156. /package/{import/typings → typings}/di/interface/defs.d.ts +0 -0
  157. /package/{import/typings → typings}/di/interface/injector.d.ts +0 -0
  158. /package/{import/typings → typings}/di/interface/provider.d.ts +0 -0
  159. /package/{import/typings → typings}/di/internal_tokens.d.ts +0 -0
  160. /package/{import/typings → typings}/di/metadata.d.ts +0 -0
  161. /package/{import/typings → typings}/di/null_injector.d.ts +0 -0
  162. /package/{import/typings → typings}/di/provider_collection.d.ts +0 -0
  163. /package/{import/typings → typings}/di/provider_token.d.ts +0 -0
  164. /package/{import/typings → typings}/di/r3_injector.d.ts +0 -0
  165. /package/{import/typings → typings}/di/scope.d.ts +0 -0
  166. /package/{import/typings → typings}/di.d.ts +0 -0
  167. /package/{import/typings → typings}/errors.d.ts +0 -0
  168. /package/{import/typings → typings}/interface/lifecycle_hooks.d.ts +0 -0
  169. /package/{import/typings → typings}/interface/type.d.ts +0 -0
  170. /package/{import/typings → typings}/render3/definition_factory.d.ts +0 -0
  171. /package/{import/typings → typings}/render3/errors_di.d.ts +0 -0
  172. /package/{import/typings → typings}/render3/fields.d.ts +0 -0
  173. /package/{import/typings → typings}/render3/instructions/di.d.ts +0 -0
  174. /package/{import/typings → typings}/render3/util/stringify_utils.d.ts +0 -0
  175. /package/{import/typings → typings}/util/closure.d.ts +0 -0
  176. /package/{import/typings → typings}/util/decorators.d.ts +0 -0
  177. /package/{import/typings → typings}/util/empty.d.ts +0 -0
  178. /package/{import/typings → typings}/util/property.d.ts +0 -0
  179. /package/{import/typings → typings}/util/stringify.d.ts +0 -0
@@ -1,522 +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
- /**
10
- * Metadata extracted from an instance of a decorator on another declaration.
11
- */
12
- export interface Decorator {
13
- /**
14
- * Name by which the decorator was invoked in the user's code.
15
- *
16
- * This is distinct from the name by which the decorator was imported (though in practice they
17
- * will usually be the same).
18
- */
19
- name: string;
20
- /**
21
- * Identifier which refers to the decorator in the user's code.
22
- */
23
- identifier: DecoratorIdentifier;
24
- /**
25
- * `Import` by which the decorator was brought into the module in which it was invoked, or `null`
26
- * if the decorator was declared in the same module and not imported.
27
- *
28
- * Note: this field is declared using computed property syntax to work around a clang-format bug
29
- * that resulted in inconsistent indentation of this comment block.
30
- */
31
- ['import']: Import | null;
32
- /**
33
- * TypeScript reference to the decorator itself.
34
- */
35
- node: ts.Node;
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
- * A decorator is identified by either a simple identifier (e.g. `Decorator`) or, in some cases,
44
- * a namespaced property access (e.g. `core.Decorator`).
45
- */
46
- export type DecoratorIdentifier = ts.Identifier | NamespacedIdentifier;
47
- export type NamespacedIdentifier = ts.PropertyAccessExpression & {
48
- expression: ts.Identifier;
49
- name: ts.Identifier;
50
- };
51
- export declare function isDecoratorIdentifier(exp: ts.Expression): exp is DecoratorIdentifier;
52
- /**
53
- * The `ts.Declaration` of a "class".
54
- *
55
- * Classes are represented differently in different code formats:
56
- * - In TS code, they are typically defined using the `class` keyword.
57
- * - In ES2015 code, they are usually defined using the `class` keyword, but they can also be
58
- * variable declarations, which are initialized to a class expression (e.g.
59
- * `let Foo = Foo1 = class Foo {}`).
60
- * - In ES5 code, they are typically defined as variable declarations being assigned the return
61
- * value of an IIFE. The actual "class" is implemented as a constructor function inside the IIFE,
62
- * but the outer variable declaration represents the "class" to the rest of the program.
63
- *
64
- * For `ReflectionHost` purposes, a class declaration should always have a `name` identifier,
65
- * because we need to be able to reference it in other parts of the program.
66
- */
67
- export type ClassDeclaration<T extends DeclarationNode = DeclarationNode> = T & {
68
- name: ts.Identifier;
69
- };
70
- /**
71
- * An enumeration of possible kinds of class members.
72
- */
73
- export declare enum ClassMemberKind {
74
- Constructor = 0,
75
- Getter = 1,
76
- Setter = 2,
77
- Property = 3,
78
- Method = 4
79
- }
80
- /**
81
- * A member of a class, such as a property, method, or constructor.
82
- */
83
- export interface ClassMember {
84
- /**
85
- * TypeScript reference to the class member itself, or null if it is not applicable.
86
- */
87
- node: ts.Node | null;
88
- /**
89
- * Indication of which type of member this is (property, method, etc).
90
- */
91
- kind: ClassMemberKind;
92
- /**
93
- * TypeScript `ts.TypeNode` representing the type of the member, or `null` if not present or
94
- * applicable.
95
- */
96
- type: ts.TypeNode | null;
97
- /**
98
- * Name of the class member.
99
- */
100
- name: string;
101
- /**
102
- * TypeScript `ts.Identifier` or `ts.StringLiteral` representing the name of the member, or `null`
103
- * if no such node is present.
104
- *
105
- * The `nameNode` is useful in writing references to this member that will be correctly source-
106
- * mapped back to the original file.
107
- */
108
- nameNode: ts.Identifier | ts.StringLiteral | null;
109
- /**
110
- * TypeScript `ts.Expression` which represents the value of the member.
111
- *
112
- * If the member is a property, this will be the property initializer if there is one, or null
113
- * otherwise.
114
- */
115
- value: ts.Expression | null;
116
- /**
117
- * TypeScript `ts.Declaration` which represents the implementation of the member.
118
- *
119
- * In TypeScript code this is identical to the node, but in downleveled code this should always be
120
- * the Declaration which actually represents the member's runtime value.
121
- *
122
- * For example, the TS code:
123
- *
124
- * ```
125
- * class Clazz {
126
- * static get property(): string {
127
- * return 'value';
128
- * }
129
- * }
130
- * ```
131
- *
132
- * Downlevels to:
133
- *
134
- * ```
135
- * var Clazz = (function () {
136
- * function Clazz() {
137
- * }
138
- * Object.defineProperty(Clazz, "property", {
139
- * get: function () {
140
- * return 'value';
141
- * },
142
- * enumerable: true,
143
- * configurable: true
144
- * });
145
- * return Clazz;
146
- * }());
147
- * ```
148
- *
149
- * In this example, for the property "property", the node would be the entire
150
- * Object.defineProperty ExpressionStatement, but the implementation would be this
151
- * FunctionDeclaration:
152
- *
153
- * ```
154
- * function () {
155
- * return 'value';
156
- * },
157
- * ```
158
- */
159
- implementation: ts.Declaration | null;
160
- /**
161
- * Whether the member is static or not.
162
- */
163
- isStatic: boolean;
164
- /**
165
- * Any `Decorator`s which are present on the member, or `null` if none are present.
166
- */
167
- decorators: Decorator[] | null;
168
- }
169
- export declare const enum TypeValueReferenceKind {
170
- LOCAL = 0,
171
- IMPORTED = 1,
172
- UNAVAILABLE = 2
173
- }
174
- /**
175
- * A type reference that refers to any type via a `ts.Expression` that's valid within the local file
176
- * where the type was referenced.
177
- */
178
- export interface LocalTypeValueReference {
179
- kind: TypeValueReferenceKind.LOCAL;
180
- /**
181
- * The synthesized expression to reference the type in a value position.
182
- */
183
- expression: ts.Expression;
184
- /**
185
- * If the type originates from a default import, the import statement is captured here to be able
186
- * to track its usages, preventing the import from being elided if it was originally only used in
187
- * a type-position. See `DefaultImportTracker` for details.
188
- */
189
- defaultImportStatement: ts.ImportDeclaration | null;
190
- }
191
- /**
192
- * A reference that refers to a type that was imported, and gives the symbol `name` and the
193
- * `moduleName` of the import. Note that this `moduleName` may be a relative path, and thus is
194
- * likely only valid within the context of the file which contained the original type reference.
195
- */
196
- export interface ImportedTypeValueReference {
197
- kind: TypeValueReferenceKind.IMPORTED;
198
- /**
199
- * The module specifier from which the `importedName` symbol should be imported.
200
- */
201
- moduleName: string;
202
- /**
203
- * The name of the top-level symbol that is imported from `moduleName`. If `nestedPath` is also
204
- * present, a nested object is being referenced from the top-level symbol.
205
- */
206
- importedName: string;
207
- /**
208
- * If present, represents the symbol names that are referenced from the top-level import.
209
- * When `null` or empty, the `importedName` itself is the symbol being referenced.
210
- */
211
- nestedPath: string[] | null;
212
- valueDeclaration: DeclarationNode | null;
213
- }
214
- /**
215
- * A representation for a type value reference that is used when no value is available. This can
216
- * occur due to various reasons, which is indicated in the `reason` field.
217
- */
218
- export interface UnavailableTypeValueReference {
219
- kind: TypeValueReferenceKind.UNAVAILABLE;
220
- /**
221
- * The reason why no value reference could be determined for a type.
222
- */
223
- reason: UnavailableValue;
224
- }
225
- /**
226
- * The various reasons why the compiler may be unable to synthesize a value from a type reference.
227
- */
228
- export declare const enum ValueUnavailableKind {
229
- /**
230
- * No type node was available.
231
- */
232
- MISSING_TYPE = 0,
233
- /**
234
- * The type does not have a value declaration, e.g. an interface.
235
- */
236
- NO_VALUE_DECLARATION = 1,
237
- /**
238
- * The type is imported using a type-only imports, so it is not suitable to be used in a
239
- * value-position.
240
- */
241
- TYPE_ONLY_IMPORT = 2,
242
- /**
243
- * The type reference could not be resolved to a declaration.
244
- */
245
- UNKNOWN_REFERENCE = 3,
246
- /**
247
- * The type corresponds with a namespace.
248
- */
249
- NAMESPACE = 4,
250
- /**
251
- * The type is not supported in the compiler, for example union types.
252
- */
253
- UNSUPPORTED = 5
254
- }
255
- export interface UnsupportedType {
256
- kind: ValueUnavailableKind.UNSUPPORTED;
257
- typeNode: ts.TypeNode;
258
- }
259
- export interface NoValueDeclaration {
260
- kind: ValueUnavailableKind.NO_VALUE_DECLARATION;
261
- typeNode: ts.TypeNode;
262
- decl: ts.Declaration | null;
263
- }
264
- export interface TypeOnlyImport {
265
- kind: ValueUnavailableKind.TYPE_ONLY_IMPORT;
266
- typeNode: ts.TypeNode;
267
- node: ts.ImportClause | ts.ImportSpecifier;
268
- }
269
- export interface NamespaceImport {
270
- kind: ValueUnavailableKind.NAMESPACE;
271
- typeNode: ts.TypeNode;
272
- importClause: ts.ImportClause;
273
- }
274
- export interface UnknownReference {
275
- kind: ValueUnavailableKind.UNKNOWN_REFERENCE;
276
- typeNode: ts.TypeNode;
277
- }
278
- export interface MissingType {
279
- kind: ValueUnavailableKind.MISSING_TYPE;
280
- }
281
- /**
282
- * The various reasons why a type node may not be referred to as a value.
283
- */
284
- export type UnavailableValue = UnsupportedType | NoValueDeclaration | TypeOnlyImport | NamespaceImport | UnknownReference | MissingType;
285
- /**
286
- * A reference to a value that originated from a type position.
287
- *
288
- * For example, a constructor parameter could be declared as `foo: Foo`. A `TypeValueReference`
289
- * extracted from this would refer to the value of the class `Foo` (assuming it was actually a
290
- * type).
291
- *
292
- * See the individual types for additional information.
293
- */
294
- export type TypeValueReference = LocalTypeValueReference | ImportedTypeValueReference | UnavailableTypeValueReference;
295
- /**
296
- * A parameter to a constructor.
297
- */
298
- export interface CtorParameter {
299
- /**
300
- * Name of the parameter, if available.
301
- *
302
- * Some parameters don't have a simple string name (for example, parameters which are destructured
303
- * into multiple variables). In these cases, `name` can be `null`.
304
- */
305
- name: string | null;
306
- /**
307
- * TypeScript `ts.BindingName` representing the name of the parameter.
308
- *
309
- * The `nameNode` is useful in writing references to this member that will be correctly source-
310
- * mapped back to the original file.
311
- */
312
- nameNode: ts.BindingName;
313
- /**
314
- * Reference to the value of the parameter's type annotation, if it's possible to refer to the
315
- * parameter's type as a value.
316
- *
317
- * This can either be a reference to a local value, a reference to an imported value, or no
318
- * value if no is present or cannot be represented as an expression.
319
- */
320
- typeValueReference: TypeValueReference;
321
- /**
322
- * TypeScript `ts.TypeNode` representing the type node found in the type position.
323
- *
324
- * This field can be used for diagnostics reporting if `typeValueReference` is `null`.
325
- *
326
- * Can be null, if the param has no type declared.
327
- */
328
- typeNode: ts.TypeNode | null;
329
- /**
330
- * Any `Decorator`s which are present on the parameter, or `null` if none are present.
331
- */
332
- decorators: Decorator[] | null;
333
- }
334
- /**
335
- * Definition of a function or method, including its body if present and any parameters.
336
- *
337
- * In TypeScript code this metadata will be a simple reflection of the declarations in the node
338
- * itself. In ES5 code this can be more complicated, as the default values for parameters may
339
- * be extracted from certain body statements.
340
- */
341
- export interface FunctionDefinition {
342
- /**
343
- * A reference to the node which declares the function.
344
- */
345
- node: ts.MethodDeclaration | ts.FunctionDeclaration | ts.FunctionExpression | ts.VariableDeclaration | ts.ArrowFunction;
346
- /**
347
- * Statements of the function body, if a body is present, or null if no body is present or the
348
- * function is identified to represent a tslib helper function, in which case `helper` will
349
- * indicate which helper this function represents.
350
- *
351
- * This list may have been filtered to exclude statements which perform parameter default value
352
- * initialization.
353
- */
354
- body: ts.Statement[] | null;
355
- /**
356
- * Metadata regarding the function's parameters, including possible default value expressions.
357
- */
358
- parameters: Parameter[];
359
- /**
360
- * Generic type parameters of the function.
361
- */
362
- typeParameters: ts.TypeParameterDeclaration[] | null;
363
- /**
364
- * Number of known signatures of the function.
365
- */
366
- signatureCount: number;
367
- }
368
- /**
369
- * A parameter to a function or method.
370
- */
371
- export interface Parameter {
372
- /**
373
- * Name of the parameter, if available.
374
- */
375
- name: string | null;
376
- /**
377
- * Declaration which created this parameter.
378
- */
379
- node: ts.ParameterDeclaration;
380
- /**
381
- * Expression which represents the default value of the parameter, if any.
382
- */
383
- initializer: ts.Expression | null;
384
- /**
385
- * Type of the parameter.
386
- */
387
- type: ts.TypeNode | null;
388
- }
389
- /**
390
- * The source of an imported symbol, including the original symbol name and the module from which it
391
- * was imported.
392
- */
393
- export interface Import {
394
- /**
395
- * The name of the imported symbol under which it was exported (not imported).
396
- */
397
- name: string;
398
- /**
399
- * The module from which the symbol was imported.
400
- *
401
- * This could either be an absolute module name (@angular/core for example) or a relative path.
402
- */
403
- from: string;
404
- /**
405
- * TypeScript node that represents this import.
406
- */
407
- node: ts.ImportDeclaration;
408
- }
409
- /**
410
- * A type that is used to identify a declaration.
411
- */
412
- export type DeclarationNode = ts.Declaration;
413
- export type AmbientImport = {
414
- __brand: 'AmbientImport';
415
- };
416
- /** Indicates that a declaration is referenced through an ambient type. */
417
- export declare const AmbientImport: AmbientImport;
418
- /**
419
- * The declaration of a symbol, along with information about how it was imported into the
420
- * application.
421
- */
422
- export interface Declaration<T extends ts.Declaration = ts.Declaration> {
423
- /**
424
- * The absolute module path from which the symbol was imported into the application, if the symbol
425
- * was imported via an absolute module (even through a chain of re-exports). If the symbol is part
426
- * of the application and was not imported from an absolute path, this will be `null`.
427
- */
428
- viaModule: string | AmbientImport | null;
429
- /**
430
- * TypeScript reference to the declaration itself, if one exists.
431
- */
432
- node: T;
433
- }
434
- /**
435
- * Abstracts reflection operations on a TypeScript AST.
436
- *
437
- * Depending on the format of the code being interpreted, different concepts are represented
438
- * with different syntactical structures. The `ReflectionHost` abstracts over those differences and
439
- * presents a single API by which the compiler can query specific information about the AST.
440
- *
441
- * All operations on the `ReflectionHost` require the use of TypeScript `ts.Node`s with binding
442
- * information already available (that is, nodes that come from a `ts.Program` that has been
443
- * type-checked, and are not synthetically created).
444
- */
445
- export interface ReflectionHost {
446
- /**
447
- * Examine a declaration (for example, of a class or function) and return metadata about any
448
- * decorators present on the declaration.
449
- *
450
- * @param declaration a TypeScript `ts.Declaration` node representing the class or function over
451
- * which to reflect. For example, if the intent is to reflect the decorators of a class and the
452
- * source is in ES6 format, this will be a `ts.ClassDeclaration` node. If the source is in ES5
453
- * format, this might be a `ts.VariableDeclaration` as classes in ES5 are represented as the
454
- * result of an IIFE execution.
455
- *
456
- * @returns an array of `Decorator` metadata if decorators are present on the declaration, or
457
- * `null` if either no decorators were present or if the declaration is not of a decoratable type.
458
- */
459
- getDecoratorsOfDeclaration(declaration: DeclarationNode): Decorator[] | null;
460
- /**
461
- * Examine a declaration which should be of a class, and return metadata about the members of the
462
- * class.
463
- *
464
- * @param clazz a `ClassDeclaration` representing the class over which to reflect.
465
- *
466
- * @returns an array of `ClassMember` metadata representing the members of the class.
467
- *
468
- * @throws if `declaration` does not resolve to a class declaration.
469
- */
470
- getMembersOfClass(clazz: ClassDeclaration): ClassMember[];
471
- /**
472
- * Reflect over the constructor of a class and return metadata about its parameters.
473
- *
474
- * This method only looks at the constructor of a class directly and not at any inherited
475
- * constructors.
476
- *
477
- * @param clazz a `ClassDeclaration` representing the class over which to reflect.
478
- *
479
- * @returns an array of `Parameter` metadata representing the parameters of the constructor, if
480
- * a constructor exists. If the constructor exists and has 0 parameters, this array will be empty.
481
- * If the class has no constructor, this method returns `null`.
482
- */
483
- getConstructorParameters(clazz: ClassDeclaration): CtorParameter[] | null;
484
- /**
485
- * Determine if an identifier was imported from another module and return `Import` metadata
486
- * describing its origin.
487
- *
488
- * @param id a TypeScript `ts.Identifier` to reflect.
489
- *
490
- * @returns metadata about the `Import` if the identifier was imported from another module, or
491
- * `null` if the identifier doesn't resolve to an import but instead is locally defined.
492
- */
493
- getImportOfIdentifier(id: ts.Identifier): Import | null;
494
- /**
495
- * Check whether the given node actually represents a class.
496
- */
497
- isClass(node: ts.Node): node is ClassDeclaration;
498
- /**
499
- * Determines whether the given declaration, which should be a class, has a base class.
500
- *
501
- * @param clazz a `ClassDeclaration` representing the class over which to reflect.
502
- */
503
- hasBaseClass(clazz: ClassDeclaration): boolean;
504
- /**
505
- * Get an expression representing the base class (if any) of the given `clazz`.
506
- *
507
- * This expression is most commonly an Identifier, but is possible to inherit from a more dynamic
508
- * expression.
509
- *
510
- * @param clazz the class whose base we want to get.
511
- */
512
- getBaseClassExpression(clazz: ClassDeclaration): ts.Expression | null;
513
- /**
514
- * Get the number of generic type parameters of a given class.
515
- *
516
- * @param clazz a `ClassDeclaration` representing the class over which to reflect.
517
- *
518
- * @returns the number of type parameters of the class, if known, or `null` if the declaration
519
- * is not a class or has an unknown number of type parameters.
520
- */
521
- getGenericArityOfClass(clazz: ClassDeclaration): number | null;
522
- }
@@ -1,34 +0,0 @@
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
- var __importDefault = (this && this.__importDefault) || function (mod) {
10
- return (mod && mod.__esModule) ? mod : { "default": mod };
11
- };
12
- Object.defineProperty(exports, "__esModule", { value: true });
13
- exports.AmbientImport = exports.ClassMemberKind = exports.isDecoratorIdentifier = void 0;
14
- const typescript_1 = __importDefault(require("typescript"));
15
- function isDecoratorIdentifier(exp) {
16
- return (typescript_1.default.isIdentifier(exp) ||
17
- (typescript_1.default.isPropertyAccessExpression(exp) &&
18
- typescript_1.default.isIdentifier(exp.expression) &&
19
- typescript_1.default.isIdentifier(exp.name)));
20
- }
21
- exports.isDecoratorIdentifier = isDecoratorIdentifier;
22
- /**
23
- * An enumeration of possible kinds of class members.
24
- */
25
- var ClassMemberKind;
26
- (function (ClassMemberKind) {
27
- ClassMemberKind[ClassMemberKind["Constructor"] = 0] = "Constructor";
28
- ClassMemberKind[ClassMemberKind["Getter"] = 1] = "Getter";
29
- ClassMemberKind[ClassMemberKind["Setter"] = 2] = "Setter";
30
- ClassMemberKind[ClassMemberKind["Property"] = 3] = "Property";
31
- ClassMemberKind[ClassMemberKind["Method"] = 4] = "Method";
32
- })(ClassMemberKind || (exports.ClassMemberKind = ClassMemberKind = {}));
33
- /** Indicates that a declaration is referenced through an ambient type. */
34
- exports.AmbientImport = {};
@@ -1,25 +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 { TypeValueReference } from './host';
10
- /**
11
- * Potentially convert a `ts.TypeNode` to a `TypeValueReference`, which indicates how to use the
12
- * type given in the `ts.TypeNode` in a value position.
13
- *
14
- * This can return `null` if the `typeNode` is `null`, if it does not refer to a symbol with a value
15
- * declaration, or if it is not possible to statically understand.
16
- */
17
- export declare function typeToValue(typeNode: ts.TypeNode | null, checker: ts.TypeChecker, isLocalCompilation: boolean): TypeValueReference;
18
- /**
19
- * Attempt to extract a `ts.Expression` that's equivalent to a `ts.TypeNode`, as the two have
20
- * different AST shapes but can reference the same symbols.
21
- *
22
- * This will return `null` if an equivalent expression cannot be constructed.
23
- */
24
- export declare function typeNodeToValueExpr(node: ts.TypeNode): ts.Expression | null;
25
- export declare function entityNameToValue(node: ts.EntityName): ts.Expression | null;