@angular/compiler-cli 10.0.6 → 10.0.10

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 (85) hide show
  1. package/ngcc/src/analysis/ngcc_trait_compiler.js +2 -1
  2. package/ngcc/src/host/esm2015_host.js +10 -4
  3. package/ngcc/src/host/esm5_host.d.ts +118 -0
  4. package/ngcc/src/host/esm5_host.js +210 -123
  5. package/ngcc/src/packages/build_marker.d.ts +1 -1
  6. package/ngcc/src/packages/build_marker.js +1 -1
  7. package/package.json +2 -2
  8. package/src/main.js +1 -2
  9. package/src/ngtsc/annotations/src/component.d.ts +1 -1
  10. package/src/ngtsc/annotations/src/component.js +3 -3
  11. package/src/ngtsc/annotations/src/diagnostics.js +2 -2
  12. package/src/ngtsc/annotations/src/metadata.js +3 -3
  13. package/src/ngtsc/annotations/src/ng_module.js +6 -6
  14. package/src/ngtsc/annotations/src/util.d.ts +4 -8
  15. package/src/ngtsc/annotations/src/util.js +73 -22
  16. package/src/ngtsc/core/src/compiler.d.ts +2 -1
  17. package/src/ngtsc/core/src/compiler.js +8 -9
  18. package/src/ngtsc/diagnostics/index.d.ts +1 -1
  19. package/src/ngtsc/diagnostics/index.js +2 -1
  20. package/src/ngtsc/diagnostics/src/error.d.ts +5 -6
  21. package/src/ngtsc/diagnostics/src/error.js +20 -20
  22. package/src/ngtsc/diagnostics/src/error_code.d.ts +10 -0
  23. package/src/ngtsc/diagnostics/src/error_code.js +11 -1
  24. package/src/ngtsc/imports/src/core.js +2 -1
  25. package/src/ngtsc/incremental/api.d.ts +12 -7
  26. package/src/ngtsc/incremental/api.js +1 -1
  27. package/src/ngtsc/incremental/src/noop.js +2 -1
  28. package/src/ngtsc/incremental/src/state.d.ts +1 -1
  29. package/src/ngtsc/incremental/src/state.js +1 -1
  30. package/src/ngtsc/program.d.ts +2 -1
  31. package/src/ngtsc/program.js +1 -1
  32. package/src/ngtsc/reflection/src/host.d.ts +110 -25
  33. package/src/ngtsc/reflection/src/host.js +1 -1
  34. package/src/ngtsc/reflection/src/type_to_value.d.ts +1 -1
  35. package/src/ngtsc/reflection/src/type_to_value.js +62 -11
  36. package/src/ngtsc/reflection/src/typescript.js +1 -4
  37. package/src/ngtsc/scope/src/local.js +4 -4
  38. package/src/ngtsc/shims/api.d.ts +6 -2
  39. package/src/ngtsc/shims/api.js +1 -1
  40. package/src/ngtsc/shims/src/factory_generator.d.ts +2 -2
  41. package/src/ngtsc/shims/src/factory_generator.js +58 -9
  42. package/src/ngtsc/transform/src/api.d.ts +1 -1
  43. package/src/ngtsc/transform/src/api.js +1 -1
  44. package/src/ngtsc/transform/src/compilation.d.ts +1 -1
  45. package/src/ngtsc/transform/src/compilation.js +1 -1
  46. package/src/ngtsc/transform/src/transform.js +2 -2
  47. package/src/ngtsc/tsc_plugin.d.ts +1 -1
  48. package/src/ngtsc/tsc_plugin.js +1 -1
  49. package/src/ngtsc/typecheck/{src → api}/api.d.ts +25 -2
  50. package/src/ngtsc/typecheck/{src → api}/api.js +2 -2
  51. package/src/ngtsc/typecheck/api/checker.d.ts +91 -0
  52. package/src/ngtsc/typecheck/api/checker.js +44 -0
  53. package/src/ngtsc/typecheck/api/context.d.ts +44 -0
  54. package/src/ngtsc/typecheck/api/context.js +20 -0
  55. package/src/ngtsc/typecheck/api/index.d.ts +11 -0
  56. package/src/ngtsc/typecheck/api/index.js +24 -0
  57. package/src/ngtsc/typecheck/index.d.ts +4 -5
  58. package/src/ngtsc/typecheck/index.js +6 -8
  59. package/src/ngtsc/typecheck/src/augmented_program.d.ts +3 -1
  60. package/src/ngtsc/typecheck/src/augmented_program.js +9 -3
  61. package/src/ngtsc/typecheck/src/checker.d.ts +63 -18
  62. package/src/ngtsc/typecheck/src/checker.js +394 -62
  63. package/src/ngtsc/typecheck/src/context.d.ts +76 -55
  64. package/src/ngtsc/typecheck/src/context.js +111 -67
  65. package/src/ngtsc/typecheck/src/diagnostics.d.ts +9 -3
  66. package/src/ngtsc/typecheck/src/diagnostics.js +28 -5
  67. package/src/ngtsc/typecheck/src/dom.d.ts +4 -5
  68. package/src/ngtsc/typecheck/src/dom.js +3 -3
  69. package/src/ngtsc/typecheck/src/environment.d.ts +1 -1
  70. package/src/ngtsc/typecheck/src/environment.js +1 -1
  71. package/src/ngtsc/typecheck/src/expression.d.ts +1 -1
  72. package/src/ngtsc/typecheck/src/expression.js +2 -2
  73. package/src/ngtsc/typecheck/src/oob.d.ts +9 -5
  74. package/src/ngtsc/typecheck/src/oob.js +25 -6
  75. package/src/ngtsc/typecheck/src/source.d.ts +4 -3
  76. package/src/ngtsc/typecheck/src/source.js +20 -4
  77. package/src/ngtsc/typecheck/src/template_semantics.d.ts +1 -1
  78. package/src/ngtsc/typecheck/src/template_semantics.js +1 -1
  79. package/src/ngtsc/typecheck/src/type_check_block.d.ts +1 -1
  80. package/src/ngtsc/typecheck/src/type_check_block.js +1 -1
  81. package/src/ngtsc/typecheck/src/type_check_file.d.ts +1 -1
  82. package/src/ngtsc/typecheck/src/type_check_file.js +1 -1
  83. package/src/ngtsc/typecheck/src/type_constructor.d.ts +1 -1
  84. package/src/ngtsc/typecheck/src/type_constructor.js +1 -1
  85. package/src/version.js +1 -1
