@angular/compiler-cli 20.0.0-next.1 → 20.0.0-next.2

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 (53) hide show
  1. package/bundles/{chunk-QYORKQDN.js → chunk-7HRFJETP.js} +3 -2
  2. package/bundles/{chunk-QYORKQDN.js.map → chunk-7HRFJETP.js.map} +1 -1
  3. package/bundles/{chunk-YSSSYIZJ.js → chunk-B73DMM7T.js} +2 -2
  4. package/bundles/{chunk-PLKJMRGZ.js → chunk-CD575TJ6.js} +276 -205
  5. package/bundles/chunk-CD575TJ6.js.map +6 -0
  6. package/bundles/{chunk-SNXU6YPZ.js → chunk-FVYXSSAL.js} +2 -2
  7. package/bundles/{chunk-SEPXPBD2.js → chunk-PAYJFU4V.js} +3 -3
  8. package/bundles/{chunk-O2OVHMWL.js → chunk-RFDMMGNB.js} +60 -29
  9. package/bundles/chunk-RFDMMGNB.js.map +6 -0
  10. package/bundles/{chunk-UAA7BTBW.js → chunk-SWJRL4N4.js} +3 -3
  11. package/bundles/index.js +6 -6
  12. package/bundles/linker/babel/index.js +2 -2
  13. package/bundles/linker/index.js +2 -2
  14. package/bundles/private/migrations.js +4 -4
  15. package/bundles/private/tooling.js +4 -4
  16. package/bundles/src/bin/ng_xi18n.js +5 -5
  17. package/bundles/src/bin/ngc.js +5 -5
  18. package/bundles_metadata.json +1 -1
  19. package/linker/src/file_linker/partial_linkers/util.d.ts +1 -1
  20. package/package.json +2 -2
  21. package/private/migrations.d.ts +1 -1
  22. package/src/ngtsc/annotations/common/src/evaluation.d.ts +1 -1
  23. package/src/ngtsc/annotations/common/src/util.d.ts +19 -2
  24. package/src/ngtsc/annotations/component/src/metadata.d.ts +2 -2
  25. package/src/ngtsc/annotations/component/src/resources.d.ts +3 -2
  26. package/src/ngtsc/annotations/index.d.ts +1 -1
  27. package/src/ngtsc/core/api/src/options.d.ts +8 -0
  28. package/src/ngtsc/core/src/compiler.d.ts +3 -3
  29. package/src/ngtsc/docs/src/function_extractor.d.ts +1 -1
  30. package/src/ngtsc/hmr/src/update_declaration.d.ts +3 -2
  31. package/src/ngtsc/metadata/index.d.ts +1 -1
  32. package/src/ngtsc/metadata/src/resource_registry.d.ts +9 -8
  33. package/src/ngtsc/typecheck/api/api.d.ts +22 -24
  34. package/src/ngtsc/typecheck/api/checker.d.ts +3 -3
  35. package/src/ngtsc/typecheck/api/context.d.ts +26 -17
  36. package/src/ngtsc/typecheck/diagnostics/src/diagnostic.d.ts +2 -2
  37. package/src/ngtsc/typecheck/diagnostics/src/id.d.ts +2 -2
  38. package/src/ngtsc/typecheck/src/checker.d.ts +6 -6
  39. package/src/ngtsc/typecheck/src/completion.d.ts +2 -2
  40. package/src/ngtsc/typecheck/src/context.d.ts +24 -26
  41. package/src/ngtsc/typecheck/src/diagnostics.d.ts +5 -5
  42. package/src/ngtsc/typecheck/src/dom.d.ts +5 -5
  43. package/src/ngtsc/typecheck/src/oob.d.ts +41 -45
  44. package/src/ngtsc/typecheck/src/source.d.ts +11 -11
  45. package/src/ngtsc/typecheck/src/tcb_util.d.ts +15 -15
  46. package/src/ngtsc/typecheck/src/template_symbol_builder.d.ts +3 -3
  47. package/src/ngtsc/typecheck/src/type_check_block.d.ts +3 -3
  48. package/bundles/chunk-O2OVHMWL.js.map +0 -6
  49. package/bundles/chunk-PLKJMRGZ.js.map +0 -6
  50. /package/bundles/{chunk-YSSSYIZJ.js.map → chunk-B73DMM7T.js.map} +0 -0
  51. /package/bundles/{chunk-SNXU6YPZ.js.map → chunk-FVYXSSAL.js.map} +0 -0
  52. /package/bundles/{chunk-SEPXPBD2.js.map → chunk-PAYJFU4V.js.map} +0 -0
  53. /package/bundles/{chunk-UAA7BTBW.js.map → chunk-SWJRL4N4.js.map} +0 -0
@@ -7,7 +7,7 @@
7
7
  */
