@angular/compiler-cli 10.1.4 → 10.2.1

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 (76) hide show
  1. package/ngcc/src/analysis/module_with_providers_analyzer.d.ts +2 -2
  2. package/ngcc/src/analysis/module_with_providers_analyzer.js +1 -1
  3. package/ngcc/src/analysis/ngcc_references_registry.d.ts +3 -3
  4. package/ngcc/src/analysis/ngcc_references_registry.js +2 -2
  5. package/ngcc/src/analysis/private_declarations_analyzer.js +1 -1
  6. package/ngcc/src/dependencies/commonjs_dependency_host.js +1 -1
  7. package/ngcc/src/dependencies/dependency_host.d.ts +15 -0
  8. package/ngcc/src/dependencies/dependency_host.js +42 -9
  9. package/ngcc/src/entry_point_finder/program_based_entry_point_finder.js +4 -6
  10. package/ngcc/src/host/commonjs_host.d.ts +5 -1
  11. package/ngcc/src/host/commonjs_host.js +50 -20
  12. package/ngcc/src/host/commonjs_umd_utils.d.ts +59 -12
  13. package/ngcc/src/host/commonjs_umd_utils.js +57 -15
  14. package/ngcc/src/host/delegating_host.d.ts +3 -3
  15. package/ngcc/src/host/delegating_host.js +1 -1
  16. package/ngcc/src/host/esm2015_host.d.ts +82 -27
  17. package/ngcc/src/host/esm2015_host.js +129 -107
  18. package/ngcc/src/host/esm5_host.js +7 -7
  19. package/ngcc/src/host/umd_host.d.ts +21 -1
  20. package/ngcc/src/host/umd_host.js +210 -25
  21. package/ngcc/src/locking/async_locker.d.ts +0 -2
  22. package/ngcc/src/locking/async_locker.js +8 -51
  23. package/ngcc/src/migrations/missing_injectable_migration.js +1 -1
  24. package/ngcc/src/migrations/undecorated_parent_migration.js +1 -1
  25. package/ngcc/src/migrations/utils.d.ts +1 -1
  26. package/ngcc/src/migrations/utils.js +1 -1
  27. package/ngcc/src/packages/build_marker.d.ts +1 -1
  28. package/ngcc/src/packages/build_marker.js +1 -1
  29. package/ngcc/src/utils.d.ts +3 -3
  30. package/ngcc/src/utils.js +1 -1
  31. package/package.json +2 -2
  32. package/src/ngtsc/annotations/src/component.js +1 -1
  33. package/src/ngtsc/annotations/src/directive.js +9 -3
  34. package/src/ngtsc/annotations/src/metadata.d.ts +2 -3
  35. package/src/ngtsc/annotations/src/metadata.js +1 -1
  36. package/src/ngtsc/annotations/src/ng_module.js +4 -9
  37. package/src/ngtsc/annotations/src/references_registry.d.ts +3 -3
  38. package/src/ngtsc/annotations/src/references_registry.js +1 -1
  39. package/src/ngtsc/core/src/compiler.d.ts +2 -1
  40. package/src/ngtsc/core/src/compiler.js +1 -1
  41. package/src/ngtsc/entry_point/src/private_export_checker.js +1 -1
  42. package/src/ngtsc/entry_point/src/reference_graph.d.ts +2 -2
  43. package/src/ngtsc/entry_point/src/reference_graph.js +1 -1
  44. package/src/ngtsc/imports/src/emitter.d.ts +2 -2
  45. package/src/ngtsc/imports/src/emitter.js +12 -8
  46. package/src/ngtsc/indexer/src/api.d.ts +2 -3
  47. package/src/ngtsc/indexer/src/api.js +1 -1
  48. package/src/ngtsc/indexer/src/transform.d.ts +2 -2
  49. package/src/ngtsc/indexer/src/transform.js +1 -1
  50. package/src/ngtsc/partial_evaluator/src/interpreter.d.ts +1 -0
  51. package/src/ngtsc/partial_evaluator/src/interpreter.js +15 -20
  52. package/src/ngtsc/perf/src/api.d.ts +3 -3
  53. package/src/ngtsc/perf/src/api.js +1 -1
  54. package/src/ngtsc/perf/src/noop.d.ts +0 -7
  55. package/src/ngtsc/perf/src/noop.js +1 -8
  56. package/src/ngtsc/perf/src/tracking.d.ts +3 -2
  57. package/src/ngtsc/perf/src/tracking.js +1 -1
  58. package/src/ngtsc/program.d.ts +2 -1
  59. package/src/ngtsc/program.js +1 -1
  60. package/src/ngtsc/reflection/src/host.d.ts +39 -22
  61. package/src/ngtsc/reflection/src/host.js +10 -2
  62. package/src/ngtsc/reflection/src/typescript.d.ts +3 -3
  63. package/src/ngtsc/reflection/src/typescript.js +4 -2
  64. package/src/ngtsc/reflection/src/util.js +7 -4
  65. package/src/ngtsc/scope/src/local.js +1 -1
  66. package/src/ngtsc/sourcemaps/src/source_file.d.ts +3 -2
  67. package/src/ngtsc/sourcemaps/src/source_file.js +8 -7
  68. package/src/ngtsc/sourcemaps/src/source_file_loader.js +4 -5
  69. package/src/ngtsc/transform/src/compilation.d.ts +3 -3
  70. package/src/ngtsc/transform/src/compilation.js +1 -1
  71. package/src/ngtsc/typecheck/diagnostics/src/id.d.ts +2 -2
  72. package/src/ngtsc/typecheck/diagnostics/src/id.js +1 -1
  73. package/src/ngtsc/typecheck/src/type_parameter_emitter.js +1 -1
  74. package/src/ngtsc/util/src/typescript.d.ts +4 -1
  75. package/src/ngtsc/util/src/typescript.js +7 -2
  76. package/src/version.js +1 -1
