@angular/compiler-cli 20.0.1 → 20.1.0-next.0

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 (66) hide show
  1. package/bundles/{chunk-M3WWDK6S.js → chunk-CZ5FD3CS.js} +4 -15
  2. package/bundles/{chunk-M3WWDK6S.js.map → chunk-CZ5FD3CS.js.map} +1 -1
  3. package/bundles/{chunk-QAGJD3X3.js → chunk-FPJJEIPU.js} +2 -2
  4. package/bundles/{chunk-C5GIHHVB.js → chunk-FYR5CLCG.js} +5 -5
  5. package/bundles/{chunk-C5GIHHVB.js.map → chunk-FYR5CLCG.js.map} +1 -1
  6. package/bundles/{chunk-4OIPE63R.js → chunk-N3B6BMGR.js} +30 -30
  7. package/bundles/{chunk-4OIPE63R.js.map → chunk-N3B6BMGR.js.map} +1 -1
  8. package/bundles/{chunk-NODL47CE.js → chunk-OVACIG5Q.js} +3 -3
  9. package/bundles/{chunk-NODL47CE.js.map → chunk-OVACIG5Q.js.map} +1 -1
  10. package/bundles/{chunk-KGJOQ7ZK.js → chunk-PG2VUSMN.js} +161 -324
  11. package/bundles/chunk-PG2VUSMN.js.map +6 -0
  12. package/bundles/{chunk-3TXROOKD.js → chunk-UMD7AW7S.js} +1720 -883
  13. package/bundles/chunk-UMD7AW7S.js.map +6 -0
  14. package/bundles/index.js +19 -21
  15. package/bundles/index.js.map +2 -2
  16. package/bundles/linker/babel/index.js +9 -9
  17. package/bundles/linker/babel/index.js.map +1 -1
  18. package/bundles/linker/index.js +2 -2
  19. package/bundles/private/migrations.js +2 -3
  20. package/bundles/private/tooling.js +4 -5
  21. package/bundles/src/bin/ng_xi18n.js +8 -9
  22. package/bundles/src/bin/ng_xi18n.js.map +2 -2
  23. package/bundles/src/bin/ngc.js +6 -7
  24. package/bundles/src/bin/ngc.js.map +2 -2
  25. package/linker/src/file_linker/partial_linkers/util.d.ts +1 -1
  26. package/package.json +2 -6
  27. package/src/ngtsc/annotations/component/src/handler.d.ts +5 -2
  28. package/src/ngtsc/annotations/component/src/metadata.d.ts +7 -0
  29. package/src/ngtsc/annotations/component/src/selectorless.d.ts +16 -0
  30. package/src/ngtsc/annotations/directive/src/handler.d.ts +2 -1
  31. package/src/ngtsc/annotations/directive/src/shared.d.ts +2 -2
  32. package/src/ngtsc/annotations/ng_module/src/handler.d.ts +2 -1
  33. package/src/ngtsc/annotations/src/pipe.d.ts +1 -1
  34. package/src/ngtsc/core/api/src/public_options.d.ts +13 -0
  35. package/src/ngtsc/core/src/compiler.d.ts +1 -0
  36. package/src/ngtsc/diagnostics/src/error_code.d.ts +4 -0
  37. package/src/ngtsc/docs/src/entities.d.ts +1 -1
  38. package/src/ngtsc/indexer/src/api.d.ts +20 -8
  39. package/src/ngtsc/metadata/src/api.d.ts +9 -3
  40. package/src/ngtsc/scope/index.d.ts +2 -1
  41. package/src/ngtsc/scope/src/api.d.ts +12 -2
  42. package/src/ngtsc/scope/src/selectorless_scope.d.ts +25 -0
  43. package/src/ngtsc/scope/src/typecheck.d.ts +5 -3
  44. package/src/ngtsc/transform/index.d.ts +1 -0
  45. package/src/ngtsc/transform/src/api.d.ts +0 -2
  46. package/src/ngtsc/transform/src/compilation.d.ts +2 -1
  47. package/src/ngtsc/transform/src/implicit_signal_debug_name_transform.d.ts +74 -0
  48. package/src/ngtsc/transform/src/transform.d.ts +1 -1
  49. package/src/ngtsc/translator/src/translator.d.ts +0 -3
  50. package/src/ngtsc/typecheck/api/api.d.ts +3 -0
  51. package/src/ngtsc/typecheck/api/checker.d.ts +24 -6
  52. package/src/ngtsc/typecheck/api/scope.d.ts +17 -1
  53. package/src/ngtsc/typecheck/api/symbols.d.ts +39 -3
  54. package/src/ngtsc/typecheck/src/checker.d.ts +12 -4
  55. package/src/ngtsc/typecheck/src/completion.d.ts +7 -2
  56. package/src/ngtsc/typecheck/src/oob.d.ts +3 -3
  57. package/src/ngtsc/typecheck/src/template_symbol_builder.d.ts +6 -2
  58. package/bundles/chunk-3TXROOKD.js.map +0 -6
  59. package/bundles/chunk-KGJOQ7ZK.js.map +0 -6
  60. package/bundles/chunk-WUCT7QTW.js +0 -216
  61. package/bundles/chunk-WUCT7QTW.js.map +0 -6
  62. package/bundles/private/bazel.js +0 -19
  63. package/bundles/private/bazel.js.map +0 -6
  64. package/private/babel.d.ts +0 -28
  65. package/private/bazel.d.ts +0 -12
  66. /package/bundles/{chunk-QAGJD3X3.js.map → chunk-FPJJEIPU.js.map} +0 -0
@@ -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
- import { DirectiveMeta as T2DirectiveMeta, Expression, SchemaMetadata } from '@angular/compiler';
8
+ import { DirectiveMeta as T2DirectiveMeta, Expression, SchemaMetadata, ExternalReference } from '@angular/compiler';
9
9
  import ts from 'typescript';