8
8
  import { MaybeForwardRefExpression, outputAst as o, R3DeclareDependencyMetadata, R3DependencyMetadata, R3Reference } from '@angular/compiler';
9
9
  import { AstObject, AstValue } from '../../ast/ast_value';
10
- export declare const PLACEHOLDER_VERSION = "20.0.0-next.1";
10
+ export declare const PLACEHOLDER_VERSION = "20.0.0-next.2";
11
11
  export declare function wrapReference<TExpression>(wrapped: o.WrappedNodeExpr<TExpression>): R3Reference;
12
12
  /**
13
13
  * Parses the value of an enum from the AST value's symbol name.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@angular/compiler-cli",
3
- "version": "20.0.0-next.1",
3
+ "version": "20.0.0-next.2",
4
4
  "description": "Angular - the compiler CLI for Node.js",
5
5
  "typings": "index.d.ts",
6
6
  "bin": {
@@ -52,7 +52,7 @@
52
52
  "yargs": "^17.2.1"
53
53
  },
54
54
  "peerDependencies": {
55
- "@angular/compiler": "20.0.0-next.1",
55
+ "@angular/compiler": "20.0.0-next.2",
56
56
  "typescript": ">=5.8 <5.9"
57
57
  },
58
58
  "repository": {
@@ -9,7 +9,7 @@
9
9
  * @fileoverview The API from compiler-cli that the `@angular/core`
10
10
  * package requires for migration schematics.
11
11
  */
12
- export { forwardRefResolver } from '../src/ngtsc/annotations';
12
+ export { createForwardRefResolver } from '../src/ngtsc/annotations';
13
13
  export { AbsoluteFsPath } from '../src/ngtsc/file_system';
14
14
  export { Reference } from '../src/ngtsc/imports';
15
15
  export { DynamicValue, PartialEvaluator, ResolvedValue, ResolvedValueMap, StaticInterpreter, } from '../src/ngtsc/partial_evaluator';
@@ -9,7 +9,7 @@ import ts from 'typescript';
9
9
  import { Reference } from '../../../imports';
10
10
  import { PartialEvaluator, ResolvedValue } from '../../../partial_evaluator';
11
11
  import { ClassDeclaration, Decorator } from '../../../reflection';
12
- export declare function resolveEnumValue(evaluator: PartialEvaluator, metadata: Map<string, ts.Expression>, field: string, enumSymbolName: string): number | null;
12
+ export declare function resolveEnumValue(evaluator: PartialEvaluator, metadata: Map<string, ts.Expression>, field: string, enumSymbolName: string, isCore: boolean): number | null;
13
13
  /**
14
14
  * Resolves a EncapsulationEnum expression locally on best effort without having to calculate the
15
15
  * reference. This suites local compilation mode where each file is compiled individually.
@@ -26,7 +26,24 @@ export declare function toR3Reference(origin: ts.Node, ref: Reference, context:
26
26
  export declare function isAngularCore(decorator: Decorator): decorator is Decorator & {
27
27
  import: Import;
28
28
  };
29
- export declare function isAngularCoreReference(reference: Reference, symbolName: string): boolean;
29
+ /**
30
+ * This function is used for verifying that a given reference is declared
31
+ * inside `@angular/core` and corresponds to the given symbol name.
32
+ *
33
+ * In some cases, due to the compiler face duplicating many symbols as
34
+ * an independent bridge between core and the compiler, the dts bundler may
35
+ * decide to alias declarations in the `.d.ts`, to avoid conflicts.
36
+ *
37
+ * e.g.
38
+ *
39
+ * ```
40
+ * declare enum ViewEncapsulation {} // from the facade
41
+ * declare enum ViewEncapsulation$1 {} // the real one exported to users.
42
+ * ```
43
+ *
44
+ * This function accounts for such potential re-namings.
45
+ */
46
+ export declare function isAngularCoreReferenceWithPotentialAliasing(reference: Reference, symbolName: string, isCore: boolean): boolean;
30
47
  export declare function findAngularDecorator(decorators: Decorator[], name: string, isCore: boolean): Decorator | undefined;
31
48
  export declare function isAngularDecorator(decorator: Decorator, name: string, isCore: boolean): boolean;
32
49
  export declare function getAngularDecorators(decorators: Decorator[], names: readonly string[], isCore: boolean): Decorator[];