@@ -8,7 +8,7 @@
8
8
  /// <amd-module name="@angular/compiler-cli/ngcc/src/host/esm2015_host" />
9
9
  import * as ts from 'typescript';
10
10
  import { Logger } from '../../../src/ngtsc/logging';
11
- import { ClassDeclaration, ClassMember, ClassMemberKind, CtorParameter, Declaration, Decorator, EnumMember, TypeScriptReflectionHost } from '../../../src/ngtsc/reflection';
11
+ import { ClassDeclaration, ClassMember, ClassMemberKind, CtorParameter, Declaration, DeclarationNode, Decorator, EnumMember, TypeScriptReflectionHost } from '../../../src/ngtsc/reflection';
12
12
  import { BundleProgram } from '../packages/bundle_program';
13
13
  import { NgccClassSymbol, NgccReflectionHost, SwitchableVariableDeclaration } from './ngcc_host';
14
14
  export declare const DECORATORS: ts.__String;
@@ -54,7 +54,7 @@ export declare class Esm2015ReflectionHost extends TypeScriptReflectionHost impl
54
54
  * tree. Note that by definition the key and value declarations will not be in the same TS
55
55
  * program.
56
56
  */
57
- protected publicDtsDeclarationMap: Map<ts.Declaration, ts.Declaration> | null;
57
+ protected publicDtsDeclarationMap: Map<DeclarationNode, ts.Declaration> | null;
58
58
  /**
59
59
  * A mapping from source declarations to typings declarations, which are not publicly exported.
60
60
  *
@@ -62,7 +62,7 @@ export declare class Esm2015ReflectionHost extends TypeScriptReflectionHost impl
62
62
  * the same name in both the source and the dts file. Note that by definition the key and value
63
63
  * declarations will not be in the same TS program.
64
64
  */
65
- protected privateDtsDeclarationMap: Map<ts.Declaration, ts.Declaration> | null;
65
+ protected privateDtsDeclarationMap: Map<DeclarationNode, ts.Declaration> | null;
66
66
  /**
67
67
  * The set of source files that have already been preprocessed.
68
68
  */
@@ -82,14 +82,14 @@ export declare class Esm2015ReflectionHost extends TypeScriptReflectionHost impl
82
82
  *
