@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
@@ -6,61 +6,35 @@
6
6
  * found in the LICENSE file at https://angular.io/license
7
7
  */
8
8
  /// <amd-module name="@angular/compiler-cli/src/ngtsc/typecheck/src/context" />
9
- import { BoundTarget, ParseSourceFile, SchemaMetadata } from '@angular/compiler';
9
+ import { ParseSourceFile, R3TargetBinder, SchemaMetadata, TmplAstNode } from '@angular/compiler';
10
10
  import * as ts from 'typescript';
11
11
  import { AbsoluteFsPath } from '../../file_system';
12
12
  import { Reference, ReferenceEmitter } from '../../imports';
13
13
  import { ClassDeclaration, ReflectionHost } from '../../reflection';
14
- import { TemplateSourceMapping, TypeCheckableDirectiveMeta, TypeCheckingConfig, TypeCtorMetadata } from './api';
15
- import { TemplateSourceResolver } from './diagnostics';
14
+ import { ComponentToShimMappingStrategy, TemplateSourceMapping, TypeCheckableDirectiveMeta, TypeCheckContext, TypeCheckingConfig, TypeCtorMetadata } from '../api';
15
+ import { TemplateDiagnostic } from './diagnostics';
16
16
  import { DomSchemaChecker } from './dom';
17
17
  import { OutOfBandDiagnosticRecorder } from './oob';
18
18
  import { TemplateSourceManager } from './source';
19
19
  import { TypeCheckFile } from './type_check_file';
