@angular/compiler-cli 10.1.2 → 10.1.6

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 (94) 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 +0 -1
  11. package/ngcc/src/host/commonjs_host.js +28 -19
  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 +95 -31
  17. package/ngcc/src/host/esm2015_host.js +165 -113
  18. package/ngcc/src/host/esm5_host.js +7 -7
  19. package/ngcc/src/host/umd_host.d.ts +16 -1
  20. package/ngcc/src/host/umd_host.js +190 -25
  21. package/ngcc/src/migrations/missing_injectable_migration.js +1 -1
  22. package/ngcc/src/migrations/undecorated_parent_migration.js +1 -1
  23. package/ngcc/src/migrations/utils.d.ts +1 -1
  24. package/ngcc/src/migrations/utils.js +1 -1
  25. package/ngcc/src/packages/build_marker.d.ts +1 -1
  26. package/ngcc/src/packages/build_marker.js +1 -1
  27. package/ngcc/src/rendering/renderer.js +9 -10
  28. package/ngcc/src/utils.d.ts +3 -3
  29. package/ngcc/src/utils.js +1 -1
  30. package/package.json +2 -2
  31. package/src/ngtsc/annotations/src/component.js +1 -1
  32. package/src/ngtsc/annotations/src/directive.js +9 -3
  33. package/src/ngtsc/annotations/src/metadata.d.ts +2 -3
  34. package/src/ngtsc/annotations/src/metadata.js +1 -1
  35. package/src/ngtsc/annotations/src/ng_module.js +4 -9
  36. package/src/ngtsc/annotations/src/references_registry.d.ts +3 -3
  37. package/src/ngtsc/annotations/src/references_registry.js +1 -1
  38. package/src/ngtsc/core/src/compiler.d.ts +2 -1
  39. package/src/ngtsc/core/src/compiler.js +5 -1
  40. package/src/ngtsc/entry_point/src/private_export_checker.js +1 -1
  41. package/src/ngtsc/entry_point/src/reference_graph.d.ts +2 -2
  42. package/src/ngtsc/entry_point/src/reference_graph.js +1 -1
  43. package/src/ngtsc/file_system/testing/src/mock_file_system.d.ts +3 -1
  44. package/src/ngtsc/file_system/testing/src/mock_file_system.js +29 -10
  45. package/src/ngtsc/imports/src/emitter.d.ts +2 -2
  46. package/src/ngtsc/imports/src/emitter.js +2 -6
  47. package/src/ngtsc/indexer/src/api.d.ts +2 -3
  48. package/src/ngtsc/indexer/src/api.js +1 -1
  49. package/src/ngtsc/indexer/src/template.js +10 -24
  50. package/src/ngtsc/indexer/src/transform.d.ts +2 -2
  51. package/src/ngtsc/indexer/src/transform.js +1 -1
  52. package/src/ngtsc/modulewithproviders/src/scanner.js +2 -2
  53. package/src/ngtsc/partial_evaluator/src/interpreter.d.ts +1 -0
  54. package/src/ngtsc/partial_evaluator/src/interpreter.js +13 -20
  55. package/src/ngtsc/perf/src/api.d.ts +3 -3
  56. package/src/ngtsc/perf/src/api.js +1 -1
  57. package/src/ngtsc/perf/src/noop.d.ts +0 -7
  58. package/src/ngtsc/perf/src/noop.js +1 -8
  59. package/src/ngtsc/perf/src/tracking.d.ts +3 -2
  60. package/src/ngtsc/perf/src/tracking.js +1 -1
  61. package/src/ngtsc/program.d.ts +2 -1
  62. package/src/ngtsc/program.js +1 -1
  63. package/src/ngtsc/reflection/src/host.d.ts +39 -22
  64. package/src/ngtsc/reflection/src/host.js +10 -2
  65. package/src/ngtsc/reflection/src/typescript.d.ts +3 -3
  66. package/src/ngtsc/reflection/src/typescript.js +4 -2
  67. package/src/ngtsc/reflection/src/util.js +7 -4
  68. package/src/ngtsc/scope/src/local.js +1 -1
  69. package/src/ngtsc/sourcemaps/src/source_file.d.ts +3 -2
  70. package/src/ngtsc/sourcemaps/src/source_file.js +8 -7
  71. package/src/ngtsc/sourcemaps/src/source_file_loader.js +4 -5
  72. package/src/ngtsc/transform/src/compilation.d.ts +3 -3
  73. package/src/ngtsc/transform/src/compilation.js +1 -1
  74. package/src/ngtsc/translator/index.d.ts +1 -1
  75. package/src/ngtsc/translator/index.js +3 -2
  76. package/src/ngtsc/translator/src/translator.d.ts +8 -1
  77. package/src/ngtsc/translator/src/translator.js +79 -25
  78. package/src/ngtsc/typecheck/api/api.d.ts +5 -0
  79. package/src/ngtsc/typecheck/api/api.js +1 -1
  80. package/src/ngtsc/typecheck/diagnostics/src/id.d.ts +2 -2
  81. package/src/ngtsc/typecheck/diagnostics/src/id.js +1 -1
  82. package/src/ngtsc/typecheck/src/environment.js +2 -2
  83. package/src/ngtsc/typecheck/src/host.d.ts +41 -11
  84. package/src/ngtsc/typecheck/src/host.js +53 -36
  85. package/src/ngtsc/typecheck/src/type_check_block.js +60 -1
  86. package/src/ngtsc/typecheck/src/type_parameter_emitter.js +1 -1
  87. package/src/ngtsc/util/src/typescript.d.ts +4 -1
  88. package/src/ngtsc/util/src/typescript.js +7 -2
  89. package/src/transformers/node_emitter.d.ts +2 -8
  90. package/src/transformers/node_emitter.js +54 -68
  91. package/src/transformers/node_emitter_transform.js +8 -8
  92. package/src/transformers/util.d.ts +6 -0
  93. package/src/transformers/util.js +11 -2
  94. 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
  *