10
10
  import { Reference } from '../../imports';
11
11
  import { ClassDeclaration } from '../../reflection';
@@ -241,6 +241,12 @@ export interface DirectiveMeta extends T2DirectiveMeta, DirectiveTypeCheckMeta {
241
241
  * scope via `@Component.deferredImports` field.
242
242
  */
243
243
  isExplicitlyDeferred: boolean;
244
+ /** Whether selectorless is enabled for the specific component. */
245
+ selectorlessEnabled: boolean;
246
+ /**
247
+ * Names of the symbols within the source file that are referenced directly inside the template.
248
+ */
249
+ localReferencedSymbols: Set<string> | null;
244
250
  }
245
251
  /** Metadata collected about an additional directive that is being applied to a directive host. */
246
252
  export interface HostDirectiveMeta {
@@ -251,7 +257,7 @@ export interface HostDirectiveMeta {
251
257
  * which indicates the expression could not be resolved due to being imported from some external
252
258
  * file. In this case, the expression is the raw expression as appears in the decorator.
253
259
  */
254
- directive: Reference<ClassDeclaration> | Expression;
260
+ directive: Reference<ClassDeclaration> | Expression | ExternalReference;
255
261
  /** Whether the reference to the host directive is a forward reference. */
256
262
  isForwardReference: boolean;
257
263
  /** Inputs from the host directive that have been exposed. */
@@ -300,7 +306,7 @@ export interface TemplateGuardMeta {
300
306
  export interface PipeMeta {
301
307
  kind: MetaKind.Pipe;
302
308
  ref: Reference<ClassDeclaration>;
303
- name: string;
309
+ name: string | null;
304
310
  nameExpr: ts.Expression | null;
305
311
  isStandalone: boolean;
306
312
  isPure: boolean;
@@ -5,9 +5,10 @@
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 { ComponentScopeKind, ComponentScopeReader, ExportScope, LocalModuleScope, ScopeData, StandaloneScope, } from './src/api';
8
+ export { ComponentScopeKind, ComponentScopeReader, ExportScope, LocalModuleScope, ScopeData, StandaloneScope, ComponentScope, } from './src/api';
9
9
  export { CompoundComponentScopeReader } from './src/component_scope';
10
10
  export { DtsModuleScopeResolver, MetadataDtsModuleScopeResolver } from './src/dependency';
11
11
  export { DeclarationData, LocalModuleScopeRegistry, LocalNgModuleData } from './src/local';
12
+ export { SelectorlessComponentScopeReader } from './src/selectorless_scope';
12
13
  export { TypeCheckScope, TypeCheckScopeRegistry } from './src/typecheck';
13
14
  export { makeNotStandaloneDiagnostic, makeUnknownComponentImportDiagnostic } from './src/util';
@@ -9,6 +9,7 @@ import { SchemaMetadata } from '@angular/compiler';
9
9
  import { Reexport, Reference } from '../../imports';
10
10
  import { DirectiveMeta, NgModuleMeta, PipeMeta } from '../../metadata';
11
11
  import { ClassDeclaration } from '../../reflection';
12
+ import ts from 'typescript';
12
13
  /**
13
14
  * Data for one of a given NgModule's scopes (either compilation scope or export scopes).
14
15
  */
@@ -46,7 +47,8 @@ export interface RemoteScope {
46
47
  }
47
48
  export declare enum ComponentScopeKind {
48
49
  NgModule = 0,
49
- Standalone = 1
50
+ Standalone = 1,
51
+ Selectorless = 2
50
52
  }
51
53
  export interface LocalModuleScope extends ExportScope {
52
54
  kind: ComponentScopeKind.NgModule;
@@ -63,7 +65,15 @@ export interface StandaloneScope {
63
65
  schemas: SchemaMetadata[];
64
66
  isPoisoned: boolean;
65
67
  }
66
- export type ComponentScope = LocalModuleScope | StandaloneScope;
68
+ export interface SelectorlessScope {
69
+ kind: ComponentScopeKind.Selectorless;
70
+ dependencies: Map<string, DirectiveMeta | PipeMeta>;
71
+ dependencyIdentifiers: ts.Identifier[];
72
+ component: ClassDeclaration;
73
+ schemas: SchemaMetadata[];
74
+ isPoisoned: boolean;
75
+ }
76
+ export type ComponentScope = LocalModuleScope | StandaloneScope | SelectorlessScope;
67
77
  /**
68
78
  * Read information about the compilation scope of components.
69
79
  */
@@ -0,0 +1,25 @@
1
+ /**
2
+ * @license
3
+ * Copyright Google LLC All Rights Reserved.
4
+ *
5
+ * Use of this source code is governed by an MIT-style license that can be
6
+ * found in the LICENSE file at https://angular.dev/license
7
+ */
8
+ import { MetadataReader } from '../../metadata';
9
+ import { ClassDeclaration, ReflectionHost } from '../../reflection';
10
+ import { ComponentScopeReader, SelectorlessScope } from './api';
11
+ /**
12
+ * Computes the scope for a selectorless component by looking at imports within the same
13
+ * file and resolving them to metadata.
14
+ */
15
+ export declare class SelectorlessComponentScopeReader implements ComponentScopeReader {
16
+ private metaReader;
17
+ private reflector;
18
+ private cache;
19
+ constructor(metaReader: MetadataReader, reflector: ReflectionHost);
20
+ getScopeForComponent(node: ClassDeclaration): SelectorlessScope | null;
21
+ getRemoteScope(): null;
22
+ /** Determines which identifiers a class has access to. */
23
+ private getAvailableIdentifiers;
24
+ private getMetaFromIdentifier;
25
+ }
@@ -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
- import { SchemaMetadata, SelectorMatcher } from '@angular/compiler';
8
+ import { DirectiveMatcher, SchemaMetadata } from '@angular/compiler';
9
9
  import { Reference } from '../../imports';
10
10
  import { DirectiveMeta, HostDirectivesResolver, MetadataReader, PipeMeta } from '../../metadata';
11
11
  import { ClassDeclaration } from '../../reflection';
@@ -15,10 +15,10 @@ import { ComponentScopeReader } from './api';
15
15
  */
16
16
  export interface TypeCheckScope {
17
17
  /**
18
- * A `SelectorMatcher` instance that contains the flattened directive metadata of all directives
18
+ * A `DirectiveMatcher` instance that contains the flattened directive metadata of all directives
19
19
  * that are in the compilation scope of the declaring NgModule.
20
20
  */
21
- matcher: SelectorMatcher<DirectiveMeta[]>;
21
+ matcher: DirectiveMatcher<DirectiveMeta> | null;
22
22
  /**
23
23
  * All of the directives available in the compilation scope of the declaring NgModule.
24
24
  */
@@ -62,4 +62,6 @@ export declare class TypeCheckScopeRegistry {
62
62
  getTypeCheckScope(node: ClassDeclaration): TypeCheckScope;
63
63
  getTypeCheckDirectiveMetadata(ref: Reference<ClassDeclaration>): DirectiveMeta | null;
64
64
  private applyExplicitlyDeferredFlag;
65
+ private getSelectorMatcher;
66
+ private getSelectorlessMatcher;
65
67
  }
@@ -11,3 +11,4 @@ export { ClassRecord, TraitCompiler } from './src/compilation';
11
11
  export { declarationTransformFactory, DtsTransformRegistry, IvyDeclarationDtsTransform, } from './src/declaration';
12
12
  export { AnalyzedTrait, PendingTrait, ResolvedTrait, SkippedTrait, Trait, TraitState, } from './src/trait';
13
13
  export { ivyTransformFactory } from './src/transform';
14
+ export { signalMetadataTransform } from './src/implicit_signal_debug_name_transform';
@@ -221,7 +221,5 @@ export interface ResolveResult<R> {
221
221
  data?: Readonly<R>;
222
222
  }
223
223
  export interface DtsTransform {
224
- transformClassElement?(element: ts.ClassElement, imports: ImportManager): ts.ClassElement;
225
- transformFunctionDeclaration?(element: ts.FunctionDeclaration, imports: ImportManager): ts.FunctionDeclaration;
226
224
  transformClass?(clazz: ts.ClassDeclaration, elements: ReadonlyArray<ts.ClassElement>, reflector: ReflectionHost, refEmitter: ReferenceEmitter, imports: ImportManager): ts.ClassDeclaration;
227
225
  }
@@ -65,6 +65,7 @@ export declare class TraitCompiler implements ProgramTypeCheckAdapter {
65
65
  private dtsTransforms;
66
66
  private semanticDepGraphUpdater;
67
67
  private sourceFileTypeIdentifier;
68
+ private emitDeclarationOnly;
68
69
  /**
69
70
  * Maps class declarations to their `ClassRecord`, which tracks the Ivy traits being applied to
70
71
  * those classes.
@@ -82,7 +83,7 @@ export declare class TraitCompiler implements ProgramTypeCheckAdapter {
82
83
  private filesWithoutTraits;
83
84
  private reexportMap;
84
85
  private handlersByName;
85
- constructor(handlers: DecoratorHandler<unknown, unknown, SemanticSymbol | null, unknown>[], reflector: ReflectionHost, perf: PerfRecorder, incrementalBuild: IncrementalBuild<ClassRecord, unknown>, compileNonExportedClasses: boolean, compilationMode: CompilationMode, dtsTransforms: DtsTransformRegistry, semanticDepGraphUpdater: SemanticDepGraphUpdater | null, sourceFileTypeIdentifier: SourceFileTypeIdentifier);
86
+ constructor(handlers: DecoratorHandler<unknown, unknown, SemanticSymbol | null, unknown>[], reflector: ReflectionHost, perf: PerfRecorder, incrementalBuild: IncrementalBuild<ClassRecord, unknown>, compileNonExportedClasses: boolean, compilationMode: CompilationMode, dtsTransforms: DtsTransformRegistry, semanticDepGraphUpdater: SemanticDepGraphUpdater | null, sourceFileTypeIdentifier: SourceFileTypeIdentifier, emitDeclarationOnly: boolean);
86
87
  analyzeSync(sf: ts.SourceFile): void;
87
88
  analyzeAsync(sf: ts.SourceFile): Promise<void> | undefined;
88
89
  private analyze;
@@ -0,0 +1,74 @@
1
+ /**
2
+ * @license
3
+ * Copyright Google LLC All Rights Reserved.
4
+ *
5
+ * Use of this source code is governed by an MIT-style license that can be
6
+ * found in the LICENSE file at https://angular.dev/license
7
+ */
8
+ import ts from 'typescript';
9
+ /**
10
+ *
11
+ * This transformer adds a debugName property to the config object of signal functions like
12
+ * signal, computed, effect, etc.
13
+ *
14
+ * The debugName property is added conditionally based on the value of ngDevMode. This is done
15
+ * to avoid adding the debugName property in production builds.
16
+ *
17
+ * Ex:
18
+ * ```ts
19
+ * import {signal} from '@angular/core';
20
+ * const mySignal = signal('Hello World');
21
+ * ```
22
+ *
23
+ * is transformed to:
24
+ * ```ts
25
+ * import {signal} from '@angular/core';
26
+ * const mySignal = signal('Hello World', ...(ngDevMode ? [{ debugName: "mySignal" }] : []));
27
+ * ```
28
+ *
29
+ * The transformer supports the following cases:
30
+ *
31
+ * # Variable declaration
32
+ * ```ts
33
+ * const mySignal = signal('Hello World');
34
+ * ```
35
+ *
36
+ * becomes
37
+ * ```
38
+ * const mySignal = signal('Hello World', ...(ngDevMode ? [{ debugName: "mySignal" }] : []));
39
+ * ```
40
+ *
41
+ * # Property assignment
42
+ * ```ts
43
+ * class MyClass {
44
+ * mySignal: Signal<string>;
45
+ * constructor() {
46
+ * this.mySignal = signal('Hello World');
47
+ * }
48
+ * }
49
+ * ```
50
+ * becomes
51
+ * ```ts
52
+ * class MyClass {
53
+ * mySignal: Signal<string>;
54
+ * constructor() {
55
+ * this.mySignal = signal(...(ngDevMode ? ['Hello World', { debugName: "mySignal" }] : ['Hello World']));
56
+ * }
57
+ * }
58
+ * ```
59
+ *
60
+ * # Property declaration
61
+ * ```ts
62
+ * class MyClass {
63
+ * mySignal = signal('Hello World');
64
+ * }
65
+ * ```
66
+ * becomes
67
+ * ```ts
68
+ * class MyClass {
69
+ * mySignal = signal(...(ngDevMode ? ['Hello World', { debugName: "mySignal" }] : ['Hello World']));
70
+ * }
71
+ * ```
72
+ *
73
+ */
74
+ export declare function signalMetadataTransform(program: ts.Program): ts.TransformerFactory<ts.SourceFile>;
@@ -10,4 +10,4 @@ import { DefaultImportTracker, ImportRewriter, LocalCompilationExtraImportsTrack
10
10
  import { PerfRecorder } from '../../perf';
11
11
  import { ReflectionHost } from '../../reflection';
12
12
  import { TraitCompiler } from './compilation';
13
- export declare function ivyTransformFactory(compilation: TraitCompiler, reflector: ReflectionHost, importRewriter: ImportRewriter, defaultImportTracker: DefaultImportTracker, localCompilationExtraImportsTracker: LocalCompilationExtraImportsTracker | null, perf: PerfRecorder, isCore: boolean, isClosureCompilerEnabled: boolean): ts.TransformerFactory<ts.SourceFile>;
13
+ export declare function ivyTransformFactory(compilation: TraitCompiler, reflector: ReflectionHost, importRewriter: ImportRewriter, defaultImportTracker: DefaultImportTracker, localCompilationExtraImportsTracker: LocalCompilationExtraImportsTracker | null, perf: PerfRecorder, isCore: boolean, isClosureCompilerEnabled: boolean, emitDeclarationOnly: boolean): ts.TransformerFactory<ts.SourceFile>;
@@ -30,9 +30,6 @@ export declare class ExpressionTranslatorVisitor<TFile, TStatement, TExpression>
30
30
  visitReturnStmt(stmt: o.ReturnStatement, context: Context): TStatement;
31
31
  visitIfStmt(stmt: o.IfStmt, context: Context): TStatement;
32
32
  visitReadVarExpr(ast: o.ReadVarExpr, _context: Context): TExpression;
33
- visitWriteVarExpr(expr: o.WriteVarExpr, context: Context): TExpression;
34
- visitWriteKeyExpr(expr: o.WriteKeyExpr, context: Context): TExpression;
35
- visitWritePropExpr(expr: o.WritePropExpr, context: Context): TExpression;
36
33
  visitInvokeFunctionExpr(ast: o.InvokeFunctionExpr, context: Context): TExpression;
37
34
  visitTaggedTemplateLiteralExpr(ast: o.TaggedTemplateLiteralExpr, context: Context): TExpression;
38
35
  visitTemplateLiteralExpr(ast: o.TemplateLiteralExpr, context: Context): TExpression;
@@ -361,3 +361,6 @@ export interface FullSourceMapping {
361
361
  sourceMapping: SourceMapping;
362
362
  span: ParseSourceSpan;
363
363
  }
364
+ export interface GetPotentialAngularMetaOptions {
365
+ includeExternalModule: boolean;
366
+ }
@@ -5,17 +5,17 @@
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
- import { AST, LiteralPrimitive, ParseSourceSpan, PropertyRead, SafePropertyRead, TemplateEntity, TmplAstElement, TmplAstHostElement, TmplAstNode, TmplAstTemplate, TmplAstTextAttribute } from '@angular/compiler';
8
+ import { AST, LiteralPrimitive, ParseSourceSpan, PropertyRead, SafePropertyRead, TemplateEntity, TmplAstComponent, TmplAstDirective, TmplAstElement, TmplAstHostElement, TmplAstNode, TmplAstTemplate, TmplAstTextAttribute } from '@angular/compiler';
9
9
  import ts from 'typescript';
10
10
  import { AbsoluteFsPath } from '../../../../src/ngtsc/file_system';
11
11
  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 { FullSourceMapping, NgTemplateDiagnostic, TypeCheckableDirectiveMeta } from './api';
15
+ import { FullSourceMapping, GetPotentialAngularMetaOptions, NgTemplateDiagnostic, TypeCheckableDirectiveMeta } from './api';
16
16
  import { GlobalCompletion } from './completion';
17
- import { PotentialDirective, PotentialImport, PotentialImportMode, PotentialPipe } from './scope';
18
- import { ElementSymbol, Symbol, TcbLocation, TemplateSymbol } from './symbols';
17
+ import { PotentialDirective, PotentialImport, PotentialImportMode, PotentialPipe, TsCompletionEntryInfo } from './scope';
18
+ import { ElementSymbol, SelectorlessComponentSymbol, SelectorlessDirectiveSymbol, Symbol, TcbLocation, TemplateSymbol } from './symbols';
19
19
  /**
20
20
  * Interface to the Angular Template Type Checker to extract diagnostics and intelligence from the
21
21
  * compiler's understanding of component templates.
@@ -92,6 +92,8 @@ export interface TemplateTypeChecker {
92
92
  */
93
93
  getSymbolOfNode(node: TmplAstElement, component: ts.ClassDeclaration): ElementSymbol | null;
94
94
  getSymbolOfNode(node: TmplAstTemplate, component: ts.ClassDeclaration): TemplateSymbol | null;
95
+ getSymbolOfNode(node: TmplAstComponent, component: ts.ClassDeclaration): SelectorlessComponentSymbol | null;
96
+ getSymbolOfNode(node: TmplAstDirective, component: ts.ClassDeclaration): SelectorlessDirectiveSymbol | null;
95
97
  getSymbolOfNode(node: AST | TmplAstNode, component: ts.ClassDeclaration): Symbol | null;
96
98
  /**
97
99
  * Get "global" `Completion`s in the given context.
@@ -103,6 +105,10 @@ export interface TemplateTypeChecker {
103
105
  * template variables which are in scope for that expression.
104
106
  */
105
107
  getGlobalCompletions(context: TmplAstTemplate | null, component: ts.ClassDeclaration, node: AST | TmplAstNode): GlobalCompletion | null;
108
+ /**
109
+ * Get the `TcbLocation` for the global context, which is the location of the `this` variable.
110
+ */
111
+ getGlobalTsContext(component: ts.ClassDeclaration): TcbLocation | null;
106
112
  /**
107
113
  * For the given expression node, retrieve a `TcbLocation` that can be used to perform
108
114
  * autocompletion at that point in the expression, if such a location exists.
@@ -118,7 +124,7 @@ export interface TemplateTypeChecker {
118
124
  * Get basic metadata on the directives which are in scope or can be imported for the given
119
125
  * component.
120
126
  */
121
- getPotentialTemplateDirectives(component: ts.ClassDeclaration): PotentialDirective[];
127
+ getPotentialTemplateDirectives(component: ts.ClassDeclaration, tsLs: ts.LanguageService, options: GetPotentialAngularMetaOptions): PotentialDirective[];
122
128
  /**
123
129
  * Get basic metadata on the pipes which are in scope or can be imported for the given component.
124
130
  */
@@ -128,7 +134,19 @@ export interface TemplateTypeChecker {
128
134
  * declares them (if the tag is from a directive/component), or `null` if the tag originates from
129
135
  * the DOM schema.
130
136
  */
131
- getPotentialElementTags(component: ts.ClassDeclaration): Map<string, PotentialDirective | null>;
137
+ getPotentialElementTags(component: ts.ClassDeclaration, tsLs: ts.LanguageService, options: GetPotentialAngularMetaOptions): Map<string, PotentialDirective | null>;
138
+ /**
139
+ * Retrieve a `Map` of potential template element tags that includes in the current component's file
140
+ * scope, or in the component's NgModule scope.
141
+ *
142
+ * The different with the `getPotentialElementTags` is that the directives in the map do not need
143
+ * to update the import statement.
144
+ */
145
+ getElementsInFileScope(component: ts.ClassDeclaration): Map<string, PotentialDirective | null>;
146
+ /**
147
+ * Get the scope data for a directive.
148
+ */
149
+ getDirectiveScopeData(component: ts.ClassDeclaration, isInScope: boolean, tsCompletionEntryInfo: TsCompletionEntryInfo | null): PotentialDirective | null;
132
150
  /**
133
151
  * In the context of an Angular trait, generate potential imports for a directive.
134
152
  */
@@ -26,6 +26,20 @@ export declare enum PotentialImportKind {
26
26
  NgModule = 0,
27
27
  Standalone = 1
28
28
  }
29
+ export interface TsCompletionEntryInfo {
30
+ /**
31
+ * Sometimes, the location of the tsCompletionEntry symbol does not match the location of the Angular symbol.
32
+ *
33
+ * For example, the BarComponent is declared in `bar.ts` and exported from there. The `public_api.ts` also
34
+ * reexports the BarComponent from `bar.ts`, so the `tsCompletionEntrySymbolFileName` will be `public_api.ts`.
35
+ */
36
+ tsCompletionEntrySymbolFileName: string;
37
+ /**
38
+ * This data is from the tsLs completion entry, and
39
+ * will be used in the `ls.getCompletionEntryDetails`.
40
+ */
41
+ tsCompletionEntryData?: ts.CompletionEntryData;
42
+ }
29
43
  /**
30
44
  * Metadata on a directive which is available in a template.
31
45
  */
@@ -55,6 +69,7 @@ export interface PotentialDirective {
55
69
  * Whether or not this directive is in scope.
56
70
  */
57
71
  isInScope: boolean;
72
+ tsCompletionEntryInfo: TsCompletionEntryInfo | null;
58
73
  }
59
74
  /**
60
75
  * Metadata for a pipe which is available in a template.
@@ -68,11 +83,12 @@ export interface PotentialPipe {
68
83
  /**
69
84
  * Name of the pipe.
70
85
  */
71
- name: string;
86
+ name: string | null;
72
87
  /**
73
88
  * Whether or not this pipe is in scope.
74
89
  */
75
90
  isInScope: boolean;
91
+ tsCompletionEntryInfo: TsCompletionEntryInfo | null;
76
92
  }
77
93
  /**
78
94
  * Possible modes in which to look up a potential import.
@@ -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
- import { TmplAstElement, TmplAstLetDeclaration, TmplAstReference, TmplAstTemplate, TmplAstVariable } from '@angular/compiler';
8
+ import { TmplAstComponent, TmplAstDirective, TmplAstElement, TmplAstLetDeclaration, TmplAstReference, TmplAstTemplate, TmplAstVariable } from '@angular/compiler';
9
9
  import ts from 'typescript';
10
10
  import { AbsoluteFsPath } from '../../file_system';
11
11
  import { SymbolWithValueDeclaration } from '../../util/src/typescript';
@@ -22,12 +22,14 @@ export declare enum SymbolKind {
22
22
  Expression = 8,
23
23
  DomBinding = 9,
24
24
  Pipe = 10,
25
- LetDeclaration = 11
25
+ LetDeclaration = 11,
26
+ SelectorlessComponent = 12,
27
+ SelectorlessDirective = 13
26
28
  }
27
29
  /**
28
30
  * A representation of an entity in the `TemplateAst`.
29
31
  */
30
- export type Symbol = InputBindingSymbol | OutputBindingSymbol | ElementSymbol | ReferenceSymbol | VariableSymbol | ExpressionSymbol | DirectiveSymbol | TemplateSymbol | DomBindingSymbol | PipeSymbol | LetDeclarationSymbol;
32
+ export type Symbol = InputBindingSymbol | OutputBindingSymbol | ElementSymbol | ReferenceSymbol | VariableSymbol | ExpressionSymbol | DirectiveSymbol | TemplateSymbol | DomBindingSymbol | PipeSymbol | LetDeclarationSymbol | SelectorlessComponentSymbol | SelectorlessDirectiveSymbol;
31
33
  /**
32
34
  * A `Symbol` which declares a new named entity in the template scope.
33
35
  */
@@ -234,6 +236,40 @@ export interface TemplateSymbol {
234
236
  directives: DirectiveSymbol[];
235
237
  templateNode: TmplAstTemplate;
236
238
  }
239
+ /** A representation of a selectorless component reference in a template. */
240
+ export interface SelectorlessComponentSymbol {
241
+ kind: SymbolKind.SelectorlessComponent;
242
+ /** The `ts.Type` for the component class. */
243
+ tsType: ts.Type;
244
+ /** The `ts.Symbol` for the component class. */
245
+ tsSymbol: ts.Symbol | null;
246
+ /**
247
+ * Includes the component class itself and any host directives
248
+ * that may have been applied as a side-effect of it.
249
+ */
250
+ directives: DirectiveSymbol[];
251
+ /** The location in the shim file for the variable that holds the type of the component. */
252
+ tcbLocation: TcbLocation;
253
+ /** Template AST node defining the component. */
254
+ templateNode: TmplAstComponent;
255
+ }
256
+ /** A representation of a selectorless directive reference in a template. */
257
+ export interface SelectorlessDirectiveSymbol {
258
+ kind: SymbolKind.SelectorlessDirective;
259
+ /** The `ts.Type` for the directive class. */
260
+ tsType: ts.Type;
261
+ /** The `ts.Symbol` for the directive class. */
262
+ tsSymbol: ts.Symbol | null;
263
+ /**
264
+ * Includes the directive class itself and any host directives
265
+ * that may have been applied as a side-effect of it.
266
+ */
267
+ directives: DirectiveSymbol[];
268
+ /** The location in the shim file for the variable that holds the type of the directive. */
269
+ tcbLocation: TcbLocation;
270
+ /** Template AST node defining the directive. */
271
+ templateNode: TmplAstDirective;
272
+ }
237
273
  /** Interface shared between host and non-host directives. */
238
274
  interface DirectiveSymbolBase extends PotentialDirective {
239
275
  kind: SymbolKind.Directive;
@@ -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
- import { AST, LiteralPrimitive, ParseSourceSpan, PropertyRead, SafePropertyRead, TemplateEntity, TmplAstElement, TmplAstHostElement, TmplAstNode, TmplAstTemplate, TmplAstTextAttribute } from '@angular/compiler';
8
+ import { AST, LiteralPrimitive, ParseSourceSpan, PropertyRead, SafePropertyRead, TemplateEntity, TmplAstComponent, TmplAstDirective, TmplAstElement, TmplAstHostElement, TmplAstNode, TmplAstTemplate, TmplAstTextAttribute } from '@angular/compiler';
9
9
  import ts from 'typescript';
10
10
  import { ErrorCode } from '../../diagnostics';
11
11
  import { AbsoluteFsPath } from '../../file_system';
@@ -16,7 +16,7 @@ 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, FullSourceMapping, GlobalCompletion, NgTemplateDiagnostic, OptimizeFor, PotentialDirective, PotentialImport, PotentialImportMode, PotentialPipe, ProgramTypeCheckAdapter, TcbLocation, TemplateSymbol, TemplateTypeChecker, TypeCheckableDirectiveMeta, TypeCheckingConfig } from '../api';
19
+ import { ElementSymbol, FullSourceMapping, GetPotentialAngularMetaOptions, GlobalCompletion, NgTemplateDiagnostic, OptimizeFor, PotentialDirective, PotentialImport, PotentialImportMode, PotentialPipe, ProgramTypeCheckAdapter, SelectorlessComponentSymbol, SelectorlessDirectiveSymbol, TcbLocation, TemplateSymbol, TemplateTypeChecker, TsCompletionEntryInfo, TypeCheckableDirectiveMeta, TypeCheckingConfig } from '../api';
20
20
  import { ShimTypeCheckingData } from './context';
21
21
  import { DirectiveSourceManager } from './source';
22
22
  /**
@@ -121,13 +121,20 @@ export declare class TemplateTypeCheckerImpl implements TemplateTypeChecker {
121
121
  getFileData(path: AbsoluteFsPath): FileTypeCheckingData;
122
122
  getSymbolOfNode(node: TmplAstTemplate, component: ts.ClassDeclaration): TemplateSymbol | null;
123
123
  getSymbolOfNode(node: TmplAstElement, component: ts.ClassDeclaration): ElementSymbol | null;
124
+ getSymbolOfNode(node: TmplAstComponent, component: ts.ClassDeclaration): SelectorlessComponentSymbol | null;
125
+ getSymbolOfNode(node: TmplAstDirective, component: ts.ClassDeclaration): SelectorlessDirectiveSymbol | null;
124
126
  private getOrCreateSymbolBuilder;
125
- getPotentialTemplateDirectives(component: ts.ClassDeclaration): PotentialDirective[];
127
+ getGlobalTsContext(component: ts.ClassDeclaration): TcbLocation | null;
128
+ getPotentialTemplateDirectives(component: ts.ClassDeclaration, tsLs: ts.LanguageService, options: GetPotentialAngularMetaOptions): PotentialDirective[];
126
129
  getPotentialPipes(component: ts.ClassDeclaration): PotentialPipe[];
127
130
  getDirectiveMetadata(dir: ts.ClassDeclaration): TypeCheckableDirectiveMeta | null;
128
131
  getNgModuleMetadata(module: ts.ClassDeclaration): NgModuleMeta | null;
129
132
  getPipeMetadata(pipe: ts.ClassDeclaration): PipeMeta | null;
130
- getPotentialElementTags(component: ts.ClassDeclaration): Map<string, PotentialDirective | null>;
133
+ getTemplateDirectiveInScope(component: ts.ClassDeclaration): PotentialDirective[];
134
+ getDirectiveScopeData(component: ts.ClassDeclaration, isInScope: boolean, tsCompletionEntryInfo: TsCompletionEntryInfo | null): PotentialDirective | null;
135
+ getElementsInFileScope(component: ts.ClassDeclaration): Map<string, PotentialDirective | null>;
136
+ getElementsInGlobal(component: ts.ClassDeclaration, tsLs: ts.LanguageService, options: GetPotentialAngularMetaOptions): PotentialDirective[];
137
+ getPotentialElementTags(component: ts.ClassDeclaration, tsLs: ts.LanguageService, options: GetPotentialAngularMetaOptions): Map<string, PotentialDirective | null>;
131
138
  getPotentialDomBindings(tagName: string): {
132
139
  attribute: string;
133
140
  property: string;
@@ -137,6 +144,7 @@ export declare class TemplateTypeCheckerImpl implements TemplateTypeChecker {
137
144
  getOwningNgModule(component: ts.ClassDeclaration): ts.ClassDeclaration | null;
138
145
  private emit;
139
146
  getPotentialImportsFor(toImport: Reference<ClassDeclaration>, inContext: ts.Node, importMode: PotentialImportMode): ReadonlyArray<PotentialImport>;
147
+ private getComponentScope;
140
148
  private getScopeData;
141
149
  private scopeDataOfDirectiveMeta;
142
150
  private scopeDataOfPipeMeta;
@@ -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
- import { AST, LiteralPrimitive, PropertyRead, PropertyWrite, SafePropertyRead, TmplAstNode, TmplAstTemplate, TmplAstTextAttribute } from '@angular/compiler';
8
+ import { AST, LiteralPrimitive, PropertyRead, SafePropertyRead, TmplAstNode, TmplAstTemplate, TmplAstTextAttribute } from '@angular/compiler';
9
9
  import ts from 'typescript';
10
10
  import { AbsoluteFsPath } from '../../file_system';
11
11
  import { GlobalCompletion, TcbLocation } from '../api';
@@ -22,6 +22,10 @@ export declare class CompletionEngine {
22
22
  private tcbPath;
23
23
  private tcbIsShim;
24
24
  private componentContext;
25
+ /**
26
+ * Get the `TcbLocation` for the global context, which is the location of the `this` variable.
27
+ */
28
+ private globalTsContext;
25
29
  /**
26
30
  * Cache of completions for various levels of the template, including the root template (`null`).
27
31
  * Memoizes `getTemplateContextCompletions`.
@@ -29,6 +33,7 @@ export declare class CompletionEngine {
29
33
  private templateContextCache;
30
34
  private expressionCompletionCache;
31
35
  constructor(tcb: ts.Node, data: TypeCheckData, tcbPath: AbsoluteFsPath, tcbIsShim: boolean);
36
+ getGlobalTsContext(): TcbLocation | null;
32
37
  /**
33
38
  * Get global completions within the given template context and AST node.
34
39
  *
@@ -38,7 +43,7 @@ export declare class CompletionEngine {
38
43
  * @param node the given AST node
39
44
  */
40
45
  getGlobalCompletions(context: TmplAstTemplate | null, node: AST | TmplAstNode): GlobalCompletion | null;
41
- getExpressionCompletionLocation(expr: PropertyRead | PropertyWrite | SafePropertyRead): TcbLocation | null;
46
+ getExpressionCompletionLocation(expr: PropertyRead | SafePropertyRead): TcbLocation | null;
42
47
  getLiteralCompletionLocation(expr: LiteralPrimitive | TmplAstTextAttribute): TcbLocation | null;
43
48
  /**
44
49
  * Get global completions within the given template context - either a `TmplAstTemplate` embedded
@@ -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
- import { BindingPipe, PropertyRead, PropertyWrite, TmplAstBoundAttribute, TmplAstBoundEvent, TmplAstComponent, TmplAstDirective, TmplAstElement, TmplAstForLoopBlock, TmplAstForLoopBlockEmpty, TmplAstHoverDeferredTrigger, TmplAstIfBlockBranch, TmplAstInteractionDeferredTrigger, TmplAstLetDeclaration, TmplAstReference, TmplAstSwitchBlockCase, TmplAstTemplate, TmplAstTextAttribute, TmplAstVariable, TmplAstViewportDeferredTrigger } from '@angular/compiler';
8
+ import { BindingPipe, PropertyRead, AST, TmplAstBoundAttribute, TmplAstBoundEvent, TmplAstComponent, TmplAstDirective, TmplAstElement, TmplAstForLoopBlock, TmplAstForLoopBlockEmpty, TmplAstHoverDeferredTrigger, TmplAstIfBlockBranch, TmplAstInteractionDeferredTrigger, TmplAstLetDeclaration, TmplAstReference, TmplAstSwitchBlockCase, TmplAstTemplate, TmplAstTextAttribute, TmplAstVariable, TmplAstViewportDeferredTrigger } from '@angular/compiler';
9
9
  import ts from 'typescript';
10
10
  import { ClassDeclaration } from '../../reflection';
11
11
  import { TemplateDiagnostic, TypeCheckId } from '../api';
@@ -88,7 +88,7 @@ export interface OutOfBandDiagnosticRecorder {
88
88
  */
89
89
  controlFlowPreventingContentProjection(id: TypeCheckId, category: ts.DiagnosticCategory, projectionNode: TmplAstElement | TmplAstTemplate, componentName: string, slotSelector: string, controlFlowNode: TmplAstIfBlockBranch | TmplAstSwitchBlockCase | TmplAstForLoopBlock | TmplAstForLoopBlockEmpty, preservesWhitespaces: boolean): void;
90
90
  /** Reports cases where users are writing to `@let` declarations. */
91
- illegalWriteToLetDeclaration(id: TypeCheckId, node: PropertyWrite, target: TmplAstLetDeclaration): void;
91
+ illegalWriteToLetDeclaration(id: TypeCheckId, node: AST, target: TmplAstLetDeclaration): void;
92
92
  /** Reports cases where users are accessing an `@let` before it is defined.. */
93
93
  letUsedBeforeDefinition(id: TypeCheckId, node: PropertyRead, target: TmplAstLetDeclaration): void;
94
94
  /**
@@ -152,7 +152,7 @@ export declare class OutOfBandDiagnosticRecorderImpl implements OutOfBandDiagnos
152
152
  illegalForLoopTrackAccess(id: TypeCheckId, block: TmplAstForLoopBlock, access: PropertyRead): void;
153
153
  inaccessibleDeferredTriggerElement(id: TypeCheckId, trigger: TmplAstHoverDeferredTrigger | TmplAstInteractionDeferredTrigger | TmplAstViewportDeferredTrigger): void;
154
154
  controlFlowPreventingContentProjection(id: TypeCheckId, category: ts.DiagnosticCategory, projectionNode: TmplAstElement | TmplAstTemplate, componentName: string, slotSelector: string, controlFlowNode: TmplAstIfBlockBranch | TmplAstSwitchBlockCase | TmplAstForLoopBlock | TmplAstForLoopBlockEmpty, preservesWhitespaces: boolean): void;
155
- illegalWriteToLetDeclaration(id: TypeCheckId, node: PropertyWrite, target: TmplAstLetDeclaration): void;
155
+ illegalWriteToLetDeclaration(id: TypeCheckId, node: AST, target: TmplAstLetDeclaration): void;
156
156
  letUsedBeforeDefinition(id: TypeCheckId, node: PropertyRead, target: TmplAstLetDeclaration): void;
157
157
  conflictingDeclaration(id: TypeCheckId, decl: TmplAstLetDeclaration): void;
158
158
  missingNamedTemplateDependency(id: TypeCheckId, node: TmplAstComponent | TmplAstDirective): void;
@@ -5,11 +5,11 @@
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
- import { AST, TmplAstElement, TmplAstLetDeclaration, TmplAstNode, TmplAstReference, TmplAstTemplate, TmplAstVariable } from '@angular/compiler';
8
+ import { AST, TmplAstComponent, TmplAstDirective, TmplAstElement, TmplAstLetDeclaration, TmplAstNode, TmplAstReference, TmplAstTemplate, TmplAstVariable } from '@angular/compiler';
9
9
  import ts from 'typescript';
10
10
  import { AbsoluteFsPath } from '../../file_system';
11
11
  import { ComponentScopeReader } from '../../scope';
12
- import { ElementSymbol, LetDeclarationSymbol, ReferenceSymbol, Symbol, TemplateSymbol, VariableSymbol } from '../api';
12
+ import { ElementSymbol, LetDeclarationSymbol, ReferenceSymbol, SelectorlessComponentSymbol, SelectorlessDirectiveSymbol, Symbol, TemplateSymbol, VariableSymbol } from '../api';
13
13
  import { TypeCheckData } from './context';
14
14
  /**
15
15
  * Generates and caches `Symbol`s for various template structures for a given component.
@@ -28,9 +28,13 @@ export declare class SymbolBuilder {
28
28
  constructor(tcbPath: AbsoluteFsPath, tcbIsShim: boolean, typeCheckBlock: ts.Node, typeCheckData: TypeCheckData, componentScopeReader: ComponentScopeReader, getTypeChecker: () => ts.TypeChecker);
29
29
  getSymbol(node: TmplAstTemplate | TmplAstElement): TemplateSymbol | ElementSymbol | null;
30
30
  getSymbol(node: TmplAstReference | TmplAstVariable | TmplAstLetDeclaration): ReferenceSymbol | VariableSymbol | LetDeclarationSymbol | null;
31
+ getSymbol(node: TmplAstComponent): SelectorlessComponentSymbol | null;
32
+ getSymbol(node: TmplAstDirective): SelectorlessDirectiveSymbol | null;
31
33
  getSymbol(node: AST | TmplAstNode): Symbol | null;
32
34
  private getSymbolOfAstTemplate;
33
35
  private getSymbolOfElement;
36
+ private getSymbolOfSelectorlessComponent;
37
+ private getSymbolOfSelectorlessDirective;
34
38
  private getDirectivesOfNode;
35
39
  private addHostDirectiveSymbols;
36
40
  private getDirectiveMeta;