83
83
  * This map is populated during the preprocessing of each source file.
84
84
  */
85
- protected aliasedClassDeclarations: Map<ts.Declaration, ts.Identifier>;
85
+ protected aliasedClassDeclarations: Map<DeclarationNode, ts.Identifier>;
86
86
  /**
87
87
  * Caches the information of the decorators on a class, as the work involved with extracting
88
88
  * decorators is complex and frequently used.
89
89
  *
90
90
  * This map is lazily populated during the first call to `acquireDecoratorInfo` for a given class.
91
91
  */
92
- protected decoratorCache: Map<ClassDeclaration<ts.Declaration>, DecoratorInfo>;
92
+ protected decoratorCache: Map<ClassDeclaration<DeclarationNode>, DecoratorInfo>;
93
93
  constructor(logger: Logger, isCore: boolean, src: BundleProgram, dts?: BundleProgram | null);
94
94
  /**
95
95
  * Find a symbol for a node that we think is a class.
@@ -119,16 +119,17 @@ export declare class Esm2015ReflectionHost extends TypeScriptReflectionHost impl
119
119
  * Examine a declaration (for example, of a class or function) and return metadata about any
120
120
  * decorators present on the declaration.
121
121
  *
122
- * @param declaration a TypeScript `ts.Declaration` node representing the class or function over
123
- * which to reflect. For example, if the intent is to reflect the decorators of a class and the
124
- * source is in ES6 format, this will be a `ts.ClassDeclaration` node. If the source is in ES5
125
- * format, this might be a `ts.VariableDeclaration` as classes in ES5 are represented as the
126
- * result of an IIFE execution.
122
+ * @param declaration a TypeScript node representing the class or function over which to reflect.
123
+ * For example, if the intent is to reflect the decorators of a class and the source is in ES6
124
+ * format, this will be a `ts.ClassDeclaration` node. If the source is in ES5 format, this
125
+ * might be a `ts.VariableDeclaration` as classes in ES5 are represented as the result of an
126
+ * IIFE execution.
127
127
  *
128
128
  * @returns an array of `Decorator` metadata if decorators are present on the declaration, or
129
- * `null` if either no decorators were present or if the declaration is not of a decoratable type.
129
+ * `null` if either no decorators were present or if the declaration is not of a decoratable
130
+ * type.
130
131
  */
131
- getDecoratorsOfDeclaration(declaration: ts.Declaration): Decorator[] | null;
132
+ getDecoratorsOfDeclaration(declaration: DeclarationNode): Decorator[] | null;
132
133
  /**
133
134
  * Examine a declaration which should be of a class, and return metadata about the members of the
134
135
  * class.
@@ -220,7 +221,7 @@ export declare class Esm2015ReflectionHost extends TypeScriptReflectionHost impl
220
221
  * Note that the `ts.ClassDeclaration` returned from this function may not be from the same
221
222
  * `ts.Program` as the input declaration.
222
223
  */
223
- getDtsDeclaration(declaration: ts.Declaration): ts.Declaration | null;
224
+ getDtsDeclaration(declaration: DeclarationNode): ts.Declaration | null;
224
225
  getEndOfClass(classSymbol: NgccClassSymbol): ts.Node;
225
226
  /**
226
227
  * Check whether a `Declaration` corresponds with a known declaration, such as `Object`, and set
@@ -230,6 +231,16 @@ export declare class Esm2015ReflectionHost extends TypeScriptReflectionHost impl
230
231
  * @return The passed in `Declaration` (potentially enhanced with a `KnownDeclaration`).
231
232
  */
232
233
  detectKnownDeclaration<T extends Declaration>(decl: T): T;