@@ -139,4 +139,122 @@ export declare class Esm5ReflectionHost extends Esm2015ReflectionHost {
139
139
  * @returns an array of statements that may contain helper calls.
140
140
  */
141
141
  protected getStatementsForClass(classSymbol: NgccClassSymbol): ts.Statement[];
142
+ /**
143
+ * A constructor function may have been "synthesized" by TypeScript during JavaScript emit,
144
+ * in the case no user-defined constructor exists and e.g. property initializers are used.
145
+ * Those initializers need to be emitted into a constructor in JavaScript, so the TypeScript
146
+ * compiler generates a synthetic constructor.
147
+ *
148
+ * We need to identify such constructors as ngcc needs to be able to tell if a class did
149
+ * originally have a constructor in the TypeScript source. For ES5, we can not tell an
150
+ * empty constructor apart from a synthesized constructor, but fortunately that does not
151
+ * matter for the code generated by ngtsc.
152
+ *
153
+ * When a class has a superclass however, a synthesized constructor must not be considered
154
+ * as a user-defined constructor as that prevents a base factory call from being created by
155
+ * ngtsc, resulting in a factory function that does not inject the dependencies of the
156
+ * superclass. Hence, we identify a default synthesized super call in the constructor body,
157
+ * according to the structure that TypeScript's ES2015 to ES5 transformer generates in
158
+ * https://github.com/Microsoft/TypeScript/blob/v3.2.2/src/compiler/transformers/es2015.ts#L1082-L1098
159
+ *
160
+ * Additionally, we handle synthetic delegate constructors that are emitted when TypeScript
161
+ * downlevel's ES2015 synthetically generated to ES5. These vary slightly from the default
162
+ * structure mentioned above because the ES2015 output uses a spread operator, for delegating
163
+ * to the parent constructor, that is preserved through a TypeScript helper in ES5. e.g.
164
+ *
165
+ * ```
166
+ * return _super.apply(this, tslib.__spread(arguments)) || this;
167
+ * ```
168
+ *
169
+ * Such constructs can be still considered as synthetic delegate constructors as they are
170
+ * the product of a common TypeScript to ES5 synthetic constructor, just being downleveled
171
+ * to ES5 using `tsc`. See: https://github.com/angular/angular/issues/38453.
172
+ *
173
+ *
174
+ * @param constructor a constructor function to test
175
+ * @returns true if the constructor appears to have been synthesized
176
+ */
177
+ private isSynthesizedConstructor;
178
+ /**
179
+ * Identifies synthesized super calls which pass-through function arguments directly and are
180
+ * being assigned to a common `_this` variable. The following patterns we intend to match:
181
+ *
182
+ * 1. Delegate call emitted by TypeScript when it emits ES5 directly.
183
+ * ```
184
+ * var _this = _super !== null && _super.apply(this, arguments) || this;
185
+ * ```
186
+ *
187
+ * 2. Delegate call emitted by TypeScript when it downlevel's ES2015 to ES5.
188
+ * ```
189
+ * var _this = _super.apply(this, tslib.__spread(arguments)) || this;
190
+ * ```
191
+ *
192
+ *
193
+ * @param statement a statement that may be a synthesized super call
194
+ * @returns true if the statement looks like a synthesized super call
195
+ */
196
+ private isSynthesizedSuperThisAssignment;
197
+ /**
198
+ * Identifies synthesized super calls which pass-through function arguments directly and
199
+ * are being returned. The following patterns correspond to synthetic super return calls:
200
+ *
201
+ * 1. Delegate call emitted by TypeScript when it emits ES5 directly.
202
+ * ```
203
+ * return _super !== null && _super.apply(this, arguments) || this;
204
+ * ```
205
+ *
206
+ * 2. Delegate call emitted by TypeScript when it downlevel's ES2015 to ES5.
207
+ * ```
208
+ * return _super.apply(this, tslib.__spread(arguments)) || this;
209
+ * ```
210
+ *
211
+ * @param statement a statement that may be a synthesized super call
212
+ * @returns true if the statement looks like a synthesized super call
213
+ */
214
+ private isSynthesizedSuperReturnStatement;
215
+ /**
216
+ * Identifies synthesized super calls which pass-through function arguments directly. The
217
+ * synthetic delegate super call match the following patterns we intend to match:
218
+ *
219
+ * 1. Delegate call emitted by TypeScript when it emits ES5 directly.
220
+ * ```
221
+ * _super !== null && _super.apply(this, arguments) || this;
222
+ * ```
223
+ *
224
+ * 2. Delegate call emitted by TypeScript when it downlevel's ES2015 to ES5.
225
+ * ```
226
+ * _super.apply(this, tslib.__spread(arguments)) || this;
227
+ * ```
228
+ *
229
+ * @param expression an expression that may represent a default super call
230
+ * @returns true if the expression corresponds with the above form
231
+ */
232
+ private isSynthesizedDefaultSuperCall;
233
+ /**
234
+ * Tests whether the expression corresponds to a `super` call passing through
235
+ * function arguments without any modification. e.g.
236
+ *
237
+ * ```
238
+ * _super !== null && _super.apply(this, arguments) || this;
239
+ * ```
240
+ *
241
+ * This structure is generated by TypeScript when transforming ES2015 to ES5, see
242
+ * https://github.com/Microsoft/TypeScript/blob/v3.2.2/src/compiler/transformers/es2015.ts#L1148-L1163
243
+ *
244
+ * Additionally, we also handle cases where `arguments` are wrapped by a TypeScript spread helper.
245
+ * This can happen if ES2015 class output contain auto-generated constructors due to class
246
+ * members. The ES2015 output will be using `super(...arguments)` to delegate to the superclass,
247
+ * but once downleveled to ES5, the spread operator will be persisted through a TypeScript spread
248
+ * helper. For example:
249
+ *
250
+ * ```
251
+ * _super.apply(this, __spread(arguments)) || this;
252
+ * ```
253
+ *
254
+ * More details can be found in: https://github.com/angular/angular/issues/38453.
255
+ *
256
+ * @param expression an expression that may represent a default super call
257
+ * @returns true if the expression corresponds with the above form
258
+ */
259
+ private isSuperApplyCall;
142
260
  }