20
- /**
21
- * Complete type-checking code generated for the user's program, ready for input into the
22
- * type-checking engine.
23
- */
24
- export interface TypeCheckRequest {
25
- /**
26
- * Map of source filenames to new contents for those files.
27
- *
28
- * This includes both contents of type-checking shim files, as well as changes to any user files
29
- * which needed to be made to support template type-checking.
30
- */
31
- updates: Map<AbsoluteFsPath, string>;
32
- /**
33
- * Map containing additional data for each type-checking shim that is required to support
34
- * generation of diagnostics.
35
- */
36
- perFileData: Map<AbsoluteFsPath, FileTypeCheckingData>;
37
- }
38
- /**
39
- * Data for a type-checking shim which is required to support generation of diagnostics.
40
- */
41
- export interface FileTypeCheckingData {
42
- /**
43
- * Whether the type-checking shim required any inline changes to the original file, which affects
44
- * whether the shim can be reused.
45
- */
46
- hasInlines: boolean;
20
+ export interface ShimTypeCheckingData {
47
21
  /**
48
- * Source mapping information for mapping diagnostics back to the original template.
22
+ * Path to the shim file.
49
23
  */
50
- sourceResolver: TemplateSourceResolver;
24
+ path: AbsoluteFsPath;
51
25
  /**
52
26
  * Any `ts.Diagnostic`s which were produced during the generation of this shim.
53
27
  *
54
28
  * Some diagnostics are produced during creation time and are tracked here.
55
29
  */
56
- genesisDiagnostics: ts.Diagnostic[];
30
+ genesisDiagnostics: TemplateDiagnostic[];
57
31
  /**
58
- * Path to the shim file.
32
+ * Whether any inline operations for the input file were required to generate this shim.
59
33
  */
60
- typeCheckFile: AbsoluteFsPath;
34
+ hasInlines: boolean;
61
35
  }
62
36
  /**
63
- * Data for a type-checking shim which is still having its code generated.
37
+ * Data for an input file which is still in the process of template type-checking code generation.
64
38
  */
65
39
  export interface PendingFileTypeCheckingData {
66
40
  /**
@@ -68,9 +42,16 @@ export interface PendingFileTypeCheckingData {
68
42
  */
69
43
  hasInlines: boolean;
70
44
  /**
71
- * `TemplateSourceManager` being used to track source mapping information for this shim.
45
+ * Source mapping information for mapping diagnostics from inlined type check blocks back to the
46
+ * original template.
72
47
  */
73
48
  sourceManager: TemplateSourceManager;
49
+ /**
50
+ * Map of in-progress shim data for shims generated from this input file.
51
+ */
52
+ shimData: Map<AbsoluteFsPath, PendingShimData>;
53
+ }
54
+ export interface PendingShimData {
74
55
  /**
75
56
  * Recorder for out-of-band diagnostics which are raised during generation.
76
57
  */
@@ -80,9 +61,57 @@ export interface PendingFileTypeCheckingData {
80
61
  */
81
62
  domSchemaChecker: DomSchemaChecker;
82
63
  /**
83
- * Path to the shim file.
64
+ * Shim file in the process of being generated.
84
65
  */
85
- typeCheckFile: TypeCheckFile;
66
+ file: TypeCheckFile;
67
+ }
68
+ /**
69
+ * Adapts the `TypeCheckContextImpl` to the larger template type-checking system.
70
+ *
71
+ * Through this interface, a single `TypeCheckContextImpl` (which represents one "pass" of template
72
+ * type-checking) requests information about the larger state of type-checking, as well as reports
73
+ * back its results once finalized.
74
+ */
75
+ export interface TypeCheckingHost {
76
+ /**
77
+ * Retrieve the `TemplateSourceManager` responsible for components in the given input file path.
78
+ */
79
+ getSourceManager(sfPath: AbsoluteFsPath): TemplateSourceManager;
80
+ /**
81
+ * Whether a particular component class should be included in the current type-checking pass.
82
+ *
83
+ * Not all components offered to the `TypeCheckContext` for checking may require processing. For
84
+ * example, the component may have results already available from a prior pass or from a previous
85
+ * program.
86
+ */
87
+ shouldCheckComponent(node: ts.ClassDeclaration): boolean;
88
+ /**
89
+ * Check if the given component has had its template overridden, and retrieve the new template
90
+ * nodes if so.
91
+ */
92
+ getTemplateOverride(sfPath: AbsoluteFsPath, node: ts.ClassDeclaration): TmplAstNode[] | null;
93
+ /**
94
+ * Report data from a shim generated from the given input file path.
95
+ */
96
+ recordShimData(sfPath: AbsoluteFsPath, data: ShimTypeCheckingData): void;
97
+ /**
98
+ * Record that all of the components within the given input file path had code generated - that
99
+ * is, coverage for the file can be considered complete.
100
+ */
101
+ recordComplete(sfPath: AbsoluteFsPath): void;
102
+ }
103
+ /**
104
+ * How a type-checking context should handle operations which would require inlining.
105
+ */
106
+ export declare enum InliningMode {
107
+ /**
108
+ * Use inlining operations when required.
109
+ */
110
+ InlineOps = 0,
111
+ /**
112
+ * Produce diagnostics if an operation would require inlining.
113
+ */
114
+ Error = 1
86
115
  }
87
116
  /**
88
117
  * A template type checking context for a program.
@@ -90,13 +119,16 @@ export interface PendingFileTypeCheckingData {
90
119
  * The `TypeCheckContext` allows registration of components and their templates which need to be
91
120
  * type checked.
92
121
  */
93
- export declare class TypeCheckContext {
122
+ export declare class TypeCheckContextImpl implements TypeCheckContext {
94
123
  private config;
95
124
  private compilerHost;
125
+ private componentMappingStrategy;
96
126
  private refEmitter;
97
127
  private reflector;
128
+ private host;
129
+ private inlining;
98
130
  private fileMap;
99
- constructor(config: TypeCheckingConfig, compilerHost: Pick<ts.CompilerHost, 'getCanonicalFileName'>, refEmitter: ReferenceEmitter, reflector: ReflectionHost);
131
+ constructor(config: TypeCheckingConfig, compilerHost: Pick<ts.CompilerHost, 'getCanonicalFileName'>, componentMappingStrategy: ComponentToShimMappingStrategy, refEmitter: ReferenceEmitter, reflector: ReflectionHost, host: TypeCheckingHost, inlining: InliningMode);
100
132
  /**
101
133
  * A `Map` of `ts.SourceFile`s that the context has seen to the operations (additions of methods
102
134
  * or type-check blocks) that need to be eventually performed on that file.
@@ -107,18 +139,6 @@ export declare class TypeCheckContext {
107
139
  * queued.
108
140
  */
109
141
  private typeCtorPending;
110
- /**
111
- * Map of data for file paths which was adopted from a prior compilation.
112
- *
113
- * This data allows the `TypeCheckContext` to generate a `TypeCheckRequest` which can interpret
114
- * diagnostics from type-checking shims included in the prior compilation.
115
- */
116
- private adoptedFiles;
117
- /**
118
- * Record the `FileTypeCheckingData` from a previous program that's associated with a particular
119
- * source file.
120
- */
121
- adoptPriorResults(sf: ts.SourceFile, data: FileTypeCheckingData): void;
122
142
  /**
123
143
  * Record a template for the given component `node`, with a `SelectorMatcher` for directive
124
144
  * matching.
@@ -127,7 +147,7 @@ export declare class TypeCheckContext {
127
147
  * @param template AST nodes of the template being recorded.
128
148
  * @param matcher `SelectorMatcher` which tracks directives that are in scope for this template.
129
149
  */
130
- addTemplate(ref: Reference<ClassDeclaration<ts.ClassDeclaration>>, boundTarget: BoundTarget<TypeCheckableDirectiveMeta>, pipes: Map<string, Reference<ClassDeclaration<ts.ClassDeclaration>>>, schemas: SchemaMetadata[], sourceMapping: TemplateSourceMapping, file: ParseSourceFile): void;
150
+ addTemplate(ref: Reference<ClassDeclaration<ts.ClassDeclaration>>, binder: R3TargetBinder<TypeCheckableDirectiveMeta>, template: TmplAstNode[], pipes: Map<string, Reference<ClassDeclaration<ts.ClassDeclaration>>>, schemas: SchemaMetadata[], sourceMapping: TemplateSourceMapping, file: ParseSourceFile): void;
131
151
  /**
132
152
  * Record a type constructor for the given `node` with the given `ctorMetadata`.
133
153
  */
@@ -139,7 +159,8 @@ export declare class TypeCheckContext {
139
159
  * will be returned. Otherwise, a `null` return indicates no changes were necessary.
140
160
  */
141
161
  transform(sf: ts.SourceFile): string | null;
142
- finalize(): TypeCheckRequest;
162
+ finalize(): Map<AbsoluteFsPath, string>;
143
163
  private addInlineTypeCheckBlock;
164
+ private pendingShimForComponent;
144
165
  private dataForFile;
145
166
  }