@@ -563,12 +574,21 @@ export declare class Esm2015ReflectionHost extends TypeScriptReflectionHost impl
563
574
  /**
564
575
  * Compute the `TypeValueReference` for the given `typeExpression`.
565
576
  *
566
- * In ngcc, all the `typeExpression` are guaranteed to be "values" because it is working in JS and
567
- * not TS. This means that the TS compiler is not going to remove the "type" import and so we can
568
- * always use a LOCAL `TypeValueReference` kind, rather than trying to force an additional import
569
- * for non-local expressions.
577
+ * Although `typeExpression` is a valid `ts.Expression` that could be emitted directly into the
578
+ * generated code, ngcc still needs to resolve the declaration and create an `IMPORTED` type
579
+ * value reference as the compiler has specialized handling for some symbols, for example
580
+ * `ChangeDetectorRef` from `@angular/core`. Such an `IMPORTED` type value reference will result
581
+ * in a newly generated namespace import, instead of emitting the original `typeExpression` as is.
570
582
  */
571
583
  private typeToValue;
584
+ /**
585
+ * Determines where the `expression` is imported from.
586
+ *
587
+ * @param expression the expression to determine the import details for.
588
+ * @returns the `Import` for the expression, or `null` if the expression is not imported or the
589
+ * expression syntax is not supported.
590
+ */
591
+ private getImportOfExpression;
572
592
  /**
573
593
  * Get the parameter type and decorators for the constructor of a class,
574
594
  * where the information is stored on a static property of the class.
@@ -638,7 +658,7 @@ export declare class Esm2015ReflectionHost extends TypeScriptReflectionHost impl
638
658
  * @param dts the program bundle containing the typings files.
639
659
  * @returns a map of source declarations to typings declarations.
640
660
  */
