@angular/compiler-cli 21.0.0-rc.2 → 21.0.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 (39) hide show
  1. package/bundles/{chunk-JCBKDAHA.js → chunk-3UWOVJPM.js} +1 -1
  2. package/bundles/{chunk-Y65S2AOA.js → chunk-67N3I5R2.js} +1643 -1525
  3. package/bundles/{chunk-UI6E44E7.js → chunk-EZPRBQ4S.js} +2 -2
  4. package/bundles/{chunk-Z6XYTYZD.js → chunk-IUWOX36C.js} +1 -1
  5. package/bundles/chunk-ZJZNLTWN.js +1 -1
  6. package/bundles/index.js +4 -4
  7. package/bundles/private/migrations.js +2 -2
  8. package/bundles/private/testing.js +1 -1
  9. package/bundles/private/tooling.js +1 -1
  10. package/bundles/src/bin/ng_xi18n.js +4 -4
  11. package/bundles/src/bin/ngc.js +4 -4
  12. package/linker/src/file_linker/partial_linkers/util.d.ts +1 -1
  13. package/package.json +2 -2
  14. package/src/ngtsc/typecheck/src/ops/base.d.ts +43 -0
  15. package/src/ngtsc/typecheck/src/ops/bindings.d.ts +64 -0
  16. package/src/ngtsc/typecheck/src/ops/completions.d.ts +22 -0
  17. package/src/ngtsc/typecheck/src/ops/content_projection.d.ts +34 -0
  18. package/src/ngtsc/typecheck/src/ops/context.d.ts +67 -0
  19. package/src/ngtsc/typecheck/src/ops/directive_constructor.d.ts +59 -0
  20. package/src/ngtsc/typecheck/src/ops/directive_type.d.ts +53 -0
  21. package/src/ngtsc/typecheck/src/ops/element.d.ts +26 -0
  22. package/src/ngtsc/typecheck/src/ops/events.d.ts +55 -0
  23. package/src/ngtsc/typecheck/src/ops/expression.d.ts +49 -0
  24. package/src/ngtsc/typecheck/src/ops/for_block.d.ts +32 -0
  25. package/src/ngtsc/typecheck/src/ops/host.d.ts +25 -0
  26. package/src/ngtsc/typecheck/src/ops/if_block.d.ts +28 -0
  27. package/src/ngtsc/typecheck/src/ops/inputs.d.ts +56 -0
  28. package/src/ngtsc/typecheck/src/ops/intersection_observer.d.ts +22 -0
  29. package/src/ngtsc/typecheck/src/ops/let.d.ts +29 -0
  30. package/src/ngtsc/typecheck/src/ops/references.d.ts +57 -0
  31. package/src/ngtsc/typecheck/src/ops/schema.d.ts +31 -0
  32. package/src/ngtsc/typecheck/src/ops/scope.d.ts +187 -0
  33. package/src/ngtsc/typecheck/src/ops/selectorless.d.ts +26 -0
  34. package/src/ngtsc/typecheck/src/ops/signal_forms.d.ts +40 -0
  35. package/src/ngtsc/typecheck/src/ops/switch_block.d.ts +25 -0
  36. package/src/ngtsc/typecheck/src/ops/template.d.ts +40 -0
  37. package/src/ngtsc/typecheck/src/ops/variables.d.ts +56 -0
  38. package/src/ngtsc/typecheck/src/type_check_block.d.ts +2 -274
  39. package/src/ngtsc/typecheck/src/type_check_file.d.ts +1 -1
@@ -8,7 +8,7 @@ import {
8
8
  TrackedIncrementalBuildStrategy,
9
9
  freshCompilationTicket,
10
10
  incrementalFromCompilerTicket
11
- } from "./chunk-JCBKDAHA.js";
11
+ } from "./chunk-3UWOVJPM.js";
12
12
  import {
13
13
  ActivePerfRecorder,
14
14
  OptimizeFor,
@@ -18,7 +18,7 @@ import {
18
18
  TsCreateProgramDriver,
19
19
  replaceTsWithNgInErrors,
20
20
  retagAllTsFiles
21
- } from "./chunk-Y65S2AOA.js";
21
+ } from "./chunk-67N3I5R2.js";
22
22
  import {
23
23
  absoluteFrom,
24
24
  createFileSystemTsReadDirectoryFn,
@@ -12,7 +12,7 @@ import {
12
12
  formatDiagnostics,
13
13
  performCompilation,
14
14
  readConfiguration
15
- } from "./chunk-UI6E44E7.js";
15
+ } from "./chunk-EZPRBQ4S.js";
16
16
 
