@angular/compiler-cli 22.0.0-next.3 → 22.0.0-next.5

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 (61) hide show
  1. package/bundles/{chunk-HFKTR5QY.js → chunk-456UYWVI.js} +5 -4
  2. package/bundles/chunk-456UYWVI.js.map +6 -0
  3. package/bundles/{chunk-XSRMZ57L.js → chunk-AQWJY4QK.js} +5075 -534
  4. package/bundles/chunk-AQWJY4QK.js.map +6 -0
  5. package/bundles/{chunk-5EGV6MZF.js → chunk-F56AXDTP.js} +1831 -6350
  6. package/bundles/chunk-F56AXDTP.js.map +6 -0
  7. package/bundles/{chunk-UUQRZWDP.js → chunk-G4HQADYD.js} +2 -2
  8. package/bundles/{chunk-I6T4FEIP.js → chunk-L35AQF75.js} +84 -37
  9. package/bundles/chunk-L35AQF75.js.map +6 -0
  10. package/bundles/{chunk-NPMPTFII.js → chunk-RALPCPVT.js} +76 -40
  11. package/bundles/{chunk-NPMPTFII.js.map → chunk-RALPCPVT.js.map} +1 -1
  12. package/bundles/{chunk-EAE5KCUR.js → chunk-TQQE4HRK.js} +8 -8
  13. package/bundles/index.js +11 -9
  14. package/bundles/index.js.map +1 -1
  15. package/bundles/linker/babel/index.js +69 -12
  16. package/bundles/linker/babel/index.js.map +1 -1
  17. package/bundles/linker/index.js +2 -2
  18. package/bundles/private/hybrid_analysis.js +4 -2
  19. package/bundles/private/migrations.js +18 -18
  20. package/bundles/private/testing.js +38 -11
  21. package/bundles/private/testing.js.map +2 -2
  22. package/bundles/private/tooling.js +3 -3
  23. package/bundles/src/bin/ng_xi18n.js +6 -6
  24. package/bundles/src/bin/ngc.js +6 -6
  25. package/linker/babel/src/ast/babel_ast_factory.d.ts +15 -8
  26. package/linker/src/file_linker/emit_scopes/emit_scope.d.ts +3 -3
  27. package/linker/src/file_linker/emit_scopes/local_emit_scope.d.ts +1 -1
  28. package/linker/src/file_linker/file_linker.d.ts +2 -2
  29. package/linker/src/file_linker/linker_environment.d.ts +4 -4
  30. package/linker/src/file_linker/partial_linkers/partial_component_linker_1.d.ts +1 -1
  31. package/linker/src/file_linker/partial_linkers/partial_linker_selector.d.ts +1 -1
  32. package/linker/src/file_linker/partial_linkers/util.d.ts +1 -1
  33. package/linker/src/file_linker/translator.d.ts +2 -2
  34. package/linker/src/linker_import_generator.d.ts +2 -2
  35. package/package.json +3 -3
  36. package/private/hybrid_analysis.d.ts +2 -2
  37. package/src/ngtsc/annotations/directive/src/shared.d.ts +5 -3
  38. package/src/ngtsc/core/api/src/public_options.d.ts +1 -1
  39. package/src/ngtsc/core/src/compiler.d.ts +6 -1
  40. package/src/ngtsc/diagnostics/src/error_code.d.ts +4 -0
  41. package/src/ngtsc/file_system/testing/index.d.ts +1 -1
  42. package/src/ngtsc/file_system/testing/src/test_helper.d.ts +1 -0
  43. package/src/ngtsc/translator/src/api/ast_factory.d.ts +38 -6
  44. package/src/ngtsc/translator/src/translator.d.ts +8 -2
  45. package/src/ngtsc/translator/src/typescript_ast_factory.d.ts +12 -6
  46. package/src/ngtsc/typecheck/api/api.d.ts +2 -1
  47. package/src/ngtsc/typecheck/api/index.d.ts +1 -0
  48. package/src/ngtsc/typecheck/api/oob.d.ts +140 -0
  49. package/src/ngtsc/typecheck/src/context.d.ts +6 -3
  50. package/src/ngtsc/typecheck/src/host_bindings.d.ts +51 -9
  51. package/src/ngtsc/typecheck/src/oob.d.ts +5 -131
  52. package/src/ngtsc/typecheck/src/ops/context.d.ts +3 -4
  53. package/src/ngtsc/typecheck/src/tcb_adapter.d.ts +2 -1
  54. package/src/ngtsc/typecheck/src/type_check_block.d.ts +2 -4
  55. package/src/ngtsc/typecheck/src/type_check_file.d.ts +2 -3
  56. package/bundles/chunk-5EGV6MZF.js.map +0 -6
  57. package/bundles/chunk-HFKTR5QY.js.map +0 -6
  58. package/bundles/chunk-I6T4FEIP.js.map +0 -6
  59. package/bundles/chunk-XSRMZ57L.js.map +0 -6
  60. /package/bundles/{chunk-UUQRZWDP.js.map → chunk-G4HQADYD.js.map} +0 -0
  61. /package/bundles/{chunk-EAE5KCUR.js.map → chunk-TQQE4HRK.js.map} +0 -0
@@ -12,14 +12,14 @@ import { AstFactory } from '../../../src/ngtsc/translator';
12
12
  import { AstHost } from '../ast/ast_host';
13
13
  import { LinkerOptions } from './linker_options';
14
14
  import { Translator } from './translator';