234
+ /**
235
+ * Extract all the "classes" from the `statement` and add them to the `classes` map.
236
+ */
237
+ protected addClassSymbolsFromStatement(classes: Map<ts.Symbol, NgccClassSymbol>, statement: ts.Statement): void;
238
+ /**
239
+ * Compute the inner declaration node of a "class" from the given `declaration` node.
240
+ *
241
+ * @param declaration a node that is either an inner declaration or an alias of a class.
242
+ */
243
+ protected getInnerDeclarationFromAliasOrInner(declaration: ts.Node): ts.Node;
233
244
  /**
234
245
  * A class may be declared as a top level class declaration:
235
246
  *
@@ -309,7 +320,7 @@ export declare class Esm2015ReflectionHost extends TypeScriptReflectionHost impl
309
320
  * @returns the `NgccClassSymbol` representing the class, or undefined if a `ts.Symbol` for any of
310
321
  * the declarations could not be resolved.
311
322
  */
312
- protected createClassSymbol(outerDeclaration: ClassDeclaration, innerDeclaration: ts.Node | null): NgccClassSymbol | undefined;
323
+ protected createClassSymbol(outerDeclaration: ts.Identifier, innerDeclaration: ts.Node | null): NgccClassSymbol | undefined;
313
324
  private getAdjacentSymbol;
314
325
  /**
315
326
  * Resolve a `ts.Symbol` to its declaration and detect whether it corresponds with a known
@@ -327,7 +338,7 @@ export declare class Esm2015ReflectionHost extends TypeScriptReflectionHost impl
327
338
  * @returns The original identifier that the given class declaration resolves to, or `undefined`
328
339
  * if the declaration does not represent an aliased class.
329
340
  */
330
- protected resolveAliasedClassIdentifier(declaration: ts.Declaration): ts.Identifier | null;
341
+ protected resolveAliasedClassIdentifier(declaration: DeclarationNode): ts.Identifier | null;
331
342
  /**
332
343
  * Ensures that the source file that `node` is part of has been preprocessed.
333
344
  *
@@ -647,7 +658,7 @@ export declare class Esm2015ReflectionHost extends TypeScriptReflectionHost impl
647
658
  * @param dts the program bundle containing the typings files.
648
659
  * @returns a map of source declarations to typings declarations.
649
660
  */
650
- protected computePublicDtsDeclarationMap(src: BundleProgram, dts: BundleProgram): Map<ts.Declaration, ts.Declaration>;
661
+ protected computePublicDtsDeclarationMap(src: BundleProgram, dts: BundleProgram): Map<DeclarationNode, ts.Declaration>;
651
662
  /**
652
663
  * Create a mapping between the "private" exports in a src program and the "private" exports of a
653
664
  * dts program. These exports may be exported from individual files in the src or dts programs,
@@ -661,14 +672,14 @@ export declare class Esm2015ReflectionHost extends TypeScriptReflectionHost impl
661
672
  * @param dts the program bundle containing the typings files.
662
673
  * @returns a map of source declarations to typings declarations.
663
674
  */
664
- protected computePrivateDtsDeclarationMap(src: BundleProgram, dts: BundleProgram): Map<ts.Declaration, ts.Declaration>;
675
+ protected computePrivateDtsDeclarationMap(src: BundleProgram, dts: BundleProgram): Map<DeclarationNode, ts.Declaration>;
665
676
  /**
666
677
  * Collect mappings between names of exported declarations in a file and its actual declaration.
667
678
  *
668
679
  * Any new mappings are added to the `dtsDeclarationMap`.
669
680
  */
670
681
  protected collectDtsExportedDeclarations(dtsDeclarationMap: Map<string, ts.Declaration>, srcFile: ts.SourceFile, checker: ts.TypeChecker): void;
671
- protected collectSrcExportedDeclarations(declarationMap: Map<ts.Declaration, ts.Declaration>, dtsDeclarationMap: Map<string, ts.Declaration>, srcFile: ts.SourceFile): void;
682
+ protected collectSrcExportedDeclarations(declarationMap: Map<DeclarationNode, ts.Declaration>, dtsDeclarationMap: Map<string, ts.Declaration>, srcFile: ts.SourceFile): void;
672
683
  protected getDeclarationOfExpression(expression: ts.Expression): Declaration | null;
673
684
  /** Checks if the specified declaration resolves to the known JavaScript global `Object`. */