17
17
  // packages/compiler-cli/src/main.js
18
18
  import ts2 from "typescript";
@@ -455,7 +455,7 @@ import { compileDirectiveFromMetadata, makeBindingParser, ParseLocation, ParseSo
455
455
  // packages/compiler-cli/linker/src/file_linker/partial_linkers/util.js
456
456
  import { createMayBeForwardRefExpression, outputAst as o2 } from "@angular/compiler";
457
457
  import semver from "semver";
458
- var PLACEHOLDER_VERSION = "21.0.0-rc.2";
458
+ var PLACEHOLDER_VERSION = "21.0.0";
459
459
  function wrapReference(wrapped) {
460
460
  return { value: wrapped, type: wrapped };
461
461
  }
package/bundles/index.js CHANGED
@@ -17,7 +17,7 @@ import {
17
17
  isTsDiagnostic,
18
18
  performCompilation,
19
19
  readConfiguration
20
- } from "./chunk-UI6E44E7.js";
20
+ } from "./chunk-EZPRBQ4S.js";
21
21
  import {
22
22
  ConsoleLogger,
23
23
  LogLevel
@@ -34,7 +34,7 @@ import {
34
34
  freshCompilationTicket,
35
35
  incrementalFromStateTicket,
36
36
  isDocEntryWithSourceInfo
37
- } from "./chunk-JCBKDAHA.js";
37
+ } from "./chunk-3UWOVJPM.js";
38
38
  import {
39
39
  ActivePerfRecorder,
40
40
  ErrorCode,
@@ -46,7 +46,7 @@ import {
46
46
  getInitializerApiJitTransform,
47
47
  isLocalCompilationDiagnostics,
48
48
  ngErrorCode
49
- } from "./chunk-Y65S2AOA.js";
49
+ } from "./chunk-67N3I5R2.js";
50
50
  import "./chunk-LS5RJ5CS.js";
51
51
  import {
52
52
  InvalidFileSystem,
@@ -77,7 +77,7 @@ import "./chunk-G7GFT6BU.js";
77
77
 
78
78
  // packages/compiler-cli/src/version.js
79
79
  import { Version } from "@angular/compiler";
80
- var VERSION = new Version("21.0.0-rc.2");
80
+ var VERSION = new Version("21.0.0");
81
81
 
82
82
  // packages/compiler-cli/private/tooling.js
83
83
  var GLOBAL_DEFS_FOR_TERSER = {
@@ -5,7 +5,7 @@
5
5
  import {
6
6
  DiagnosticCategoryLabel,
7
7
  NgCompiler
8
- } from "../chunk-JCBKDAHA.js";
8
+ } from "../chunk-3UWOVJPM.js";
9
9
  import {
10
10
  CompilationMode,
11
11
  DtsMetadataReader,
@@ -32,7 +32,7 @@ import {
32
32
  queryDecoratorNames,
33
33
  reflectObjectLiteral,
34
34
  unwrapExpression
35
- } from "../chunk-Y65S2AOA.js";
35
+ } from "../chunk-67N3I5R2.js";
36
36
  import "../chunk-LS5RJ5CS.js";
37
37
  import {
38
38
  getFileSystem,
@@ -6,7 +6,7 @@ import {
6
6
  ImportedSymbolsTracker,
7
7
  TypeScriptReflectionHost,
8
8
  getInitializerApiJitTransform
9
- } from "../chunk-Y65S2AOA.js";
9
+ } from "../chunk-67N3I5R2.js";
10
10
  import "../chunk-LS5RJ5CS.js";
11
11
  import {
12
12
  InvalidFileSystem,
@@ -4,7 +4,7 @@
4
4
 
5
5
  import {
6
6
  angularJitApplicationTransform
7
- } from "../chunk-Y65S2AOA.js";
7
+ } from "../chunk-67N3I5R2.js";
8
8
  import "../chunk-LS5RJ5CS.js";
9
9
  import "../chunk-GWZQLAGK.js";
10
10
  import "../chunk-XYYEESKY.js";
@@ -6,12 +6,12 @@
6
6
  import {
7
7
  main,
8
8
  readCommandLineAndConfiguration
9
- } from "../../chunk-Z6XYTYZD.js";
9
+ } from "../../chunk-IUWOX36C.js";
10
10
  import {
11
11
  EmitFlags
12
- } from "../../chunk-UI6E44E7.js";
13
- import "../../chunk-JCBKDAHA.js";
14
- import "../../chunk-Y65S2AOA.js";
12
+ } from "../../chunk-EZPRBQ4S.js";
13
+ import "../../chunk-3UWOVJPM.js";
14
+ import "../../chunk-67N3I5R2.js";
15
15
  import "../../chunk-LS5RJ5CS.js";