15
- export declare class LinkerEnvironment<TStatement, TExpression> {
15
+ export declare class LinkerEnvironment<TStatement, TExpression, TType> {
16
16
  readonly fileSystem: ReadonlyFileSystem;
17
17
  readonly logger: Logger;
18
18
  readonly host: AstHost<TExpression>;
19
- readonly factory: AstFactory<TStatement, TExpression>;
19
+ readonly factory: AstFactory<TStatement, TExpression, TType>;
20
20
  readonly options: LinkerOptions;
21
- readonly translator: Translator<TStatement, TExpression>;
21
+ readonly translator: Translator<TStatement, TExpression, TType>;
22
22
  readonly sourceFileLoader: SourceFileLoader | null;
23
23
  private constructor();
24
- static create<TStatement, TExpression>(fileSystem: ReadonlyFileSystem, logger: Logger, host: AstHost<TExpression>, factory: AstFactory<TStatement, TExpression>, options: Partial<LinkerOptions>): LinkerEnvironment<TStatement, TExpression>;
24
+ static create<TStatement, TExpression, TType>(fileSystem: ReadonlyFileSystem, logger: Logger, host: AstHost<TExpression>, factory: AstFactory<TStatement, TExpression, TType>, options: Partial<LinkerOptions>): LinkerEnvironment<TStatement, TExpression, TType>;
25
25
  }
@@ -8,8 +8,8 @@
8
8
  import { ConstantPool, R3PartialDeclaration } from '@angular/compiler';
9
9
  import { AstObject } from '../../ast/ast_value';
10
10
  import { GetSourceFileFn } from '../get_source_file';
11
- import { LinkedDefinition, PartialLinker } from './partial_linker';
12
11
  import { AbsoluteFsPath } from '../../../../src/ngtsc/file_system/src/types';
12
+ import { LinkedDefinition, PartialLinker } from './partial_linker';
13
13
  /**
14
14
  * A `PartialLinker` that is designed to process `ɵɵngDeclareComponent()` call expressions.
15
15
  */
@@ -48,7 +48,7 @@ export interface LinkerRange<TExpression> {
48
48
  * `minVersion` of the partial-declaration should be updated, the new linker implementation should
49
49
  * be added to the end of the collection, and the version of the previous linker should be updated.
50
50
  */
51
- export declare function createLinkerMap<TStatement, TExpression>(environment: LinkerEnvironment<TStatement, TExpression>, sourceUrl: AbsoluteFsPath, code: string): Map<string, LinkerRange<TExpression>[]>;
51
+ export declare function createLinkerMap<TStatement, TExpression, TType>(environment: LinkerEnvironment<TStatement, TExpression, TType>, sourceUrl: AbsoluteFsPath, code: string): Map<string, LinkerRange<TExpression>[]>;
52
52
  /**
53
53
  * A helper that selects the appropriate `PartialLinker` for a given declaration.
54
54
  *
@@ -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 = "22.0.0-next.3";
10
+ export declare const PLACEHOLDER_VERSION = "22.0.0-next.5";
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.
@@ -13,9 +13,9 @@ import { AstFactory } from '../../../src/ngtsc/translator/src/api/ast_factory';
13
13
  * Generic translator helper class, which exposes methods for translating expressions and
14
14
  * statements.
15
15
  */
16
- export declare class Translator<TStatement, TExpression> {
16
+ export declare class Translator<TStatement, TExpression, TType> {
17
17
  private factory;
18
- constructor(factory: AstFactory<TStatement, TExpression>);
18
+ constructor(factory: AstFactory<TStatement, TExpression, TType>);
19
19
  /**
20
20
  * Translate the given output AST in the context of an expression.
21
21
  */
@@ -14,10 +14,10 @@ import { AstFactory, ImportGenerator, ImportRequest } from '../../src/ngtsc/tran
14
14
  * must be achieved by property access on an `ng` namespace identifier, which is passed in via the
15
15
  * constructor.
16
16
  */
17
- export declare class LinkerImportGenerator<TStatement, TExpression> implements ImportGenerator<null, TExpression> {
17
+ export declare class LinkerImportGenerator<TStatement, TExpression, TType> implements ImportGenerator<null, TExpression> {
18
18
  private factory;
19
19
  private ngImport;
20
- constructor(factory: AstFactory<TStatement, TExpression>, ngImport: TExpression);
20
+ constructor(factory: AstFactory<TStatement, TExpression, TType>, ngImport: TExpression);
21
21
  addImport(request: ImportRequest<null>): TExpression;
22
22
  private assertModuleName;
23
23
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@angular/compiler-cli",
3
- "version": "22.0.0-next.3",
3
+ "version": "22.0.0-next.5",
4
4
  "description": "Angular - the compiler CLI for Node.js",
5
5
  "typings": "index.d.ts",
6
6
  "bin": {
@@ -40,10 +40,10 @@
40
40
  "yargs": "^18.0.0"
41
41
  },
42
42
  "devDependencies": {
43
- "typescript": "5.9.3"
43
+ "typescript": "6.0.2"
44
44
  },
45
45
  "peerDependencies": {
46
- "@angular/compiler": "22.0.0-next.3",
46
+ "@angular/compiler": "22.0.0-next.5",
47
47
  "typescript": ">=5.9 <6.1"
48
48
  },
49
49
  "peerDependenciesMeta": {
@@ -6,13 +6,13 @@
6
6
  * found in the LICENSE file at https://angular.dev/license
7
7
  */
8
8
  export { generateTypeCheckBlock } from '../src/ngtsc/typecheck/src/type_check_block';
9
- export type { TypeCheckingConfig, TcbComponentMetadata, TcbTypeCheckBlockMetadata, TcbTypeParameter, TypeCheckId, TcbDirectiveMetadata, TemplateDiagnostic, TcbReferenceMetadata, SourceMapping, } from '../src/ngtsc/typecheck/api';
9
+ export type { TypeCheckingConfig, TcbComponentMetadata, TcbTypeCheckBlockMetadata, TcbTypeParameter, TypeCheckId, TcbDirectiveMetadata, TemplateDiagnostic, TcbReferenceMetadata, SourceMapping, OutOfBandDiagnosticRecorder, OutOfBadDiagnosticCategory, } from '../src/ngtsc/typecheck/api';
10
10
  export { DomSchemaChecker, RegistryDomSchemaChecker } from '../src/ngtsc/typecheck/src/dom';
11
11
  export { Environment } from '../src/ngtsc/typecheck/src/environment';
12
- export { OutOfBandDiagnosticRecorder } from '../src/ngtsc/typecheck/src/oob';
13
12
  export { TcbGenericContextBehavior } from '../src/ngtsc/typecheck/src/ops/context';
14
13
  export { ImportManager } from '../src/ngtsc/translator';
15
14
  export type { ReferenceEmitter } from '../src/ngtsc/imports';
16
15
  export type { ReflectionHost, ClassDeclaration } from '../src/ngtsc/reflection';
17
16
  export { ClassPropertyMapping } from '../src/ngtsc/metadata/src/property_mapping';
18
17
  export type { TypeCheckSourceResolver } from '../src/ngtsc/typecheck/src/tcb_util';
18
+ export { createHostElement, type SourceNode, type StaticSourceNode, type HostObjectLiteralBinding, type HostListenerDecorator, type HostBindingDecorator, } from '../src/ngtsc/typecheck/src/host_bindings';
@@ -13,12 +13,14 @@ import { DynamicValue, PartialEvaluator } from '../../../partial_evaluator';
13
13
  import { ClassDeclaration, Decorator, ReflectionHost } from '../../../reflection';
14
14
  import { CompilationMode } from '../../../transform';
15
15
  import { ReferencesRegistry, UndecoratedMetadataExtractor } from '../../common';
16
+ import { HostObjectLiteralBinding, HostListenerDecorator, HostBindingDecorator } from '../../../typecheck/src/host_bindings';
16
17
  type QueryDecoratorName = 'ViewChild' | 'ViewChildren' | 'ContentChild' | 'ContentChildren';
17
18
  export declare const queryDecoratorNames: QueryDecoratorName[];
18
19
  export interface HostBindingNodes {
19
- literal: ts.ObjectLiteralExpression | null;
20
- bindingDecorators: Set<ts.Decorator>;
21
- listenerDecorators: Set<ts.Decorator>;
20
+ hostObjectLiteralBindings: HostObjectLiteralBinding[];
21
+ hostBindingDecorators: HostBindingDecorator[];
22
+ hostListenerDecorators: HostListenerDecorator[];
23
+ rawNodes: ts.Node[];
22
24
  }
23
25
  /**
24
26
  * Helper function to extract metadata from a `Directive` or `Component`. `Directive`s without a
@@ -93,7 +93,7 @@ export interface TypeCheckingOptions {
93
93
  *
94
94
  * This flag is a superset of the deprecated `fullTemplateTypeCheck` option.
95
95
  *
96
- * Defaults to `false`, even if "fullTemplateTypeCheck" is `true`.
96
+ * Defaults to `true`
97
97
  */
98
98
  strictTemplates?: boolean;
99
99
  /**
@@ -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 { DirectiveResources, DirectiveMeta, PipeMeta } from '../../metadata';
13
+ import { DirectiveMeta, DirectiveResources, PipeMeta } from '../../metadata';
14
14
  import { ActivePerfRecorder } from '../../perf';
15
15
  import { ProgramDriver } from '../../program_driver';
16
16
  import { DeclarationNode } from '../../reflection';
@@ -263,6 +263,11 @@ export declare class NgCompiler {
263
263
  private ensureAnalyzed;
264
264
  private analyzeSync;
265
265
  private resolveCompilation;
266
+ /**
267
+ * strictTemplate is `true` by default.
268
+ * Explicit opt-out is required to disable strictness
269
+ */
270
+ private get strictTemplates();
266
271
  private get fullTemplateTypeCheck();
267
272
  private getTypeCheckingConfig;
268
273
  private getTemplateDiagnostics;
@@ -371,6 +371,10 @@ export declare enum ErrorCode {
371
371
  DEFER_TRIGGER_MISCONFIGURATION = 8021,
372
372
  /** Raised when the user has an unsupported binding on a `FormField` directive. */
373
373
  FORM_FIELD_UNSUPPORTED_BINDING = 8022,
374
+ /**
375
+ * Raised when multiple components in the compilation scope match a given element in a template.
376
+ */
377
+ MULTIPLE_MATCHING_COMPONENTS = 8023,
374
378
  /**
375
379
  * A two way binding in a template has an incorrect syntax,
376
380
  * parentheses outside brackets. For example:
@@ -9,4 +9,4 @@ export { Folder, MockFileSystem } from './src/mock_file_system';
9
9
  export { MockFileSystemNative } from './src/mock_file_system_native';
10
10
  export { MockFileSystemPosix } from './src/mock_file_system_posix';
11
11
  export { MockFileSystemWindows } from './src/mock_file_system_windows';
12
- export { initMockFileSystem, runInEachFileSystem, TestFile } from './src/test_helper';
12
+ export { initMockFileSystem, lockMockFileSystem, runInEachFileSystem, TestFile, } from './src/test_helper';
@@ -13,4 +13,5 @@ export interface RunInEachFileSystemFn {
13
13
  osX(callback: (os: string) => void): void;
14
14
  }
15
15
  export declare const runInEachFileSystem: RunInEachFileSystemFn;
16
+ export declare function lockMockFileSystem(): void;
16
17
  export declare function initMockFileSystem(os: string, cwd?: AbsoluteFsPath): MockFileSystem;
@@ -12,7 +12,7 @@
12
12
  * It is up to the caller to do this - e.g. only call `createTaggedTemplate()` or pass `let`|`const`
13
13
  * to `createVariableDeclaration()` if the final JS will allow it.
14
14
  */
15
- export interface AstFactory<TStatement, TExpression> {
15
+ export interface AstFactory<TStatement, TExpression, TType> {
16
16
  /**
17
17
  * Attach the `leadingComments` to the given `statement` node.
18
18
  *
@@ -84,7 +84,7 @@ export interface AstFactory<TStatement, TExpression> {
84
84
  * @param parameters the names of the function's parameters.
85
85
  * @param body a statement (or a block of statements) that are the body of the function.
86
86
  */
87
- createFunctionDeclaration(functionName: string, parameters: string[], body: TStatement): TStatement;
87
+ createFunctionDeclaration(functionName: string, parameters: Parameter<TType>[], body: TStatement): TStatement;
88
88
  /**
89
89
  * Create an expression that represents a function
90
90
  * (e.g. `function foo(param1, param2) { stmt; }`).
@@ -93,7 +93,7 @@ export interface AstFactory<TStatement, TExpression> {
93
93
  * @param parameters the names of the function's parameters.
94
94
  * @param body a statement (or a block of statements) that are the body of the function.
95
95
  */
96
- createFunctionExpression(functionName: string | null, parameters: string[], body: TStatement): TExpression;
96
+ createFunctionExpression(functionName: string | null, parameters: Parameter<TType>[], body: TStatement): TExpression;
97
97
  /**
98
98
  * Create an expression that represents an arrow function
99
99
  * (e.g. `(param1, param2) => body`).
@@ -101,7 +101,7 @@ export interface AstFactory<TStatement, TExpression> {
101
101
  * @param parameters the names of the function's parameters.
102
102
  * @param body an expression or block of statements that are the body of the function.
103
103
  */
104
- createArrowFunctionExpression(parameters: string[], body: TExpression | TStatement): TExpression;
104
+ createArrowFunctionExpression(parameters: Parameter<TType>[], body: TExpression | TStatement): TExpression;
105
105
  /**
106
106
  * Creates an expression that represents a dynamic import
107
107
  * (e.g. `import('./some/path')`)
@@ -216,9 +216,9 @@ export interface AstFactory<TStatement, TExpression> {
216
216
  *
217
217
  * @param variableName the name of the variable.
218
218
  * @param initializer if not `null` then this expression is assigned to the declared variable.
219
- * @param type whether this variable should be declared as `var`, `let` or `const`.
219
+ * @param variableType whether this variable should be declared as `var`, `let` or `const`.
220
220
  */
221
- createVariableDeclaration(variableName: string, initializer: TExpression | null, type: VariableDeclarationType): TStatement;
221
+ createVariableDeclaration(variableName: string, initializer: TExpression | null, variableType: VariableDeclarationType, type: TType | null): TStatement;
222
222
  /**
223
223
  * Create a regular expression literal (e.g. `/\d+/g`).
224
224
  *
@@ -232,6 +232,32 @@ export interface AstFactory<TStatement, TExpression> {
232
232
  * @param target Expression of the spread element.
233
233
  */
234
234
  createSpreadElement(expression: TExpression): TExpression;
235
+ /**
236
+ * Create a type node for a built-in type.
237
+ * @param type Type that should be created.
238
+ */
239
+ createBuiltInType(type: BuiltInType): TType;
240
+ /**
241
+ * Create an expression type.
242
+ * @param expression Expression to be turned into a type node.
243
+ * @param typeParams Type parameters for the expression.
244
+ */
245
+ createExpressionType(expression: TExpression, typeParams: TType[] | null): TType;
246
+ /**
247
+ * Create an array type.
248
+ * @param elementType Type of the array elements.
249
+ */
250
+ createArrayType(elementType: TType): TType;
251
+ /**
252
+ * Create a map type.
253
+ * @param valueType Type of the map values.
254
+ */
255
+ createMapType(valueType: TType): TType;
256
+ /**
257
+ * Forward a transplanted type.
258
+ * @param type Type to be transplanted, if supported.
259
+ */
260
+ transplantType(type: TType): TType;
235
261
  /**
236
262
  * Attach a source map range to the given node.
237
263
  *
@@ -249,6 +275,12 @@ export type VariableDeclarationType = 'const' | 'let' | 'var';
249
275
  * The unary operators supported by the `AstFactory`.
250
276
  */
251
277
  export type UnaryOperator = '+' | '-' | '!';
278
+ /** Supported built-in types. */
279
+ export type BuiltInType = 'any' | 'boolean' | 'number' | 'string' | 'function' | 'never' | 'unknown';
280
+ export interface Parameter<TType> {
281
+ name: string;
282
+ type: TType | null;
283
+ }
252
284
  /**
253
285
  * The binary operators supported by the `AstFactory`.
254
286
  */
@@ -16,14 +16,14 @@ export interface TranslatorOptions<TExpression> {
16
16
  recordWrappedNode?: RecordWrappedNodeFn<TExpression>;
17
17
  annotateForClosureCompiler?: boolean;
18
18
  }
19
- export declare class ExpressionTranslatorVisitor<TFile, TStatement, TExpression> implements o.ExpressionVisitor, o.StatementVisitor {
19
+ export declare class ExpressionTranslatorVisitor<TFile, TStatement, TExpression, TType> implements o.ExpressionVisitor, o.StatementVisitor, o.TypeVisitor {
20
20
  private factory;
21
21
  private imports;
22
22
  private contextFile;
23
23
  private downlevelTaggedTemplates;
24
24
  private downlevelVariableDeclarations;
25
25
  private recordWrappedNode;
26
- constructor(factory: AstFactory<TStatement, TExpression>, imports: ImportGenerator<TFile, TExpression>, contextFile: TFile, options: TranslatorOptions<TExpression>);
26
+ constructor(factory: AstFactory<TStatement, TExpression, TType>, imports: ImportGenerator<TFile, TExpression>, contextFile: TFile, options: TranslatorOptions<TExpression>);
27
27
  visitDeclareVarStmt(stmt: o.DeclareVarStmt, context: Context): TStatement;
28
28
  visitDeclareFunctionStmt(stmt: o.DeclareFunctionStmt, context: Context): TStatement;
29
29
  visitExpressionStmt(stmt: o.ExpressionStatement, context: Context): TStatement;
@@ -37,6 +37,11 @@ export declare class ExpressionTranslatorVisitor<TFile, TStatement, TExpression>
37
37
  visitLiteralExpr(ast: o.LiteralExpr, _context: Context): TExpression;
38
38
  visitRegularExpressionLiteral(ast: o.RegularExpressionLiteralExpr, context: any): TExpression;
39
39
  visitLocalizedString(ast: o.LocalizedString, context: Context): TExpression;
40
+ visitBuiltinType(ast: o.BuiltinType): TType | null;
41
+ visitExpressionType(ast: o.ExpressionType, context: Context): TType;
42
+ visitArrayType(ast: o.ArrayType, context: Context): TType;
43
+ visitMapType(ast: o.MapType, context: Context): TType;
44
+ visitTransplantedType(type: o.TransplantedType<TType>): TType;
40
45
  private createTaggedTemplateExpression;
41
46
  /**
42
47
  * Translate the tagged template literal into a call that is compatible with ES5, using the
@@ -66,4 +71,5 @@ export declare class ExpressionTranslatorVisitor<TFile, TStatement, TExpression>
66
71
  private setSourceMapRange;
67
72
  private attachComments;
68
73
  private getTemplateLiteralFromAst;
74
+ private translateParams;
69
75
  }
@@ -6,11 +6,11 @@
6
6
  * found in the LICENSE file at https://angular.dev/license
7
7
  */
8
8
  import ts from 'typescript';
9
- import { AstFactory, BinaryOperator, LeadingComment, ObjectLiteralProperty, SourceMapRange, TemplateLiteral, UnaryOperator, VariableDeclarationType } from './api/ast_factory';
9
+ import { AstFactory, BinaryOperator, BuiltInType, LeadingComment, ObjectLiteralProperty, Parameter, SourceMapRange, TemplateLiteral, UnaryOperator, VariableDeclarationType } from './api/ast_factory';
10
10
  /**
11
11
  * A TypeScript flavoured implementation of the AstFactory.
12
12
  */
13
- export declare class TypeScriptAstFactory implements AstFactory<ts.Statement, ts.Expression> {
13
+ export declare class TypeScriptAstFactory implements AstFactory<ts.Statement, ts.Expression, ts.TypeNode> {
14
14
  private annotateForClosureCompiler;
15
15
  private externalSourceFiles;
16
16
  private readonly UNARY_OPERATORS;
@@ -27,9 +27,10 @@ export declare class TypeScriptAstFactory implements AstFactory<ts.Statement, ts
27
27
  createElementAccess: (expression: ts.Expression, index: number | ts.Expression) => ts.ElementAccessExpression;
28
28
  createExpressionStatement: (expression: ts.Expression) => ts.ExpressionStatement;
29
29
  createDynamicImport(url: string | ts.Expression): ts.CallExpression;
30
- createFunctionDeclaration(functionName: string, parameters: string[], body: ts.Statement): ts.Statement;
31
- createFunctionExpression(functionName: string | null, parameters: string[], body: ts.Statement): ts.Expression;
32
- createArrowFunctionExpression(parameters: string[], body: ts.Statement | ts.Expression): ts.Expression;
30
+ createFunctionDeclaration(functionName: string, parameters: Parameter<ts.TypeNode>[], body: ts.Statement): ts.Statement;
31
+ createFunctionExpression(functionName: string | null, parameters: Parameter<ts.TypeNode>[], body: ts.Statement): ts.Expression;
32
+ createArrowFunctionExpression(parameters: Parameter<ts.TypeNode>[], body: ts.Statement | ts.Expression): ts.Expression;
33
+ private createParameter;
33
34
  createIdentifier: (text: string) => ts.Identifier;
34
35
  createIfStatement(condition: ts.Expression, thenStatement: ts.Statement, elseStatement: ts.Statement | null): ts.Statement;
35
36
  createLiteral(value: string | number | boolean | null | undefined): ts.Expression;
@@ -45,9 +46,14 @@ export declare class TypeScriptAstFactory implements AstFactory<ts.Statement, ts
45
46
  createTypeOfExpression: (expression: ts.Expression) => ts.TypeOfExpression;
46
47
  createVoidExpression: (expression: ts.Expression) => ts.VoidExpression;
47
48
  createUnaryExpression(operator: UnaryOperator, operand: ts.Expression): ts.Expression;
48
- createVariableDeclaration(variableName: string, initializer: ts.Expression | null, type: VariableDeclarationType): ts.Statement;
49
+ createVariableDeclaration(variableName: string, initializer: ts.Expression | null, variableType: VariableDeclarationType, type: ts.TypeNode | null): ts.Statement;
49
50
  createRegularExpressionLiteral(body: string, flags: string | null): ts.Expression;
50
51
  setSourceMapRange<T extends ts.Node>(node: T, sourceMapRange: SourceMapRange | null): T;
52
+ createBuiltInType(type: BuiltInType): ts.TypeNode;
53
+ createExpressionType(expression: ts.Expression, typeParams: ts.TypeNode[] | null): ts.TypeNode;
54
+ createArrayType(elementType: ts.TypeNode): ts.TypeNode;
55
+ createMapType(valueType: ts.TypeNode): ts.TypeNode;
56
+ transplantType(type: ts.TypeNode): ts.TypeNode;
51
57
  }
52
58
  export declare function createTemplateMiddle(cooked: string, raw: string): ts.TemplateMiddle;
53
59
  export declare function createTemplateTail(cooked: string, raw: string): ts.TemplateTail;
@@ -64,7 +64,7 @@ export interface TcbDirectiveMetadata {
64
64
  typeParameters: TcbTypeParameter[] | null;
65
65
  inputs: ClassPropertyMapping<TcbInputMapping>;
66
66
  outputs: ClassPropertyMapping;
67
- hasRequiresInlineTypeCtor: boolean;
67
+ requiresInlineTypeCtor: boolean;
68
68
  ngTemplateGuards: TemplateGuardMeta[];
69
69
  hasNgTemplateContextGuard: boolean;
70
70
  hasNgFieldDirective: boolean;
@@ -79,6 +79,7 @@ export interface TcbDirectiveMetadata {
79
79
  export interface TcbComponentMetadata {
80
80
  ref: TcbReferenceMetadata;
81
81
  typeParameters: TcbTypeParameter[] | null;
82
+ typeArguments: string[] | null;
82
83
  }
83
84
  export interface TcbTypeCheckBlockMetadata {
84
85
  id: TypeCheckId;
@@ -11,3 +11,4 @@ export * from './completion';
11
11
  export * from './context';
12
12
  export * from './scope';
13
13
  export * from './symbols';
14
+ export * from './oob';
@@ -0,0 +1,140 @@
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 { AST, BindingPipe, PropertyRead, TmplAstBoundAttribute, TmplAstBoundEvent, TmplAstComponent, TmplAstDirective, TmplAstElement, TmplAstForLoopBlock, TmplAstForLoopBlockEmpty, TmplAstHoverDeferredTrigger, TmplAstIfBlockBranch, TmplAstInteractionDeferredTrigger, TmplAstLetDeclaration, TmplAstReference, TmplAstSwitchBlockCase, TmplAstTemplate, TmplAstTextAttribute, TmplAstVariable, TmplAstViewportDeferredTrigger } from '@angular/compiler';
9
+ import { TcbDirectiveMetadata, TypeCheckId } from './api';
10
+ /** Categories of diagnostics that can be reported by a `OutOfBandDiagnosticRecorder`. */
11
+ export declare enum OutOfBadDiagnosticCategory {
12
+ Error = 0,
13
+ Warning = 1
14
+ }
15
+ /**
16
+ * Collects diagnostics on problems which occur in the template which aren't directly sourced
17
+ * from type check blocks.
18
+ *
19
+ * During the creation of a type check block, the template is traversed and the
20
+ * `OutOfBandDiagnosticRecorder` is called to record cases when a correct interpretation for the
21
+ * template cannot be found. These operations create diagnostics which are stored by the
22
+ * recorder for later display.
23
+ */
24
+ export interface OutOfBandDiagnosticRecorder<T> {
25
+ readonly diagnostics: ReadonlyArray<T>;
26
+ /**
27
+ * Reports a `#ref="target"` expression in the template for which a target directive could not be
28
+ * found.
29
+ *
30
+ * @param id the type-checking ID of the template which contains the broken reference.
31
+ * @param ref the `TmplAstReference` which could not be matched to a directive.
32
+ */
33
+ missingReferenceTarget(id: TypeCheckId, ref: TmplAstReference): void;
34
+ /**
35
+ * Reports usage of a `| pipe` expression in the template for which the named pipe could not be
36
+ * found.
37
+ *
38
+ * @param id the type-checking ID of the template which contains the unknown pipe.
39
+ * @param ast the `BindingPipe` invocation of the pipe which could not be found.
40
+ * @param isStandalone whether the host component is standalone.
41
+ */
42
+ missingPipe(id: TypeCheckId, ast: BindingPipe, isStandalone: boolean): void;
43
+ /**
44
+ * Reports usage of a pipe imported via `@Component.deferredImports` outside
45
+ * of a `@defer` block in a template.
46
+ *
47
+ * @param id the type-checking ID of the template which contains the unknown pipe.
48
+ * @param ast the `BindingPipe` invocation of the pipe which could not be found.
49
+ */
50
+ deferredPipeUsedEagerly(id: TypeCheckId, ast: BindingPipe): void;
51
+ /**
52
+ * Reports usage of a component/directive imported via `@Component.deferredImports` outside
53
+ * of a `@defer` block in a template.
54
+ *
55
+ * @param id the type-checking ID of the template which contains the unknown pipe.
56
+ * @param element the element which hosts a component that was defer-loaded.
57
+ */
58
+ deferredComponentUsedEagerly(id: TypeCheckId, element: TmplAstElement): void;
59
+ /**
60
+ * Reports a duplicate declaration of a template variable.
61
+ *
62
+ * @param id the type-checking ID of the template which contains the duplicate
63
+ * declaration.
64
+ * @param variable the `TmplAstVariable` which duplicates a previously declared variable.
65
+ * @param firstDecl the first variable declaration which uses the same name as `variable`.
66
+ */
67
+ duplicateTemplateVar(id: TypeCheckId, variable: TmplAstVariable, firstDecl: TmplAstVariable): void;
68
+ /**
69
+ * Report a warning when structural directives support context guards, but the current
70
+ * type-checking configuration prohibits their usage.
71
+ */
72
+ suboptimalTypeInference(id: TypeCheckId, variables: TmplAstVariable[]): void;
73
+ /**
74
+ * Reports a split two way binding error message.
75
+ */
76
+ splitTwoWayBinding(id: TypeCheckId, input: TmplAstBoundAttribute, output: TmplAstBoundEvent, inputConsumer: Pick<TcbDirectiveMetadata, 'name' | 'isComponent' | 'ref'>, outputConsumer: Pick<TcbDirectiveMetadata, 'name' | 'isComponent' | 'ref'> | TmplAstElement): void;
77
+ /** Reports required inputs that haven't been bound. */
78
+ missingRequiredInputs(id: TypeCheckId, element: TmplAstElement | TmplAstTemplate | TmplAstComponent | TmplAstDirective, directiveName: string, isComponent: boolean, inputAliases: string[]): void;
79
+ /**
80
+ * Reports accesses of properties that aren't available in a `for` block's tracking expression.
81
+ */
82
+ illegalForLoopTrackAccess(id: TypeCheckId, block: TmplAstForLoopBlock, access: PropertyRead): void;
83
+ /**
84
+ * Reports deferred triggers that cannot access the element they're referring to.
85
+ */
86
+ inaccessibleDeferredTriggerElement(id: TypeCheckId, trigger: TmplAstHoverDeferredTrigger | TmplAstInteractionDeferredTrigger | TmplAstViewportDeferredTrigger): void;
87
+ /**
88
+ * Reports cases where control flow nodes prevent content projection.
89
+ */
90
+ controlFlowPreventingContentProjection(id: TypeCheckId, category: OutOfBadDiagnosticCategory, projectionNode: TmplAstElement | TmplAstTemplate, componentName: string, slotSelector: string, controlFlowNode: TmplAstIfBlockBranch | TmplAstSwitchBlockCase | TmplAstForLoopBlock | TmplAstForLoopBlockEmpty, preservesWhitespaces: boolean): void;
91
+ /** Reports cases where users are writing to `@let` declarations. */
92
+ illegalWriteToLetDeclaration(id: TypeCheckId, node: AST, target: TmplAstLetDeclaration): void;
93
+ /** Reports cases where users are accessing an `@let` before it is defined.. */
94
+ letUsedBeforeDefinition(id: TypeCheckId, node: PropertyRead, target: TmplAstLetDeclaration): void;
95
+ /**
96
+ * Reports a `@let` declaration that conflicts with another symbol in the same scope.
97
+ *
98
+ * @param id the type-checking ID of the template which contains the declaration.
99
+ * @param current the `TmplAstLetDeclaration` which is invalid.
100
+ */
101
+ conflictingDeclaration(id: TypeCheckId, current: TmplAstLetDeclaration): void;
102
+ /**
103
+ * Reports that a named template dependency (e.g. `<Missing/>`) is not available.
104
+ * @param id Type checking ID of the template in which the dependency is declared.
105
+ * @param node Node that declares the dependency.
106
+ */
107
+ missingNamedTemplateDependency(id: TypeCheckId, node: TmplAstComponent | TmplAstDirective): void;
108
+ /**
109
+ * Reports that a templace dependency of the wrong kind has been referenced at a specific position
110
+ * (e.g. `<SomeDirective/>`).
111
+ * @param id Type checking ID of the template in which the dependency is declared.
112
+ * @param node Node that declares the dependency.
113
+ */
114
+ incorrectTemplateDependencyType(id: TypeCheckId, node: TmplAstComponent | TmplAstDirective): void;
115
+ /**
116
+ * Reports a binding inside directive syntax that does not match any of the inputs/outputs of
117
+ * the directive.
118
+ * @param id Type checking ID of the template in which the directive was defined.
119
+ * @param directive Directive that contains the binding.
120
+ * @param node Node declaring the binding.
121
+ */
122
+ unclaimedDirectiveBinding(id: TypeCheckId, directive: TmplAstDirective, node: TmplAstBoundAttribute | TmplAstTextAttribute | TmplAstBoundEvent): void;
123
+ /**
124
+ * Reports that an implicit deferred trigger is set on a block that does not have a placeholder.
125
+ */
126
+ deferImplicitTriggerMissingPlaceholder(id: TypeCheckId, trigger: TmplAstHoverDeferredTrigger | TmplAstInteractionDeferredTrigger | TmplAstViewportDeferredTrigger): void;
127
+ /**
128
+ * Reports that an implicit deferred trigger is set on a block whose placeholder is not set up
129
+ * correctly (e.g. more than one root node).
130
+ */
131
+ deferImplicitTriggerInvalidPlaceholder(id: TypeCheckId, trigger: TmplAstHoverDeferredTrigger | TmplAstInteractionDeferredTrigger | TmplAstViewportDeferredTrigger): void;
132
+ /**
133
+ * Reports an unsupported binding on a form `FormField` node.
134
+ */
135
+ formFieldUnsupportedBinding(id: TypeCheckId, node: TmplAstBoundAttribute | TmplAstTextAttribute): void;
136
+ /**
137
+ * Reports that multiple components in the compilation scope match a given element.
138
+ */
139
+ multipleMatchingComponents(id: TypeCheckId, element: TmplAstElement, componentNames: string[]): void;
140
+ }
@@ -12,9 +12,8 @@ import { Reference, ReferenceEmitter } from '../../imports';
12
12
  import { PerfRecorder } from '../../perf';
13
13
  import { FileUpdate } from '../../program_driver';
14
14
  import { ClassDeclaration, ReflectionHost } from '../../reflection';
15
- import { HostBindingsContext, TemplateDiagnostic, TypeCheckId, SourceMapping, TypeCheckableDirectiveMeta, TypeCheckContext, TypeCheckingConfig, TypeCtorMetadata, TemplateContext } from '../api';
15
+ import { HostBindingsContext, TemplateDiagnostic, TypeCheckId, SourceMapping, TypeCheckableDirectiveMeta, TypeCheckContext, TypeCheckingConfig, TypeCtorMetadata, TemplateContext, OutOfBandDiagnosticRecorder } from '../api';
16
16
  import { DomSchemaChecker } from './dom';
17
- import { OutOfBandDiagnosticRecorder } from './oob';
18
17
  import { DirectiveSourceManager } from './source';
19
18
  import { TypeCheckFile } from './type_check_file';
20
19
  export interface ShimTypeCheckingData {
@@ -82,7 +81,7 @@ export interface PendingShimData {
82
81
  /**
83
82
  * Recorder for out-of-band diagnostics which are raised during generation.
84
83
  */
85
- oobRecorder: OutOfBandDiagnosticRecorder;
84
+ oobRecorder: OutOfBandDiagnosticRecorder<TemplateDiagnostic>;
86
85
  /**
87
86
  * The `DomSchemaChecker` in use for this template, which records any schema-related diagnostics.
88
87
  */
@@ -95,6 +94,10 @@ export interface PendingShimData {
95
94
  * Map of `TypeCheckId` to information collected about the template as it's ingested.
96
95
  */
97
96
  data: Map<TypeCheckId, TypeCheckData>;
97
+ /**
98
+ * Diagnostics produced during shim creation.
99
+ */
100
+ shimDiagnostics: TemplateDiagnostic[] | null;
98
101
  }
99
102
  /**
100
103
  * Adapts the `TypeCheckContextImpl` to the larger template type-checking system.
@@ -5,20 +5,62 @@
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 { TmplAstHostElement } from '@angular/compiler';
8
+ import { ParseSourceSpan, TmplAstHostElement } from '@angular/compiler';
9
9
  import ts from 'typescript';
10
- import { ClassDeclaration } from '../../reflection';
10
+ /** Represents information extracted from the source AST. */
11
+ export type SourceNode = StaticSourceNode | {
12
+ kind: 'unspecified';
13
+ sourceSpan: ParseSourceSpan;
14
+ };
15
+ /** A `SourceNode` which represents a static expression. */
16
+ export interface StaticSourceNode {
17
+ kind: 'string' | 'identifier';
18
+ /** Raw source code of the node (e.g. strings include the quotes). */
19
+ source: string;
20
+ /** Actual text of the node (e.g. value inside the quotes in strings). */
21
+ text: string;
22
+ /** Location information about the node. */
23
+ sourceSpan: ParseSourceSpan;
24
+ }
25
+ /** A single binding inside the `host` object of a directive. */
26
+ export interface HostObjectLiteralBinding {
27
+ /** Node representing the key of the binding. */
28
+ key: SourceNode;
29
+ /** Node representing the value of the binding. */
30
+ value: SourceNode;
31
+ /** Location information about the entire binding. */
32
+ sourceSpan: ParseSourceSpan;
33
+ }
34
+ /** A single binding declared by a `@HostListener` decorator on a class member. */
35
+ export interface HostListenerDecorator {
36
+ /** Node declaring the name of the event (e.g. first argument of `@HostListener`). */
37
+ eventName: SourceNode | null;
38
+ /** Node representing the name of the member that was decorated. */
39
+ memberName: StaticSourceNode;
40
+ /** Location information about the member that the decorator is set on. */
41
+ memberSpan: ParseSourceSpan;
42
+ /** Arguments passed to the event. */
43
+ arguments: SourceNode[];
44
+ /** Location information about the decorator. */
45
+ decoratorSpan: ParseSourceSpan;
46
+ }
47
+ /** A single binding declared by the `@HostBinding` decorator on a class member. */
48
+ export interface HostBindingDecorator {
49
+ /** Node representing the name of the member that was decorated. */
50
+ memberName: StaticSourceNode;
51
+ /** Location information about the member that the decorator is set on. */
52
+ memberSpan: ParseSourceSpan;
53
+ /** Arguments passed into the decorator */
54
+ arguments: SourceNode[];
55
+ /** Location information about the decorator. */
56
+ decoratorSpan: ParseSourceSpan;
57
+ }
11
58
  /**
12
59
  * Creates an AST node that represents the host element of a directive.
13
60
  * Can return null if there are no valid bindings to be checked.
14
- * @param type Whether the host element is for a directive or a component.
15
- * @param selector Selector of the directive.
16
- * @param sourceNode Class declaration for the directive.
17
- * @param literal `host` object literal from the decorator.
18
- * @param bindingDecorators `HostBinding` decorators discovered on the node.
19
- * @param listenerDecorators `HostListener` decorators discovered on the node.
61
+ * @param meta Metadata used to construct the host element.
20
62
  */
21
- export declare function createHostElement(type: 'component' | 'directive', selector: string | null, sourceNode: ClassDeclaration, literal: ts.ObjectLiteralExpression | null, bindingDecorators: Iterable<ts.Decorator>, listenerDecorators: Iterable<ts.Decorator>): TmplAstHostElement | null;
63
+ export declare function createHostElement(type: 'component' | 'directive', selector: string | null, nameSpan: ParseSourceSpan, hostObjectLiteralBindings: HostObjectLiteralBinding[], hostBindingDecorators: HostBindingDecorator[], hostListenerDecorators: HostListenerDecorator[]): TmplAstHostElement | null;
22
64
  /**
23
65
  * Creates an AST node that can be used as a guard in `if` statements to distinguish TypeScript
24
66
  * nodes used for checking host bindings from ones used for checking templates.