674
685
  protected isJavaScriptObjectDeclaration(decl: Declaration): boolean;
@@ -714,6 +725,7 @@ export declare class Esm2015ReflectionHost extends TypeScriptReflectionHost impl
714
725
  * @returns An `EnumMember` if the statement is according to the expected syntax, null otherwise.
715
726
  */
716
727
  protected reflectEnumMember(enumName: ts.Identifier, statement: ts.Statement): EnumMember | null;
728
+ private getAdjacentNameOfClassSymbol;
717
729
  }
718
730
  /**
719
731
  * An enum member assignment that looks like `Enum[X] = Y;`.
@@ -861,28 +873,71 @@ declare type InitializedVariableClassDeclaration = ClassDeclaration<ts.VariableD
861
873
  * var MyClass = alias1 = alias2 = <<declaration>>
862
874
  * ```
863
875
  *
864
- * @node the LHS of a variable declaration.
876
+ * @param node the LHS of a variable declaration.
865
877
  * @returns the original AST node or the RHS of a series of assignments in a variable
866
878
  * declaration.
867
879
  */
868
880
  export declare function skipClassAliases(node: InitializedVariableClassDeclaration): ts.Expression;
881
+ /**
882
+ * This expression could either be a class expression
883
+ *
884
+ * ```
885
+ * class MyClass {};
886
+ * ```
887
+ *
888
+ * or an IIFE wrapped class expression
889
+ *
890
+ * ```
891
+ * (() => {
892
+ * class MyClass {}
893
+ * ...
894
+ * return MyClass;
895
+ * })()
896
+ * ```
897
+ *
898
+ * or an IIFE wrapped aliased class expression
899
+ *
900
+ * ```
901
+ * (() => {
902
+ * let MyClass = class MyClass {}
903
+ * ...
904
+ * return MyClass;
905
+ * })()
906
+ * ```
907
+ *
908
+ * or an IFFE wrapped ES5 class function
909
+ *
910
+ * ```
911
+ * (function () {
912
+ * function MyClass() {}
913
+ * ...
914
+ * return MyClass
915
+ * })()
916
+ * ```
917
+ *
918
+ * @param expression the node that represents the class whose declaration we are finding.
919
+ * @returns the declaration of the class or `null` if it is not a "class".
920
+ */
921
+ export declare function getInnerClassDeclaration(expression: ts.Expression): ClassDeclaration<ts.ClassExpression | ts.ClassDeclaration | ts.FunctionDeclaration> | null;
869
922
  /**
870
923
  * Find the statement that contains the given node
871
924
  * @param node a node whose containing statement we wish to find
872
925
  */
873
926
  export declare function getContainingStatement(node: ts.Node): ts.Statement;
874
927
  /**
875
- * Get the actual (outer) declaration of a class.
928
+ * Get a node that represents the actual (outer) declaration of a class from its implementation.
876
929
  *
877
930
  * Sometimes, the implementation of a class is an expression that is hidden inside an IIFE and
878
- * returned to be assigned to a variable outside the IIFE, which is what the rest of the program
879
- * interacts with.
931
+ * assigned to a variable outside the IIFE, which is what the rest of the program interacts with.
932
+ * For example,
880
933
  *
881
- * Given the inner declaration, we want to get to the declaration of the outer variable that
882
- * represents the class.
934
+ * ```
935
+ * OuterNode = Alias = (function() { function InnerNode() {} return InnerNode; })();
936
+ * ```
883
937
  *
884
- * @param node a node that could be the inner declaration inside an IIFE.
885
- * @returns the outer variable declaration or `null` if it is not a "class".
938
+ * @param node a node that could be the implementation inside an IIFE.
939
+ * @returns a node that represents the outer declaration, or `null` if it is does not match the IIFE
940
+ * format shown above.
886
941
  */
887
- export declare function getClassDeclarationFromInnerDeclaration(node: ts.Node): ClassDeclaration<ts.VariableDeclaration> | null;
942
+ export declare function getOuterNodeFromInnerDeclaration(node: ts.Node): ts.Node | null;
888
943
  export {};