@@ -55,7 +72,7 @@ export declare function tryUnwrapForwardRef(node: ts.Expression, reflector: Refl
55
72
  * @param args the arguments to the invocation of the forwardRef expression
56
73
  * @returns an unwrapped argument if `ref` pointed to forwardRef, or null otherwise
57
74
  */
58
- export declare const forwardRefResolver: ForeignFunctionResolver;
75
+ export declare function createForwardRefResolver(isCore: boolean): ForeignFunctionResolver;
59
76
  /**
60
77
  * Combines an array of resolver functions into a one.
61
78
  * @param resolvers Resolvers to be combined.
@@ -8,7 +8,7 @@
8
8
  import { AnimationTriggerNames, DeclarationListEmitMode, DeferBlockDepsEmitMode, R3ClassDebugInfo, R3ClassMetadata, R3ComponentMetadata, R3DeferPerBlockDependency, R3DeferPerComponentDependency, R3TemplateDependencyMetadata, SchemaMetadata, TmplAstDeferredBlock } from '@angular/compiler';
9
9
  import ts from 'typescript';
10
10
  import { Reference } from '../../../imports';
11
- import { ClassPropertyMapping, ComponentResources, DirectiveTypeCheckMeta, HostDirectiveMeta, InputMapping } from '../../../metadata';
11
+ import { ClassPropertyMapping, DirectiveResources, DirectiveTypeCheckMeta, HostDirectiveMeta, InputMapping } from '../../../metadata';
12
12
  import { ClassDeclaration } from '../../../reflection';
13
13
  import { SubsetOfKeys } from '../../../util/src/typescript';
14
14
  import { ParsedTemplateWithSource, StyleUrlMeta } from './resources';
@@ -43,7 +43,7 @@ export interface ComponentAnalysisData {
43
43
  * require an Angular factory definition at runtime.
44
44
  */
45
45
  viewProvidersRequiringFactory: Set<Reference<ClassDeclaration>> | null;
46
- resources: ComponentResources;
46
+ resources: DirectiveResources;
47
47
  /**
48
48
  * `styleUrls` extracted from the decorator, if present.
49
49
  */
@@ -13,7 +13,7 @@ import { Resource } from '../../../metadata';
13
13
  import { PartialEvaluator } from '../../../partial_evaluator';
14
14
  import { ClassDeclaration, DeclarationNode, Decorator } from '../../../reflection';
15
15
  import { CompilationMode } from '../../../transform';
16
- import { TemplateSourceMapping } from '../../../typecheck/api';
16
+ import { SourceMapping } from '../../../typecheck/api';
17
17
  import { ResourceLoader } from '../../common';
18
18
  /**
19
19
  * The literal style url extracted from the decorator, along with metadata for diagnostics.
@@ -58,7 +58,7 @@ export interface ParsedComponentTemplate extends ParsedTemplate {
58
58
  export interface ParsedTemplateWithSource extends ParsedComponentTemplate {
59
59
  /** The string contents of the template. */
60
60
  content: string;
61
- sourceMapping: TemplateSourceMapping;
61
+ sourceMapping: SourceMapping;
62
62
  declaration: TemplateDeclaration;
63
63
  }
64
64
  /**
@@ -104,6 +104,7 @@ export interface ExtractTemplateOptions {
104
104
  preserveSignificantWhitespace?: boolean;
105
105
  }
106
106
  export declare function extractTemplate(node: ClassDeclaration, template: TemplateDeclaration, evaluator: PartialEvaluator, depTracker: DependencyTracker | null, resourceLoader: ResourceLoader, options: ExtractTemplateOptions, compilationMode: CompilationMode): ParsedTemplateWithSource;
107
+ export declare function createEmptyTemplate(componentClass: ClassDeclaration, component: Map<string, ts.Expression>, containingFile: string): ParsedTemplateWithSource;
107
108
  export declare function parseTemplateDeclaration(node: ClassDeclaration, decorator: Decorator, component: Map<string, ts.Expression>, containingFile: string, evaluator: PartialEvaluator, depTracker: DependencyTracker | null, resourceLoader: ResourceLoader, defaultPreserveWhitespaces: boolean): TemplateDeclaration;
108
109
  export declare function preloadAndParseTemplate(evaluator: PartialEvaluator, resourceLoader: ResourceLoader, depTracker: DependencyTracker | null, preanalyzeTemplateCache: Map<DeclarationNode, ParsedTemplateWithSource>, node: ClassDeclaration, decorator: Decorator, component: Map<string, ts.Expression>, containingFile: string, defaultPreserveWhitespaces: boolean, options: ExtractTemplateOptions, compilationMode: CompilationMode): Promise<ParsedTemplateWithSource | null>;
109
110
  export declare function makeResourceNotFoundError(file: string, nodeForError: ts.Node, resourceType: ResourceTypeForDiagnostics): FatalDiagnosticError;
@@ -5,7 +5,7 @@
5
5
  * Use of this source code is governed by an MIT-style license that can be
6
6
  * found in the LICENSE file at https://angular.dev/license
7
7
  */