641
- protected computePublicDtsDeclarationMap(src: BundleProgram, dts: BundleProgram): Map<ts.Declaration, ts.Declaration>;
661
+ protected computePublicDtsDeclarationMap(src: BundleProgram, dts: BundleProgram): Map<DeclarationNode, ts.Declaration>;
642
662
  /**
643
663
  * Create a mapping between the "private" exports in a src program and the "private" exports of a
644
664
  * dts program. These exports may be exported from individual files in the src or dts programs,
@@ -652,14 +672,14 @@ export declare class Esm2015ReflectionHost extends TypeScriptReflectionHost impl
652
672
  * @param dts the program bundle containing the typings files.
653
673
  * @returns a map of source declarations to typings declarations.
654
674
  */
655
- protected computePrivateDtsDeclarationMap(src: BundleProgram, dts: BundleProgram): Map<ts.Declaration, ts.Declaration>;
675
+ protected computePrivateDtsDeclarationMap(src: BundleProgram, dts: BundleProgram): Map<DeclarationNode, ts.Declaration>;
656
676
  /**
657
677
  * Collect mappings between names of exported declarations in a file and its actual declaration.
658
678
  *
659
679
  * Any new mappings are added to the `dtsDeclarationMap`.
660
680
  */
661
681
  protected collectDtsExportedDeclarations(dtsDeclarationMap: Map<string, ts.Declaration>, srcFile: ts.SourceFile, checker: ts.TypeChecker): void;
662
- 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;
663
683
  protected getDeclarationOfExpression(expression: ts.Expression): Declaration | null;
664
684
  /** Checks if the specified declaration resolves to the known JavaScript global `Object`. */
665
685
  protected isJavaScriptObjectDeclaration(decl: Declaration): boolean;
@@ -705,6 +725,7 @@ export declare class Esm2015ReflectionHost extends TypeScriptReflectionHost impl
705
725
  * @returns An `EnumMember` if the statement is according to the expected syntax, null otherwise.
706
726
  */
707
727
  protected reflectEnumMember(enumName: ts.Identifier, statement: ts.Statement): EnumMember | null;
728
+ private getAdjacentNameOfClassSymbol;
708
729
  }
709
730
  /**
710
731
  * An enum member assignment that looks like `Enum[X] = Y;`.
@@ -852,28 +873,71 @@ declare type InitializedVariableClassDeclaration = ClassDeclaration<ts.VariableD
852
873
  * var MyClass = alias1 = alias2 = <<declaration>>
853
874
  * ```
854
875
  *
855
- * @node the LHS of a variable declaration.
876
+ * @param node the LHS of a variable declaration.
856
877
  * @returns the original AST node or the RHS of a series of assignments in a variable
857
878
  * declaration.
858
879
  */
859
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;
860
922
  /**
861
923
  * Find the statement that contains the given node
862
924
  * @param node a node whose containing statement we wish to find
863
925
  */
864
926
  export declare function getContainingStatement(node: ts.Node): ts.Statement;
865
927
  /**
866
- * Get the actual (outer) declaration of a class.
928
+ * Get a node that represents the actual (outer) declaration of a class from its implementation.
867
929
  *
868
930
  * Sometimes, the implementation of a class is an expression that is hidden inside an IIFE and
869
- * returned to be assigned to a variable outside the IIFE, which is what the rest of the program
870
- * interacts with.
931
+ * assigned to a variable outside the IIFE, which is what the rest of the program interacts with.
932
+ * For example,
871
933
  *
872
- * Given the inner declaration, we want to get to the declaration of the outer variable that
873
- * represents the class.
934
+ * ```
935
+ * OuterNode = Alias = (function() { function InnerNode() {} return InnerNode; })();
936
+ * ```
874
937
  *
875
- * @param node a node that could be the inner declaration inside an IIFE.
876
- * @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.
877
941
  */
878
- export declare function getClassDeclarationFromInnerDeclaration(node: ts.Node): ClassDeclaration<ts.VariableDeclaration> | null;
942
+ export declare function getOuterNodeFromInnerDeclaration(node: ts.Node): ts.Node | null;
879
943
  export {};