16
16
  import {
17
17
  setFileSystem
@@ -5,10 +5,10 @@
5
5
 
6
6
  import {
7
7
  main
8
- } from "../../chunk-Z6XYTYZD.js";
9
- import "../../chunk-UI6E44E7.js";
10
- import "../../chunk-JCBKDAHA.js";
11
- import "../../chunk-Y65S2AOA.js";
8
+ } from "../../chunk-IUWOX36C.js";
9
+ import "../../chunk-EZPRBQ4S.js";
10
+ import "../../chunk-3UWOVJPM.js";
11
+ import "../../chunk-67N3I5R2.js";
12
12
  import "../../chunk-LS5RJ5CS.js";
13
13
  import {
14
14
  setFileSystem
@@ -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 = "21.0.0-rc.2";
10
+ export declare const PLACEHOLDER_VERSION = "21.0.0";
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": "21.0.0-rc.2",
3
+ "version": "21.0.0",
4
4
  "description": "Angular - the compiler CLI for Node.js",
5
5
  "typings": "index.d.ts",
6
6
  "bin": {
@@ -40,7 +40,7 @@
40
40
  "yargs": "^18.0.0"
41
41
  },
42
42
  "peerDependencies": {
43
- "@angular/compiler": "21.0.0-rc.2",
43
+ "@angular/compiler": "21.0.0",
44
44
  "typescript": ">=5.9 <6.0"
45
45
  },
46
46
  "peerDependenciesMeta": {
@@ -0,0 +1,43 @@
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
+ * A code generation operation that's involved in the construction of a Type Check Block.
11
+ *
12
+ * The generation of a TCB is non-linear. Bindings within a template may result in the need to
13
+ * construct certain types earlier than they otherwise would be constructed. That is, if the
14
+ * generation of a TCB for a template is broken down into specific operations (constructing a
15
+ * directive, extracting a variable from a let- operation, etc), then it's possible for operations
16
+ * earlier in the sequence to depend on operations which occur later in the sequence.
17
+ *
18
+ * `TcbOp` abstracts the different types of operations which are required to convert a template into
19
+ * a TCB. This allows for two phases of processing for the template, where 1) a linear sequence of
20
+ * `TcbOp`s is generated, and then 2) these operations are executed, not necessarily in linear
21
+ * order.
22
+ *
23
+ * Each `TcbOp` may insert statements into the body of the TCB, and also optionally return a
24
+ * `ts.Expression` which can be used to reference the operation's result.
25
+ */
26
+ export declare abstract class TcbOp {
27
+ /**
28
+ * Set to true if this operation can be considered optional. Optional operations are only executed
29
+ * when depended upon by other operations, otherwise they are disregarded. This allows for less
30
+ * code to generate, parse and type-check, overall positively contributing to performance.
31
+ */
32
+ abstract readonly optional: boolean;
33
+ abstract execute(): ts.Expression | null;
34
+ /**
35
+ * Replacement value or operation used while this `TcbOp` is executing (i.e. to resolve circular
36
+ * references during its execution).
37
+ *
38
+ * This is usually a `null!` expression (which asks TS to infer an appropriate type), but another
39
+ * `TcbOp` can be returned in cases where additional code generation is necessary to deal with
40
+ * circular references.
41
+ */
42
+ circularFallback(): TcbOp | ts.Expression;
43
+ }
@@ -0,0 +1,64 @@
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, ParseSourceSpan, TmplAstBoundAttribute, TmplAstBoundEvent, TmplAstComponent, TmplAstDirective, TmplAstElement, TmplAstTemplate } from '@angular/compiler';
9
+ import ts from 'typescript';
10
+ import { TypeCheckableDirectiveMeta } from '../../api';
11
+ import { ClassPropertyName } from '../../../metadata';
12
+ import { Reference } from '../../../imports';
13
+ import { Context } from './context';
14
+ export interface TcbBoundAttribute {
15
+ value: AST | string;
16
+ sourceSpan: ParseSourceSpan;
17
+ keySpan: ParseSourceSpan | null;
18
+ inputs: {
19
+ fieldName: ClassPropertyName;
20
+ required: boolean;
21
+ isSignal: boolean;
22
+ transformType: Reference<ts.TypeNode> | null;
23
+ isTwoWayBinding: boolean;
24
+ }[];
25
+ }
26
+ /**
27
+ * An input binding that corresponds with a field of a directive.
28
+ */
29
+ export interface TcbDirectiveBoundInput {
30
+ type: 'binding';
31
+ /**
32
+ * The name of a field on the directive that is set.
33
+ */
34
+ field: string;
35
+ /**
36
+ * The `ts.Expression` corresponding with the input binding expression.
37
+ */
38
+ expression: ts.Expression;
39
+ /**
40
+ * The source span of the full attribute binding.
41
+ */
42
+ sourceSpan: ParseSourceSpan;
43
+ /**
44
+ * Whether the binding is part of a two-way binding.
45
+ */
46
+ isTwoWayBinding: boolean;
47
+ }
48
+ /**
49
+ * Indicates that a certain field of a directive does not have a corresponding input binding.
50
+ */
51
+ export interface TcbDirectiveUnsetInput {
52
+ type: 'unset';
53
+ /**
54
+ * The name of a field on the directive for which no input binding is present.
55
+ */
56
+ field: string;
57
+ }
58
+ export type TcbDirectiveInput = TcbDirectiveBoundInput | TcbDirectiveUnsetInput;
59
+ export declare function getBoundAttributes(directive: TypeCheckableDirectiveMeta, node: TmplAstTemplate | TmplAstElement | TmplAstComponent | TmplAstDirective): TcbBoundAttribute[];
60
+ export declare function checkSplitTwoWayBinding(inputName: string, output: TmplAstBoundEvent, inputs: TmplAstBoundAttribute[], tcb: Context): boolean;
61
+ /**
62
+ * Potentially widens the type of `expr` according to the type-checking configuration.
63
+ */
64
+ export declare function widenBinding(expr: ts.Expression, tcb: Context): ts.Expression;
@@ -0,0 +1,22 @@
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 { TcbOp } from './base';
9
+ import type { Scope } from './scope';
10
+ /**
11
+ * A `TcbOp` which generates a completion point for the component context.
12
+ *
13
+ * This completion point looks like `this. ;` in the TCB output, and does not produce diagnostics.
14
+ * TypeScript autocompletion APIs can be used at this completion point (after the '.') to produce
15
+ * autocompletion results of properties and methods from the template's component context.
16
+ */
17
+ export declare class TcbComponentContextCompletionOp extends TcbOp {
18
+ private scope;
19
+ constructor(scope: Scope);
20
+ readonly optional = false;
21
+ execute(): null;
22
+ }
@@ -0,0 +1,34 @@
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 { TmplAstComponent, TmplAstElement } from '@angular/compiler';
9
+ import { TcbOp } from './base';
10
+ import { Context } from './context';
11
+ /**
12
+ * A `TcbOp` that finds and flags control flow nodes that interfere with content projection.
13
+ *
14
+ * Context:
15
+ * Control flow blocks try to emulate the content projection behavior of `*ngIf` and `*ngFor`
16
+ * in order to reduce breakages when moving from one syntax to the other (see #52414), however the
17
+ * approach only works if there's only one element at the root of the control flow expression.
18
+ * This means that a stray sibling node (e.g. text) can prevent an element from being projected
19
+ * into the right slot. The purpose of the `TcbOp` is to find any places where a node at the root
20
+ * of a control flow expression *would have been projected* into a specific slot, if the control
21
+ * flow node didn't exist.
22
+ */
23
+ export declare class TcbControlFlowContentProjectionOp extends TcbOp {
24
+ private tcb;
25
+ private element;
26
+ private ngContentSelectors;
27
+ private componentName;
28
+ private readonly category;
29
+ constructor(tcb: Context, element: TmplAstElement | TmplAstComponent, ngContentSelectors: string[], componentName: string);
30
+ readonly optional = false;
31
+ execute(): null;
32
+ private findPotentialControlFlowNodes;
33
+ private shouldCheck;
34
+ }
@@ -0,0 +1,67 @@
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 { BoundTarget, SchemaMetadata } from '@angular/compiler';
9
+ import ts from 'typescript';
10
+ import { DomSchemaChecker } from '../dom';
11
+ import { OutOfBandDiagnosticRecorder } from '../oob';
12
+ import { TypeCheckableDirectiveMeta, TypeCheckId } from '../../api';
13
+ import { PipeMeta } from '../../../metadata';
14
+ import { Environment } from '../environment';
15
+ /**
16
+ * Controls how generics for the component context class will be handled during TCB generation.
17
+ */
18
+ export declare enum TcbGenericContextBehavior {
19
+ /**
20
+ * References to generic parameter bounds will be emitted via the `TypeParameterEmitter`.
21
+ *
22
+ * The caller must verify that all parameter bounds are emittable in order to use this mode.
23
+ */
24
+ UseEmitter = 0,
25
+ /**
26
+ * Generic parameter declarations will be copied directly from the `ts.ClassDeclaration` of the
27
+ * component class.
28
+ *
29
+ * The caller must only use the generated TCB code in a context where such copies will still be
30
+ * valid, such as an inline type check block.
31
+ */
32
+ CopyClassNodes = 1,
33
+ /**
34
+ * Any generic parameters for the component context class will be set to `any`.
35
+ *
36
+ * Produces a less useful type, but is always safe to use.
37
+ */
38
+ FallbackToAny = 2
39
+ }
40
+ /**
41
+ * Overall generation context for the type check block.
42
+ *
43
+ * `Context` handles operations during code generation which are global with respect to the whole
44
+ * block. It's responsible for variable name allocation and management of any imports needed. It
45
+ * also contains the template metadata itself.
46
+ */
47
+ export declare class Context {
48
+ readonly env: Environment;
49
+ readonly domSchemaChecker: DomSchemaChecker;
50
+ readonly oobRecorder: OutOfBandDiagnosticRecorder;
51
+ readonly id: TypeCheckId;
52
+ readonly boundTarget: BoundTarget<TypeCheckableDirectiveMeta>;
53
+ private pipes;
54
+ readonly schemas: SchemaMetadata[];
55
+ readonly hostIsStandalone: boolean;
56
+ readonly hostPreserveWhitespaces: boolean;
57
+ private nextId;
58
+ constructor(env: Environment, domSchemaChecker: DomSchemaChecker, oobRecorder: OutOfBandDiagnosticRecorder, id: TypeCheckId, boundTarget: BoundTarget<TypeCheckableDirectiveMeta>, pipes: Map<string, PipeMeta> | null, schemas: SchemaMetadata[], hostIsStandalone: boolean, hostPreserveWhitespaces: boolean);
59
+ /**
60
+ * Allocate a new variable name for use within the `Context`.
61
+ *
62
+ * Currently this uses a monotonically increasing counter, but in the future the variable name
63
+ * might change depending on the type of data being stored.
64
+ */
65
+ allocateId(): ts.Identifier;
66
+ getPipeByName(name: string): PipeMeta | null;
67
+ }
@@ -0,0 +1,59 @@
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 { DirectiveOwner } from '@angular/compiler';
9
+ import ts from 'typescript';
10
+ import { TcbOp } from './base';
11
+ import { Context } from './context';
12
+ import type { Scope } from './scope';
13
+ import { TypeCheckableDirectiveMeta } from '../../api';
14
+ import { CustomFieldType } from './signal_forms';
15
+ /**
16
+ * A `TcbOp` which constructs an instance of a directive with types inferred from its inputs. The
17
+ * inputs themselves are not checked here; checking of inputs is achieved in `TcbDirectiveInputsOp`.
18
+ * Any errors reported in this statement are ignored, as the type constructor call is only present
19
+ * for type-inference.
20
+ *
21
+ * When a Directive is generic, it is required that the TCB generates the instance using this method
22
+ * in order to infer the type information correctly.
23
+ *
24
+ * Executing this operation returns a reference to the directive instance variable with its inferred
25
+ * type.
26
+ */
27
+ export declare class TcbDirectiveCtorOp extends TcbOp {
28
+ private tcb;
29
+ private scope;
30
+ private node;
31
+ private dir;
32
+ private customControlType;
33
+ constructor(tcb: Context, scope: Scope, node: DirectiveOwner, dir: TypeCheckableDirectiveMeta, customControlType: CustomFieldType | null);
34
+ get optional(): boolean;
35
+ execute(): ts.Identifier;
36
+ circularFallback(): TcbOp;
37
+ }
38
+ /**
39
+ * A `TcbOp` which is used to generate a fallback expression if the inference of a directive type
40
+ * via `TcbDirectiveCtorOp` requires a reference to its own type. This can happen using a template
41
+ * reference:
42
+ *
43
+ * ```html
44
+ * <some-cmp #ref [prop]="ref.foo"></some-cmp>
45
+ * ```
46
+ *
47
+ * In this case, `TcbDirectiveCtorCircularFallbackOp` will add a second inference of the directive
48
+ * type to the type-check block, this time calling the directive's type constructor without any
49
+ * input expressions. This infers the widest possible supertype for the directive, which is used to
50
+ * resolve any recursive references required to infer the real type.
51
+ */
52
+ export declare class TcbDirectiveCtorCircularFallbackOp extends TcbOp {
53
+ private tcb;
54
+ private scope;
55
+ private dir;
56
+ constructor(tcb: Context, scope: Scope, dir: TypeCheckableDirectiveMeta);
57
+ get optional(): boolean;
58
+ execute(): ts.Identifier;
59
+ }
@@ -0,0 +1,53 @@
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 { DirectiveOwner } from '@angular/compiler';
9
+ import ts from 'typescript';
10
+ import type { Context } from './context';
11
+ import type { Scope } from './scope';
12
+ import { TcbOp } from './base';
13
+ import { TypeCheckableDirectiveMeta } from '../../api';
14
+ /**
15
+ * A `TcbOp` which constructs an instance of a directive. For generic directives, generic
16
+ * parameters are set to `any` type.
17
+ */
18
+ export declare abstract class TcbDirectiveTypeOpBase extends TcbOp {
19
+ protected tcb: Context;
20
+ protected scope: Scope;
21
+ protected node: DirectiveOwner;
22
+ protected dir: TypeCheckableDirectiveMeta;
23
+ constructor(tcb: Context, scope: Scope, node: DirectiveOwner, dir: TypeCheckableDirectiveMeta);
24
+ get optional(): boolean;
25
+ execute(): ts.Identifier;
26
+ }
27
+ /**
28
+ * A `TcbOp` which constructs an instance of a non-generic directive _without_ setting any of its
29
+ * inputs. Inputs are later set in the `TcbDirectiveInputsOp`. Type checking was found to be
30
+ * faster when done in this way as opposed to `TcbDirectiveCtorOp` which is only necessary when the
31
+ * directive is generic.
32
+ *
33
+ * Executing this operation returns a reference to the directive instance variable with its inferred
34
+ * type.
35
+ */
36
+ export declare class TcbNonGenericDirectiveTypeOp extends TcbDirectiveTypeOpBase {
37
+ /**
38
+ * Creates a variable declaration for this op's directive of the argument type. Returns the id of
39
+ * the newly created variable.
40
+ */
41
+ execute(): ts.Identifier;
42
+ }
43
+ /**
44
+ * A `TcbOp` which constructs an instance of a generic directive with its generic parameters set
45
+ * to `any` type. This op is like `TcbDirectiveTypeOp`, except that generic parameters are set to
46
+ * `any` type. This is used for situations where we want to avoid inlining.
47
+ *
48
+ * Executing this operation returns a reference to the directive instance variable with its generic
49
+ * type parameters set to `any`.
50
+ */
51
+ export declare class TcbGenericDirectiveTypeWithAnyParamsOp extends TcbDirectiveTypeOpBase {
52
+ execute(): ts.Identifier;
53
+ }
@@ -0,0 +1,26 @@
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 { TmplAstElement } from '@angular/compiler';
9
+ import ts from 'typescript';
10
+ import { TcbOp } from './base';
11
+ import type { Context } from './context';
12
+ import type { Scope } from './scope';
13
+ /**
14
+ * A `TcbOp` which creates an expression for a native DOM element (or web component) from a
15
+ * `TmplAstElement`.
16
+ *
17
+ * Executing this operation returns a reference to the element variable.
18
+ */
19
+ export declare class TcbElementOp extends TcbOp {
20
+ private tcb;
21
+ private scope;
22
+ private element;
23
+ constructor(tcb: Context, scope: Scope, element: TmplAstElement);
24
+ get optional(): boolean;
25
+ execute(): ts.Identifier;
26
+ }
@@ -0,0 +1,55 @@
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, DirectiveOwner, TmplAstBoundAttribute, TmplAstBoundEvent } from '@angular/compiler';
9
+ import ts from 'typescript';
10
+ import { TcbOp } from './base';
11
+ import type { Context } from './context';
12
+ import type { Scope } from './scope';
13
+ import { TypeCheckableDirectiveMeta } from '../../api';
14
+ import { LocalSymbol } from './references';
15
+ /**
16
+ * Similar to `tcbExpression`, this function converts the provided `AST` expression into a
17
+ * `ts.Expression`, with special handling of the `$event` variable that can be used within event
18
+ * bindings.
19
+ */
20
+ export declare function tcbEventHandlerExpression(ast: AST, tcb: Context, scope: Scope): ts.Expression;
21
+ /**
22
+ * A `TcbOp` which generates code to check event bindings on an element that correspond with the
23
+ * outputs of a directive.
24
+ *
25
+ * Executing this operation returns nothing.
26
+ */
27
+ export declare class TcbDirectiveOutputsOp extends TcbOp {
28
+ private tcb;
29
+ private scope;
30
+ private node;
31
+ private inputs;
32
+ private outputs;
33
+ private dir;
34
+ constructor(tcb: Context, scope: Scope, node: DirectiveOwner, inputs: TmplAstBoundAttribute[] | null, outputs: TmplAstBoundEvent[], dir: TypeCheckableDirectiveMeta);
35
+ get optional(): boolean;
36
+ execute(): null;
37
+ }
38
+ /**
39
+ * A `TcbOp` which generates code to check "unclaimed outputs" - event bindings on an element which
40
+ * were not attributed to any directive or component, and are instead processed against the HTML
41
+ * element itself.
42
+ *
43
+ * Executing this operation returns nothing.
44
+ */
45
+ export declare class TcbUnclaimedOutputsOp extends TcbOp {
46
+ private tcb;
47
+ private scope;
48
+ private target;
49
+ private outputs;
50
+ private inputs;
51
+ private claimedOutputs;
52
+ constructor(tcb: Context, scope: Scope, target: LocalSymbol, outputs: TmplAstBoundEvent[], inputs: TmplAstBoundAttribute[] | null, claimedOutputs: Set<string> | null);
53
+ get optional(): boolean;
54
+ execute(): null;
55
+ }
@@ -0,0 +1,49 @@
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, PropertyRead, TmplAstLetDeclaration } from '@angular/compiler';
9
+ import ts from 'typescript';
10
+ import { TcbOp } from './base';
11
+ import type { Context } from './context';
12
+ import type { Scope } from './scope';
13
+ /**
14
+ * Process an `AST` expression and convert it into a `ts.Expression`, generating references to the
15
+ * correct identifiers in the current scope.
16
+ */
17
+ export declare function tcbExpression(ast: AST, tcb: Context, scope: Scope): ts.Expression;
18
+ /**
19
+ * Wraps an expression in an `unwrapSignal` call which extracts the signal's value.
20
+ */
21
+ export declare function unwrapWritableSignal(expression: ts.Expression, tcb: Context): ts.CallExpression;
22
+ /**
23
+ * A `TcbOp` which renders an Angular expression (e.g. `{{foo() && bar.baz}}`).
24
+ *
25
+ * Executing this operation returns nothing.
26
+ */
27
+ export declare class TcbExpressionOp extends TcbOp {
28
+ private tcb;
29
+ private scope;
30
+ private expression;
31
+ constructor(tcb: Context, scope: Scope, expression: AST);
32
+ get optional(): boolean;
33
+ execute(): null;
34
+ }
35
+ export declare class TcbExpressionTranslator {
36
+ protected tcb: Context;
37
+ protected scope: Scope;
38
+ constructor(tcb: Context, scope: Scope);
39
+ translate(ast: AST): ts.Expression;
40
+ /**
41
+ * Resolve an `AST` expression within the given scope.
42
+ *
43
+ * Some `AST` expressions refer to top-level concepts (references, variables, the component
44
+ * context). This method assists in resolving those.
45
+ */
46
+ protected resolve(ast: AST): ts.Expression | null;
47
+ private getTargetNodeExpression;
48
+ protected isValidLetDeclarationAccess(target: TmplAstLetDeclaration, ast: PropertyRead): boolean;
49
+ }