8
- export { forwardRefResolver, findAngularDecorator, getAngularDecorators, isAngularDecorator, NoopReferencesRegistry, ReferencesRegistry, ResourceLoader, ResourceLoaderContext, JitDeclarationRegistry, } from './common';
8
+ export { createForwardRefResolver, findAngularDecorator, getAngularDecorators, isAngularDecorator, NoopReferencesRegistry, ReferencesRegistry, ResourceLoader, ResourceLoaderContext, JitDeclarationRegistry, } from './common';
9
9
  export { ComponentDecoratorHandler } from './component';
10
10
  export { DirectiveDecoratorHandler, InitializerApiFunction, INPUT_INITIALIZER_FN, MODEL_INITIALIZER_FN, OUTPUT_INITIALIZER_FNS, QUERY_INITIALIZER_FNS, queryDecoratorNames, QueryFunctionName, tryParseInitializerApi, tryParseInitializerBasedOutput, tryParseSignalInputMapping, tryParseSignalModelMapping, tryParseSignalQueryFromInitializer, } from './directive';
11
11
  export { NgModuleDecoratorHandler } from './ng_module';
@@ -38,6 +38,14 @@ export interface InternalOptions {
38
38
  * Whether to check the event side of two-way bindings.
39
39
  */
40
40
  _checkTwoWayBoundEvents?: boolean;
41
+ /**
42
+ * Whether this is a compilation of Angular core itself.
43
+ *
44
+ * By default, we detect this automatically based on the existence of `r3_symbols.ts`
45
+ * in the compilation, but there are other test targets within the `core` package that
46
+ * import e.g. `Component` relatively and should be detected by the compiler.
47
+ */
48
+ _isAngularCoreCompilation?: boolean;
41
49
  }
42
50
  /**
43
51
  * A merged interface of all of the various Angular compiler options, as well as the standard
@@ -10,7 +10,7 @@ import { DocEntry } from '../../docs';
10
10
  import { AbsoluteFsPath } from '../../file_system';
11
11
  import { IncrementalBuildStrategy, IncrementalCompilation, IncrementalState } from '../../incremental';
12
12
  import { IndexedComponent } from '../../indexer';
13
- import { ComponentResources, DirectiveMeta, PipeMeta } from '../../metadata';
13
+ import { DirectiveResources, DirectiveMeta, PipeMeta } from '../../metadata';
14
14
  import { ActivePerfRecorder } from '../../perf';
15
15
  import { ProgramDriver } from '../../program_driver';
16
16
  import { DeclarationNode } from '../../reflection';
@@ -208,9 +208,9 @@ export declare class NgCompiler {
208
208
  */
209
209
  getComponentsWithStyleFile(styleFilePath: string): ReadonlySet<DeclarationNode>;
210
210
  /**
211
- * Retrieves external resources for the given component.
211
+ * Retrieves external resources for the given directive.
212
212
  */
213
- getComponentResources(classDecl: DeclarationNode): ComponentResources | null;
213
+ getDirectiveResources(classDecl: DeclarationNode): DirectiveResources | null;
214
214
  getMeta(classDecl: DeclarationNode): PipeMeta | DirectiveMeta | null;
215
215
  /**
216
216
  * Perform Angular's analysis step (as a precursor to `getDiagnostics` or `prepareEmit`)
@@ -7,7 +7,7 @@
7
7
  */
8
8
  import ts from 'typescript';
9
9
  import { EntryType, FunctionEntry, ParameterEntry } from './entities';
10
- export type FunctionLike = ts.FunctionDeclaration | ts.MethodDeclaration | ts.MethodSignature | ts.CallSignatureDeclaration | ts.ConstructSignatureDeclaration;
10
+ export type FunctionLike = ts.FunctionDeclaration | ts.MethodDeclaration | ts.MethodSignature | ts.CallSignatureDeclaration | ts.ConstructSignatureDeclaration | ts.ConstructorDeclaration;
11
11
  export declare class FunctionExtractor {
12
12
  private name;
13
13
  private exportDeclaration;
@@ -7,11 +7,12 @@
7
7
  */
8
8
  import { R3HmrMetadata, outputAst as o } from '@angular/compiler';
9
9
  import { CompileResult } from '../../transform';
10
+ import { ClassDeclaration } from '../../reflection';
10
11
  import ts from 'typescript';
11
12
  /**
12
13
  * Gets the declaration for the function that replaces the metadata of a class during HMR.
13
14
  * @param compilationResults Code generated for the class during compilation.
14
15
  * @param meta HMR metadata about the class.
15
- * @param sourceFile File in which the class is defined.
16
+ * @param declaration Class for which the update declaration is being generated.
16
17
  */
17
- export declare function getHmrUpdateDeclaration(compilationResults: CompileResult[], constantStatements: o.Statement[], meta: R3HmrMetadata, sourceFile: ts.SourceFile): ts.FunctionDeclaration;
18
+ export declare function getHmrUpdateDeclaration(compilationResults: CompileResult[], constantStatements: o.Statement[], meta: R3HmrMetadata, declaration: ClassDeclaration): ts.FunctionDeclaration;
@@ -9,7 +9,7 @@ export * from './src/api';
9
9
  export { DtsMetadataReader } from './src/dts';
10
10
  export { flattenInheritedDirectiveMetadata } from './src/inheritance';
11
11
  export { CompoundMetadataRegistry, LocalMetadataRegistry } from './src/registry';
12
- export { ResourceRegistry, Resource, ComponentResources, isExternalResource, ExternalResource, } from './src/resource_registry';
12
+ export { ResourceRegistry, Resource, DirectiveResources, isExternalResource, ExternalResource, } from './src/resource_registry';
13
13
  export { extractDirectiveTypeCheckMeta, hasInjectableFields, CompoundMetadataReader, isHostDirectiveMetaForGlobalMode, } from './src/util';
14
14
  export { BindingPropertyName, ClassPropertyMapping, ClassPropertyName, InputOrOutput, } from './src/property_mapping';
15
15
  export { ExportedProviderStatusResolver } from './src/providers';
@@ -24,16 +24,17 @@ export interface ExternalResource extends Resource {
24
24
  }
25
25
  export declare function isExternalResource(resource: Resource): resource is ExternalResource;
26
26
  /**
27
- * Represents the either inline or external resources of a component.
27
+ * Represents the either inline or external resources of a directive.
28
28
  *
29
29
  * A resource with a `path` of `null` is considered inline.
30
+ * The template will be present for components, but will be null for directives.
30
31
  */
31
- export interface ComponentResources {
32
- template: Resource;
33
- styles: ReadonlySet<Resource>;
32
+ export interface DirectiveResources {
33
+ template: Resource | null;
34
+ styles: ReadonlySet<Resource> | null;
34
35
  }
35
36
  /**
36
- * Tracks the mapping between external template/style files and the component(s) which use them.
37
+ * Tracks the mapping between external resources and the directives(s) which use them.
37
38
  *
38
39
  * This information is produced during analysis of the program and is used mainly to support
39
40
  * external tooling, for which such a mapping is challenging to determine without compiler
@@ -45,10 +46,10 @@ export declare class ResourceRegistry {
45
46
  private componentToStylesMap;
46
47
  private externalStyleToComponentsMap;
47
48
  getComponentsWithTemplate(template: AbsoluteFsPath): ReadonlySet<ClassDeclaration>;
48
- registerResources(resources: ComponentResources, component: ClassDeclaration): void;
49
- registerTemplate(templateResource: Resource, component: ClassDeclaration): void;
49
+ registerResources(resources: DirectiveResources, directive: ClassDeclaration): void;
50
+ private registerTemplate;
50
51
  getTemplate(component: ClassDeclaration): Resource | null;
51
- registerStyle(styleResource: Resource, component: ClassDeclaration): void;
52
+ private registerStyle;
52
53
  getStyles(component: ClassDeclaration): Set<Resource>;
53
54
  getComponentsWithStyle(styleUrl: AbsoluteFsPath): ReadonlySet<ClassDeclaration>;
54
55
  }
@@ -28,8 +28,8 @@ export interface TypeCheckableDirectiveMeta extends DirectiveMeta, DirectiveType
28
28
  imports: Reference<ClassDeclaration>[] | null;
29
29
  rawImports: ts.Expression | null;
30
30
  }
31
- export type TemplateId = string & {
32
- __brand: 'TemplateId';
31
+ export type TypeCheckId = string & {
32
+ __brand: 'TypeCheckId';
33
33
  };
34
34
  /**
35
35
  * A `ts.Diagnostic` with additional information about the diagnostic related to template
@@ -39,11 +39,11 @@ export interface TemplateDiagnostic extends ts.Diagnostic {
39
39
  /**
40
40
  * The component with the template that resulted in this diagnostic.
41
41
  */
42
- componentFile: ts.SourceFile;
42
+ sourceFile: ts.SourceFile;
43
43
  /**
44
- * The template id of the component that resulted in this diagnostic.
44
+ * The type check ID of the directive that resulted in this diagnostic.
45
45
  */
46
- templateId: TemplateId;
46
+ typeCheckId: TypeCheckId;
47
47
  }
48
48
  /**
49
49
  * A `TemplateDiagnostic` with a specific error code.
@@ -59,14 +59,14 @@ export interface TypeCheckBlockMetadata {
59
59
  /**
60
60
  * A unique identifier for the class which gave rise to this TCB.
61
61
  *
62
- * This can be used to map errors back to the `ts.ClassDeclaration` for the component.
62
+ * This can be used to map errors back to the `ts.ClassDeclaration` for the directive.
63
63
  */
64
- id: TemplateId;
64
+ id: TypeCheckId;
65
65
  /**
66
66
  * Semantic information about the template of the component.
67
67
  */
68
68
  boundTarget: BoundTarget<TypeCheckableDirectiveMeta>;
69
- pipes: Map<string, PipeMeta>;
69
+ pipes: Map<string, PipeMeta> | null;
70
70
  /**
71
71
  * Schemas that apply to this template.
72
72
  */
@@ -309,26 +309,24 @@ export interface TypeCheckingConfig {
309
309
  */
310
310
  checkTwoWayBoundEvents: boolean;
311
311
  }
312
- export type TemplateSourceMapping = DirectTemplateSourceMapping | IndirectTemplateSourceMapping | ExternalTemplateSourceMapping;
312
+ export type SourceMapping = DirectSourceMapping | IndirectSourceMapping | ExternalTemplateSourceMapping;
313
313
  /**
314
- * A mapping to an inline template in a TS file.
314
+ * A mapping to a node within the same source file..
315
315
  *
316
- * `ParseSourceSpan`s for this template should be accurate for direct reporting in a TS error
317
- * message.
316
+ * `ParseSourceSpan`s for this node should be accurate for direct reporting in a TS error message.
318
317
  */
319
- export interface DirectTemplateSourceMapping {
318
+ export interface DirectSourceMapping {
320
319
  type: 'direct';
321
- node: ts.StringLiteral | ts.NoSubstitutionTemplateLiteral;
320
+ node: ts.Expression;
322
321
  }
323
322
  /**
324
- * A mapping to a template which is still in a TS file, but where the node positions in any
323
+ * A mapping to a node which is still in a TS file, but where the positions in any
325
324
  * `ParseSourceSpan`s are not accurate for one reason or another.
326
325
  *
327
- * This can occur if the template expression was interpolated in a way where the compiler could not
328
- * construct a contiguous mapping for the template string. The `node` refers to the `template`
329
- * expression.
326
+ * This can occur if the expression was interpolated in a way where the compiler could not
327
+ * construct a contiguous mapping for the template string.
330
328
  */
331
- export interface IndirectTemplateSourceMapping {
329
+ export interface IndirectSourceMapping {
332
330
  type: 'indirect';
333
331
  componentClass: ClassDeclaration;
334
332
  node: ts.Expression;
@@ -348,18 +346,18 @@ export interface ExternalTemplateSourceMapping {
348
346
  templateUrl: string;
349
347
  }
350
348
  /**
351
- * A mapping of a TCB template id to a span in the corresponding template source.
349
+ * A mapping of a TCB template id to a span in the corresponding source code.
352
350
  */
353
351
  export interface SourceLocation {
354
- id: TemplateId;
352
+ id: TypeCheckId;
355
353
  span: AbsoluteSourceSpan;
356
354
  }
357
355
  /**
358
- * A representation of all a node's template mapping information we know. Useful for producing
356
+ * A representation of all a node's type checking information we know. Useful for producing
359
357
  * diagnostics based on a TCB node or generally mapping from a TCB node back to a template location.
360
358
  */
361
- export interface FullTemplateMapping {
359
+ export interface FullSourceMapping {
362
360
  sourceLocation: SourceLocation;
363
- templateSourceMapping: TemplateSourceMapping;
361
+ sourceMapping: SourceMapping;
364
362
  span: ParseSourceSpan;
365
363
  }
@@ -12,7 +12,7 @@ import { ErrorCode } from '../../diagnostics';
12
12
  import { Reference } from '../../imports';
13
13
  import { NgModuleMeta, PipeMeta } from '../../metadata';
14
14
  import { ClassDeclaration } from '../../reflection';
15
- import { FullTemplateMapping, NgTemplateDiagnostic, TypeCheckableDirectiveMeta } from './api';
15
+ import { FullSourceMapping, NgTemplateDiagnostic, TypeCheckableDirectiveMeta } from './api';
16
16
  import { GlobalCompletion } from './completion';
17
17
  import { PotentialDirective, PotentialImport, PotentialImportMode, PotentialPipe } from './scope';
18
18
  import { ElementSymbol, Symbol, TcbLocation, TemplateSymbol } from './symbols';
@@ -50,10 +50,10 @@ export interface TemplateTypeChecker {
50
50
  */
51
51
  getDiagnosticsForFile(sf: ts.SourceFile, optimizeFor: OptimizeFor): ts.Diagnostic[];
52
52
  /**
53
- * Given a `shim` and position within the file, returns information for mapping back to a template
53
+ * Given a `shim` and position within the file, returns information for mapping back to a source
54
54
  * location.
55
55
  */
56
- getTemplateMappingAtTcbLocation(tcbLocation: TcbLocation): FullTemplateMapping | null;
56
+ getSourceMappingAtTcbLocation(tcbLocation: TcbLocation): FullSourceMapping | null;
57
57
  /**
58
58
  * Get all `ts.Diagnostic`s currently available that pertain to the given component.
59
59
  *
@@ -10,34 +10,43 @@ import ts from 'typescript';
10
10
  import { Reference } from '../../imports';
11
11
  import { PipeMeta } from '../../metadata';
12
12
  import { ClassDeclaration } from '../../reflection';
13
- import { TemplateSourceMapping, TypeCheckableDirectiveMeta } from './api';
13
+ import { SourceMapping, TypeCheckableDirectiveMeta } from './api';
14
+ /** Contextuable data for type checking the template of a component. */
15
+ export interface TemplateContext {
16
+ /** AST nodes representing the template. */
17
+ nodes: TmplAstNode[];
18
+ /** Describes the origin of the template text. Used for mapping errors back. */
19
+ sourceMapping: SourceMapping;
20
+ /** `ParseSourceFile` associated with the template. */
21
+ file: ParseSourceFile;
22
+ /** Errors produced while parsing the template. */
23
+ parseErrors: ParseError[] | null;
24
+ /** Pipes available within the template. */
25
+ pipes: Map<string, PipeMeta>;
26
+ /** Whether the template preserves whitespaces. */
27
+ preserveWhitespaces: boolean;
28
+ }
14
29
  /**
15
30
  * A currently pending type checking operation, into which templates for type-checking can be
16
31
  * registered.
17
32
  */
18
33
  export interface TypeCheckContext {
19
34
  /**
20
- * Register a template to potentially be type-checked.
35
+ * Register a directive to be potentially be type-checked.
21
36
  *
22
- * Templates registered via `addTemplate` are available for checking, but might be skipped if
23
- * checking of that component is not required. This can happen for a few reasons, including if
24
- * the component was previously checked and the prior results are still valid.
37
+ * Directives registered via `addDIrective` are available for checking, but might be skipped if
38
+ * checking of that class is not required. This can happen for a few reasons, including if it was
39
+ * previously checked and the prior results are still valid.
25
40
  *
26
- * @param ref a `Reference` to the component class which yielded this template.
41
+ * @param ref a `Reference` to the directive class which yielded this template.
27
42
  * @param binder an `R3TargetBinder` which encapsulates the scope of this template, including all
28
43
  * available directives.
29
- * @param template the original template AST of this component.
30
- * @param pipes a `Map` of pipes available within the scope of this template.
31
- * @param schemas any schemas which apply to this template.
32
- * @param sourceMapping a `TemplateSourceMapping` instance which describes the origin of the
33
- * template text described by the AST.
34
- * @param file the `ParseSourceFile` associated with the template.
35
- * @param parseErrors the `ParseError`'s associated with the template.
36
- * @param isStandalone a boolean indicating whether the component is standalone.
37
- * @param preserveWhitespaces a boolean indicating whether the component's template preserves
38
- * whitespaces.
44
+ * @param schemas Schemas that will apply when checking the directive.
45
+ * @param templateContext Contextual information necessary for checking the template.
46
+ * Only relevant for component classes.
47
+ * @param isStandalone a boolean indicating whether the directive is standalone.
39
48
  */
40
- addTemplate(ref: Reference<ClassDeclaration<ts.ClassDeclaration>>, binder: R3TargetBinder<TypeCheckableDirectiveMeta>, template: TmplAstNode[], pipes: Map<string, PipeMeta>, schemas: SchemaMetadata[], sourceMapping: TemplateSourceMapping, file: ParseSourceFile, parseErrors: ParseError[] | null, isStandalone: boolean, preserveWhitespaces: boolean): void;
49
+ addDirective(ref: Reference<ClassDeclaration<ts.ClassDeclaration>>, binder: R3TargetBinder<TypeCheckableDirectiveMeta>, schemas: SchemaMetadata[], templateContext: TemplateContext | null, isStandalone: boolean): void;
41
50
  }
42
51
  /**
43
52
  * Interface to trigger generation of type-checking code for a program given a new
@@ -7,11 +7,11 @@
7
7
  */
8
8
  import { ParseSourceSpan } from '@angular/compiler';
9
9
  import ts from 'typescript';
10
- import { TemplateDiagnostic, TemplateId, TemplateSourceMapping } from '../../api';
10
+ import { TemplateDiagnostic, TypeCheckId, SourceMapping } from '../../api';
11
11
  /**
12
12
  * Constructs a `ts.Diagnostic` for a given `ParseSourceSpan` within a template.
13
13
  */
14
- export declare function makeTemplateDiagnostic(templateId: TemplateId, mapping: TemplateSourceMapping, span: ParseSourceSpan, category: ts.DiagnosticCategory, code: number, messageText: string | ts.DiagnosticMessageChain, relatedMessages?: {
14
+ export declare function makeTemplateDiagnostic(id: TypeCheckId, mapping: SourceMapping, span: ParseSourceSpan, category: ts.DiagnosticCategory, code: number, messageText: string | ts.DiagnosticMessageChain, relatedMessages?: {
15
15
  text: string;
16
16
  start: number;
17
17
  end: number;
@@ -6,5 +6,5 @@
6
6
  * found in the LICENSE file at https://angular.dev/license
7
7
  */
8
8
  import { DeclarationNode } from '../../../reflection';
9
- import { TemplateId } from '../../api';
10
- export declare function getTemplateId(clazz: DeclarationNode): TemplateId;
9
+ import { TypeCheckId } from '../../api';
10
+ export declare function getTypeCheckId(clazz: DeclarationNode): TypeCheckId;
@@ -16,9 +16,9 @@ import { PerfRecorder } from '../../perf';
16
16
  import { ProgramDriver } from '../../program_driver';
17
17
  import { ClassDeclaration, ReflectionHost } from '../../reflection';
18
18
  import { ComponentScopeReader, TypeCheckScopeRegistry } from '../../scope';
19
- import { ElementSymbol, FullTemplateMapping, GlobalCompletion, NgTemplateDiagnostic, OptimizeFor, PotentialDirective, PotentialImport, PotentialImportMode, PotentialPipe, ProgramTypeCheckAdapter, TcbLocation, TemplateSymbol, TemplateTypeChecker, TypeCheckableDirectiveMeta, TypeCheckingConfig } from '../api';
19
+ import { ElementSymbol, FullSourceMapping, GlobalCompletion, NgTemplateDiagnostic, OptimizeFor, PotentialDirective, PotentialImport, PotentialImportMode, PotentialPipe, ProgramTypeCheckAdapter, TcbLocation, TemplateSymbol, TemplateTypeChecker, TypeCheckableDirectiveMeta, TypeCheckingConfig } from '../api';
20
20
  import { ShimTypeCheckingData } from './context';
21
- import { TemplateSourceManager } from './source';
21
+ import { DirectiveSourceManager } from './source';
22
22
  /**
23
23
  * Primary template type-checking engine, which performs type-checking using a
24
24
  * `TypeCheckingProgramStrategy` for type-checking program maintenance, and the
@@ -82,7 +82,7 @@ export declare class TemplateTypeCheckerImpl implements TemplateTypeChecker {
82
82
  isTrackedTypeCheckFile(filePath: AbsoluteFsPath): boolean;
83
83
  private getFileRecordForTcbLocation;
84
84
  private getFileAndShimRecordsForPath;
85
- getTemplateMappingAtTcbLocation(tcbLocation: TcbLocation): FullTemplateMapping | null;
85
+ getSourceMappingAtTcbLocation(tcbLocation: TcbLocation): FullSourceMapping | null;
86
86
  generateAllTypeCheckBlocks(): void;
87
87
  /**
88
88
  * Retrieve type-checking and template parse diagnostics from the given `ts.SourceFile` using the
@@ -150,10 +150,10 @@ export interface FileTypeCheckingData {
150
150
  */
151
151
  hasInlines: boolean;
152
152
  /**
153
- * Source mapping information for mapping diagnostics from inlined type check blocks back to the
154
- * original template.
153
+ * Information for mapping diagnostics from inlined type check blocks
154
+ * back to their original sources.
155
155
  */
156
- sourceManager: TemplateSourceManager;
156
+ sourceManager: DirectiveSourceManager;
157
157
  /**
158
158
  * Data for each shim generated from this input file.
159
159
  *
@@ -9,7 +9,7 @@ import { AST, LiteralPrimitive, PropertyRead, PropertyWrite, SafePropertyRead, T
9
9
  import ts from 'typescript';
10
10
  import { AbsoluteFsPath } from '../../file_system';
11
11
  import { GlobalCompletion, TcbLocation } from '../api';
12
- import { TemplateData } from './context';
12
+ import { TypeCheckData } from './context';
13
13
  /**
14
14
  * Powers autocompletion for a specific component.
15
15
  *
@@ -28,7 +28,7 @@ export declare class CompletionEngine {
28
28
  */
29
29
  private templateContextCache;
30
30
  private expressionCompletionCache;
31
- constructor(tcb: ts.Node, data: TemplateData, tcbPath: AbsoluteFsPath, tcbIsShim: boolean);
31
+ constructor(tcb: ts.Node, data: TypeCheckData, tcbPath: AbsoluteFsPath, tcbIsShim: boolean);
32
32
  /**
33
33
  * Get global completions within the given template context and AST node.
34
34
  *