@angular/compiler-cli 21.2.1 → 21.2.3
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.
- package/bundles/{chunk-PW54LIP6.js → chunk-6JHVJEKD.js} +5 -5
- package/bundles/chunk-FLWAEX6T.js +1 -1
- package/bundles/{chunk-VO3Q626H.js → chunk-KJC7YNMY.js} +2 -2
- package/bundles/{chunk-IG22BDVK.js → chunk-L3PEIUBN.js} +1296 -1323
- package/bundles/{chunk-WBUBKNAO.js → chunk-NU2SXS64.js} +1 -1
- package/bundles/index.js +4 -4
- package/bundles/private/migrations.js +2 -2
- package/bundles/private/testing.js +1 -1
- package/bundles/private/tooling.js +1 -1
- package/bundles/src/bin/ng_xi18n.js +4 -4
- package/bundles/src/bin/ngc.js +4 -4
- package/linker/src/file_linker/partial_linkers/util.d.ts +1 -1
- package/package.json +2 -2
- package/src/ngtsc/annotations/common/src/diagnostics.d.ts +7 -7
- package/src/ngtsc/core/api/src/adapter.d.ts +1 -1
- package/src/ngtsc/incremental/src/incremental.d.ts +1 -1
- package/src/ngtsc/typecheck/api/api.d.ts +80 -4
- package/src/ngtsc/typecheck/src/checker.d.ts +1 -1
- package/src/ngtsc/typecheck/src/comments.d.ts +0 -7
- package/src/ngtsc/typecheck/src/context.d.ts +1 -1
- package/src/ngtsc/typecheck/src/environment.d.ts +9 -7
- package/src/ngtsc/typecheck/src/expression.d.ts +3 -15
- package/src/ngtsc/typecheck/src/host_bindings.d.ts +1 -1
- package/src/ngtsc/typecheck/src/oob.d.ts +5 -4
- package/src/ngtsc/typecheck/src/ops/base.d.ts +3 -3
- package/src/ngtsc/typecheck/src/ops/bindings.d.ts +11 -8
- package/src/ngtsc/typecheck/src/ops/codegen.d.ts +74 -0
- package/src/ngtsc/typecheck/src/ops/context.d.ts +5 -7
- package/src/ngtsc/typecheck/src/ops/directive_constructor.d.ts +6 -6
- package/src/ngtsc/typecheck/src/ops/directive_type.d.ts +7 -7
- package/src/ngtsc/typecheck/src/ops/element.d.ts +2 -2
- package/src/ngtsc/typecheck/src/ops/events.d.ts +4 -4
- package/src/ngtsc/typecheck/src/ops/expression.d.ts +5 -5
- package/src/ngtsc/typecheck/src/ops/for_block.d.ts +2 -2
- package/src/ngtsc/typecheck/src/ops/host.d.ts +2 -2
- package/src/ngtsc/typecheck/src/ops/inputs.d.ts +4 -4
- package/src/ngtsc/typecheck/src/ops/let.d.ts +2 -2
- package/src/ngtsc/typecheck/src/ops/references.d.ts +5 -5
- package/src/ngtsc/typecheck/src/ops/schema.d.ts +2 -2
- package/src/ngtsc/typecheck/src/ops/scope.d.ts +10 -10
- package/src/ngtsc/typecheck/src/ops/selectorless.d.ts +2 -2
- package/src/ngtsc/typecheck/src/ops/signal_forms.d.ts +6 -6
- package/src/ngtsc/typecheck/src/ops/template.d.ts +2 -2
- package/src/ngtsc/typecheck/src/ops/variables.d.ts +6 -6
- package/src/ngtsc/typecheck/src/reference_emit_environment.d.ts +18 -4
- package/src/ngtsc/typecheck/src/tcb_adapter.d.ts +20 -0
- package/src/ngtsc/typecheck/src/tcb_util.d.ts +2 -1
- package/src/ngtsc/typecheck/src/ts_util.d.ts +0 -37
- package/src/ngtsc/typecheck/src/type_check_block.d.ts +2 -4
- package/src/ngtsc/typecheck/src/type_check_file.d.ts +4 -2
- package/src/ngtsc/typecheck/src/type_constructor.d.ts +4 -3
package/bundles/index.js
CHANGED
|
@@ -17,7 +17,7 @@ import {
|
|
|
17
17
|
isTsDiagnostic,
|
|
18
18
|
performCompilation,
|
|
19
19
|
readConfiguration
|
|
20
|
-
} from "./chunk-
|
|
20
|
+
} from "./chunk-KJC7YNMY.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-
|
|
37
|
+
} from "./chunk-6JHVJEKD.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-
|
|
49
|
+
} from "./chunk-L3PEIUBN.js";
|
|
50
50
|
import "./chunk-CSUVPNMK.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.2.
|
|
80
|
+
var VERSION = new Version("21.2.3");
|
|
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-
|
|
8
|
+
} from "../chunk-6JHVJEKD.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-
|
|
35
|
+
} from "../chunk-L3PEIUBN.js";
|
|
36
36
|
import "../chunk-CSUVPNMK.js";
|
|
37
37
|
import {
|
|
38
38
|
getFileSystem,
|
|
@@ -6,12 +6,12 @@
|
|
|
6
6
|
import {
|
|
7
7
|
main,
|
|
8
8
|
readCommandLineAndConfiguration
|
|
9
|
-
} from "../../chunk-
|
|
9
|
+
} from "../../chunk-NU2SXS64.js";
|
|
10
10
|
import {
|
|
11
11
|
EmitFlags
|
|
12
|
-
} from "../../chunk-
|
|
13
|
-
import "../../chunk-
|
|
14
|
-
import "../../chunk-
|
|
12
|
+
} from "../../chunk-KJC7YNMY.js";
|
|
13
|
+
import "../../chunk-6JHVJEKD.js";
|
|
14
|
+
import "../../chunk-L3PEIUBN.js";
|
|
15
15
|
import "../../chunk-CSUVPNMK.js";
|
|
16
16
|
import {
|
|
17
17
|
setFileSystem
|
package/bundles/src/bin/ngc.js
CHANGED
|
@@ -5,10 +5,10 @@
|
|
|
5
5
|
|
|
6
6
|
import {
|
|
7
7
|
main
|
|
8
|
-
} from "../../chunk-
|
|
9
|
-
import "../../chunk-
|
|
10
|
-
import "../../chunk-
|
|
11
|
-
import "../../chunk-
|
|
8
|
+
} from "../../chunk-NU2SXS64.js";
|
|
9
|
+
import "../../chunk-KJC7YNMY.js";
|
|
10
|
+
import "../../chunk-6JHVJEKD.js";
|
|
11
|
+
import "../../chunk-L3PEIUBN.js";
|
|
12
12
|
import "../../chunk-CSUVPNMK.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.2.
|
|
10
|
+
export declare const PLACEHOLDER_VERSION = "21.2.3";
|
|
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.2.
|
|
3
|
+
"version": "21.2.3",
|
|
4
4
|
"description": "Angular - the compiler CLI for Node.js",
|
|
5
5
|
"typings": "index.d.ts",
|
|
6
6
|
"bin": {
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
"typescript": "5.9.3"
|
|
44
44
|
},
|
|
45
45
|
"peerDependencies": {
|
|
46
|
-
"@angular/compiler": "21.2.
|
|
46
|
+
"@angular/compiler": "21.2.3",
|
|
47
47
|
"typescript": ">=5.9 <6.1"
|
|
48
48
|
},
|
|
49
49
|
"peerDependenciesMeta": {
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
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
8
|
import ts from 'typescript';
|
|
9
9
|
import { FatalDiagnosticError } from '../../../diagnostics';
|
|
10
10
|
import { Reference } from '../../../imports';
|
|
@@ -56,7 +56,7 @@ export declare function findInheritedCtor(node: ClassDeclaration, injectableRegi
|
|
|
56
56
|
* from external files. This is a common scenario for errors in local compilation mode,
|
|
57
57
|
* and so this helper can be used to quickly generate the relevant errors.
|
|
58
58
|
*
|
|
59
|
-
* @param nodeToHighlight Node to be highlighted in
|
|
59
|
+
* @param nodeToHighlight Node to be highlighted in the error message.
|
|
60
60
|
* Will default to value.node if not provided.
|
|
61
61
|
*/
|
|
62
62
|
export declare function assertLocalCompilationUnresolvedConst(compilationMode: CompilationMode, value: ResolvedValue, nodeToHighlight: ts.Node | null, errorMessage: string): void;
|
|
@@ -12,7 +12,7 @@ import { ExtendedTsCompilerHost, UnifiedModulesHost } from './interfaces';
|
|
|
12
12
|
* Names of methods from `ExtendedTsCompilerHost` that need to be provided by the
|
|
13
13
|
* `NgCompilerAdapter`.
|
|
14
14
|
*/
|
|
15
|
-
export type ExtendedCompilerHostMethods = 'getCanonicalFileName' | 'resolveModuleNames' | 'getCurrentDirectory' | 'getModifiedResourceFiles' | 'readResource' | 'resourceNameToFileName' | 'transformResource';
|
|
15
|
+
export type ExtendedCompilerHostMethods = 'getCanonicalFileName' | 'getSourceFile' | 'resolveModuleNames' | 'getCurrentDirectory' | 'getModifiedResourceFiles' | 'readResource' | 'resourceNameToFileName' | 'transformResource';
|
|
16
16
|
/**
|
|
17
17
|
* Adapter for `NgCompiler` that allows it to be used in various circumstances, such as
|
|
18
18
|
* command-line `ngc`, as a plugin to `ts_library` in Bazel, or from the Language Service.
|
|
@@ -35,7 +35,7 @@ export declare class IncrementalCompilation implements IncrementalBuild<ClassRec
|
|
|
35
35
|
/**
|
|
36
36
|
* Begin a fresh `IncrementalCompilation`.
|
|
37
37
|
*/
|
|
38
|
-
static fresh(
|
|
38
|
+
static fresh(versions: Map<AbsoluteFsPath, string> | null): IncrementalCompilation;
|
|
39
39
|
static incremental(program: ts.Program, newVersions: Map<AbsoluteFsPath, string> | null, oldProgram: ts.Program, oldState: IncrementalState, modifiedResourceFiles: Set<AbsoluteFsPath> | null, perf: PerfRecorder): IncrementalCompilation;
|
|
40
40
|
get state(): IncrementalState;
|
|
41
41
|
get semanticDepGraphUpdater(): SemanticDepGraphUpdater;
|
|
@@ -5,12 +5,89 @@
|
|
|
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 { AbsoluteSourceSpan, BoundTarget, DirectiveMeta, ParseSourceSpan, SchemaMetadata } from '@angular/compiler';
|
|
8
|
+
import { AbsoluteSourceSpan, BoundTarget, DirectiveMeta, LegacyAnimationTriggerNames, ParseSourceSpan, SchemaMetadata } from '@angular/compiler';
|
|
9
9
|
import ts from 'typescript';
|
|
10
10
|
import { ErrorCode } from '../../diagnostics';
|
|
11
11
|
import { Reference } from '../../imports';
|
|
12
|
-
import { ClassPropertyMapping, DirectiveTypeCheckMeta, HostDirectiveMeta, InputMapping, PipeMeta } from '../../metadata';
|
|
12
|
+
import { ClassPropertyMapping, ClassPropertyName, DirectiveTypeCheckMeta, HostDirectiveMeta, InputMapping, InputOrOutput, PipeMeta, TemplateGuardMeta } from '../../metadata';
|
|
13
13
|
import { ClassDeclaration } from '../../reflection';
|
|
14
|
+
export interface TcbReferenceMetadata {
|
|
15
|
+
/** The name of the class */
|
|
16
|
+
name: string;
|
|
17
|
+
/** The module path where the symbol is located, or null if local/ambient */
|
|
18
|
+
moduleName: string | null;
|
|
19
|
+
/** True if the symbol successfully emitted locally (no external import required) */
|
|
20
|
+
isLocal: boolean;
|
|
21
|
+
/** If the reference could not be externally emitted, this string holds the diagnostic reason why */
|
|
22
|
+
unexportedDiagnostic: string | null;
|
|
23
|
+
/**
|
|
24
|
+
* Defines the `AbsoluteSourceSpan` of the target's node name, if available.
|
|
25
|
+
*/
|
|
26
|
+
nodeNameSpan?: AbsoluteSourceSpan;
|
|
27
|
+
/**
|
|
28
|
+
* The absolute path to the file containing the reference node, if available.
|
|
29
|
+
*/
|
|
30
|
+
nodeFilePath?: string;
|
|
31
|
+
}
|
|
32
|
+
export type TcbReferenceKey = string & {
|
|
33
|
+
__brand: 'TcbReferenceKey';
|
|
34
|
+
};
|
|
35
|
+
export interface TcbTypeParameter {
|
|
36
|
+
name: string;
|
|
37
|
+
representation: string;
|
|
38
|
+
representationWithDefault: string;
|
|
39
|
+
}
|
|
40
|
+
export type TcbInputMapping = InputOrOutput & {
|
|
41
|
+
required: boolean;
|
|
42
|
+
/**
|
|
43
|
+
* AST-free string representation of the transform type of the input, if available.
|
|
44
|
+
*/
|
|
45
|
+
transformType?: string;
|
|
46
|
+
};
|
|
47
|
+
export interface TcbPipeMetadata {
|
|
48
|
+
name: string;
|
|
49
|
+
ref: TcbReferenceMetadata;
|
|
50
|
+
isExplicitlyDeferred: boolean;
|
|
51
|
+
}
|
|
52
|
+
export interface TcbDirectiveMetadata {
|
|
53
|
+
ref: TcbReferenceMetadata;
|
|
54
|
+
name: string;
|
|
55
|
+
selector: string | null;
|
|
56
|
+
isComponent: boolean;
|
|
57
|
+
isGeneric: boolean;
|
|
58
|
+
isStructural: boolean;
|
|
59
|
+
isStandalone: boolean;
|
|
60
|
+
isExplicitlyDeferred: boolean;
|
|
61
|
+
preserveWhitespaces: boolean;
|
|
62
|
+
exportAs: string[] | null;
|
|
63
|
+
/** Type parameters of the directive, if available. */
|
|
64
|
+
typeParameters: TcbTypeParameter[] | null;
|
|
65
|
+
inputs: ClassPropertyMapping<TcbInputMapping>;
|
|
66
|
+
outputs: ClassPropertyMapping;
|
|
67
|
+
hasRequiresInlineTypeCtor: boolean;
|
|
68
|
+
ngTemplateGuards: TemplateGuardMeta[];
|
|
69
|
+
hasNgTemplateContextGuard: boolean;
|
|
70
|
+
hasNgFieldDirective: boolean;
|
|
71
|
+
coercedInputFields: Set<ClassPropertyName>;
|
|
72
|
+
restrictedInputFields: Set<ClassPropertyName>;
|
|
73
|
+
stringLiteralInputFields: Set<ClassPropertyName>;
|
|
74
|
+
undeclaredInputFields: Set<ClassPropertyName>;
|
|
75
|
+
publicMethods: Set<string>;
|
|
76
|
+
ngContentSelectors: string[] | null;
|
|
77
|
+
animationTriggerNames: LegacyAnimationTriggerNames | null;
|
|
78
|
+
}
|
|
79
|
+
export interface TcbComponentMetadata {
|
|
80
|
+
ref: TcbReferenceMetadata;
|
|
81
|
+
typeParameters: TcbTypeParameter[] | null;
|
|
82
|
+
}
|
|
83
|
+
export interface TcbTypeCheckBlockMetadata {
|
|
84
|
+
id: TypeCheckId;
|
|
85
|
+
boundTarget: BoundTarget<TcbDirectiveMetadata>;
|
|
86
|
+
pipes: Map<string, TcbPipeMetadata> | null;
|
|
87
|
+
schemas: SchemaMetadata[];
|
|
88
|
+
isStandalone: boolean;
|
|
89
|
+
preserveWhitespaces: boolean;
|
|
90
|
+
}
|
|
14
91
|
/**
|
|
15
92
|
* Extension of `DirectiveMeta` that includes additional information required to type-check the
|
|
16
93
|
* usage of a particular directive.
|
|
@@ -90,8 +167,7 @@ export interface TypeCtorMetadata {
|
|
|
90
167
|
* Input, output, and query field names in the type which should be included as constructor input.
|
|
91
168
|
*/
|
|
92
169
|
fields: {
|
|
93
|
-
inputs: ClassPropertyMapping<
|
|
94
|
-
queries: string[];
|
|
170
|
+
inputs: ClassPropertyMapping<TcbInputMapping>;
|
|
95
171
|
};
|
|
96
172
|
/**
|
|
97
173
|
* `Set` of field names which have type coercion enabled.
|
|
@@ -75,7 +75,7 @@ export declare class TemplateTypeCheckerImpl implements TemplateTypeChecker {
|
|
|
75
75
|
private elementTagCache;
|
|
76
76
|
private isComplete;
|
|
77
77
|
private priorResultsAdopted;
|
|
78
|
-
constructor(originalProgram: ts.Program, programDriver: ProgramDriver, typeCheckAdapter: ProgramTypeCheckAdapter, config: TypeCheckingConfig, refEmitter: ReferenceEmitter, reflector: ReflectionHost, compilerHost: Pick<ts.CompilerHost, 'getCanonicalFileName'>, priorBuild: IncrementalBuild<unknown, FileTypeCheckingData>, metaReader: MetadataReader, localMetaReader: MetadataReaderWithIndex, ngModuleIndex: NgModuleIndex, componentScopeReader: ComponentScopeReader, typeCheckScopeRegistry: TypeCheckScopeRegistry, perf: PerfRecorder);
|
|
78
|
+
constructor(originalProgram: ts.Program, programDriver: ProgramDriver, typeCheckAdapter: ProgramTypeCheckAdapter, config: TypeCheckingConfig, refEmitter: ReferenceEmitter, reflector: ReflectionHost, compilerHost: Pick<ts.CompilerHost, 'getCanonicalFileName' | 'getSourceFile'>, priorBuild: IncrementalBuild<unknown, FileTypeCheckingData>, metaReader: MetadataReader, localMetaReader: MetadataReaderWithIndex, ngModuleIndex: NgModuleIndex, componentScopeReader: ComponentScopeReader, typeCheckScopeRegistry: TypeCheckScopeRegistry, perf: PerfRecorder);
|
|
79
79
|
getTemplate(component: ts.ClassDeclaration, optimizeFor?: OptimizeFor): TmplAstNode[] | null;
|
|
80
80
|
getHostElement(directive: ts.ClassDeclaration, optimizeFor?: OptimizeFor): TmplAstHostElement | null;
|
|
81
81
|
getDirectivesOfNode(component: ts.ClassDeclaration, node: TmplAstElement | TmplAstTemplate): TypeCheckableDirectiveMeta[] | null;
|
|
@@ -26,13 +26,6 @@ export declare enum ExpressionIdentifier {
|
|
|
26
26
|
EVENT_PARAMETER = "EP",
|
|
27
27
|
VARIABLE_AS_EXPRESSION = "VAE"
|
|
28
28
|
}
|
|
29
|
-
/** Tags the node with the given expression identifier. */
|
|
30
|
-
export declare function addExpressionIdentifier(node: ts.Node, identifier: ExpressionIdentifier): void;
|
|
31
|
-
/**
|
|
32
|
-
* Tag the `ts.Node` with an indication that any errors arising from the evaluation of the node
|
|
33
|
-
* should be ignored.
|
|
34
|
-
*/
|
|
35
|
-
export declare function markIgnoreDiagnostics(node: ts.Node): void;
|
|
36
29
|
/** Returns true if the node has a marker that indicates diagnostics errors should be ignored. */
|
|
37
30
|
export declare function hasIgnoreForDiagnosticsMarker(node: ts.Node, sourceFile: ts.SourceFile): boolean;
|
|
38
31
|
export interface FindOptions<T extends ts.Node> {
|
|
@@ -153,7 +153,7 @@ export declare class TypeCheckContextImpl implements TypeCheckContext {
|
|
|
153
153
|
private inlining;
|
|
154
154
|
private perf;
|
|
155
155
|
private fileMap;
|
|
156
|
-
constructor(config: TypeCheckingConfig, compilerHost: Pick<ts.CompilerHost, 'getCanonicalFileName'>, refEmitter: ReferenceEmitter, reflector: ReflectionHost, host: TypeCheckingHost, inlining: InliningMode, perf: PerfRecorder);
|
|
156
|
+
constructor(config: TypeCheckingConfig, compilerHost: Pick<ts.CompilerHost, 'getCanonicalFileName' | 'getSourceFile'>, refEmitter: ReferenceEmitter, reflector: ReflectionHost, host: TypeCheckingHost, inlining: InliningMode, perf: PerfRecorder);
|
|
157
157
|
/**
|
|
158
158
|
* A `Map` of `ts.SourceFile`s that the context has seen to the operations (additions of methods
|
|
159
159
|
* or type-check blocks) that need to be eventually performed on that file.
|
|
@@ -9,8 +9,9 @@ import ts from 'typescript';
|
|
|
9
9
|
import { Reference, ReferenceEmitter } from '../../imports';
|
|
10
10
|
import { ClassDeclaration, ReflectionHost } from '../../reflection';
|
|
11
11
|
import { ImportManager } from '../../translator';
|
|
12
|
-
import {
|
|
12
|
+
import { TcbDirectiveMetadata, TcbPipeMetadata, TcbReferenceKey, TcbReferenceMetadata, TypeCheckingConfig } from '../api';
|
|
13
13
|
import { ReferenceEmitEnvironment } from './reference_emit_environment';
|
|
14
|
+
import { TcbExpr } from './ops/codegen';
|
|
14
15
|
/**
|
|
15
16
|
* A context which hosts one or more Type Check Blocks (TCBs).
|
|
16
17
|
*
|
|
@@ -26,9 +27,9 @@ export declare class Environment extends ReferenceEmitEnvironment {
|
|
|
26
27
|
readonly config: TypeCheckingConfig;
|
|
27
28
|
private nextIds;
|
|
28
29
|
private typeCtors;
|
|
29
|
-
protected typeCtorStatements:
|
|
30
|
+
protected typeCtorStatements: TcbExpr[];
|
|
30
31
|
private pipeInsts;
|
|
31
|
-
protected pipeInstStatements:
|
|
32
|
+
protected pipeInstStatements: TcbExpr[];
|
|
32
33
|
constructor(config: TypeCheckingConfig, importManager: ImportManager, refEmitter: ReferenceEmitter, reflector: ReflectionHost, contextFile: ts.SourceFile);
|
|
33
34
|
/**
|
|
34
35
|
* Get an expression referring to a type constructor for the given directive.
|
|
@@ -36,14 +37,15 @@ export declare class Environment extends ReferenceEmitEnvironment {
|
|
|
36
37
|
* Depending on the shape of the directive itself, this could be either a reference to a declared
|
|
37
38
|
* type constructor, or to an inline type constructor.
|
|
38
39
|
*/
|
|
39
|
-
typeCtorFor(dir:
|
|
40
|
-
pipeInst(
|
|
40
|
+
typeCtorFor(dir: TcbDirectiveMetadata): TcbExpr;
|
|
41
|
+
pipeInst(pipe: TcbPipeMetadata): TcbExpr;
|
|
41
42
|
/**
|
|
42
43
|
* Generate a `ts.Expression` that references the given node.
|
|
43
44
|
*
|
|
44
45
|
* This may involve importing the node into the file if it's not declared there already.
|
|
45
46
|
*/
|
|
46
|
-
reference(ref: Reference<ClassDeclaration<ts.ClassDeclaration>>):
|
|
47
|
+
reference(ref: Reference<ClassDeclaration<ts.ClassDeclaration>>): TcbExpr;
|
|
47
48
|
private emitTypeParameters;
|
|
48
|
-
getPreludeStatements():
|
|
49
|
+
getPreludeStatements(): TcbExpr[];
|
|
49
50
|
}
|
|
51
|
+
export declare function getTcbReferenceKey(ref: TcbReferenceMetadata): TcbReferenceKey;
|
|
@@ -6,22 +6,10 @@
|
|
|
6
6
|
* found in the LICENSE file at https://angular.dev/license
|
|
7
7
|
*/
|
|
8
8
|
import { AST } from '@angular/compiler';
|
|
9
|
-
import
|
|
9
|
+
import { TcbExpr } from './ops/codegen';
|
|
10
10
|
import { TypeCheckingConfig } from '../api';
|
|
11
11
|
/**
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
* Historically this expression was using `null as any`, but a newly-added check in TypeScript 5.6
|
|
15
|
-
* (https://devblogs.microsoft.com/typescript/announcing-typescript-5-6-beta/#disallowed-nullish-and-truthy-checks)
|
|
16
|
-
* started flagging it as always being nullish. Other options that were considered:
|
|
17
|
-
* - `NaN as any` or `Infinity as any` - not used, because they don't work if the `noLib` compiler
|
|
18
|
-
* option is enabled. Also they require more characters.
|
|
19
|
-
* - Some flavor of function call, like `isNan(0) as any` - requires even more characters than the
|
|
20
|
-
* NaN option and has the same issue with `noLib`.
|
|
21
|
-
*/
|
|
22
|
-
export declare function getAnyExpression(): ts.AsExpression;
|
|
23
|
-
/**
|
|
24
|
-
* Convert an `AST` to TypeScript code directly, without going through an intermediate `Expression`
|
|
12
|
+
* Convert an `AST` to a `TcbExpr` directly, without going through an intermediate `Expression`
|
|
25
13
|
* AST.
|
|
26
14
|
*/
|
|
27
|
-
export declare function
|
|
15
|
+
export declare function astToTcbExpr(ast: AST, maybeResolve: (ast: AST) => TcbExpr | null, config: TypeCheckingConfig): TcbExpr;
|
|
@@ -23,7 +23,7 @@ export declare function createHostElement(type: 'component' | 'directive', selec
|
|
|
23
23
|
* Creates an AST node that can be used as a guard in `if` statements to distinguish TypeScript
|
|
24
24
|
* nodes used for checking host bindings from ones used for checking templates.
|
|
25
25
|
*/
|
|
26
|
-
export declare function createHostBindingsBlockGuard():
|
|
26
|
+
export declare function createHostBindingsBlockGuard(): string;
|
|
27
27
|
/**
|
|
28
28
|
* Determines if a given node is a guard that indicates that descendant nodes are used to check
|
|
29
29
|
* host bindings.
|
|
@@ -8,7 +8,7 @@
|
|
|
8
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
9
|
import ts from 'typescript';
|
|
10
10
|
import { ClassDeclaration } from '../../reflection';
|
|
11
|
-
import { TemplateDiagnostic, TypeCheckId } from '../api';
|
|
11
|
+
import { TcbDirectiveMetadata, TemplateDiagnostic, TypeCheckId } from '../api';
|
|
12
12
|
import { TypeCheckSourceResolver } from './tcb_util';
|
|
13
13
|
/**
|
|
14
14
|
* Collects `ts.Diagnostic`s on problems which occur in the template which aren't directly sourced
|
|
@@ -73,7 +73,7 @@ export interface OutOfBandDiagnosticRecorder {
|
|
|
73
73
|
/**
|
|
74
74
|
* Reports a split two way binding error message.
|
|
75
75
|
*/
|
|
76
|
-
splitTwoWayBinding(id: TypeCheckId, input: TmplAstBoundAttribute, output: TmplAstBoundEvent, inputConsumer:
|
|
76
|
+
splitTwoWayBinding(id: TypeCheckId, input: TmplAstBoundAttribute, output: TmplAstBoundEvent, inputConsumer: Pick<TcbDirectiveMetadata, 'name' | 'isComponent' | 'ref'>, outputConsumer: Pick<TcbDirectiveMetadata, 'name' | 'isComponent' | 'ref'> | TmplAstElement): void;
|
|
77
77
|
/** Reports required inputs that haven't been bound. */
|
|
78
78
|
missingRequiredInputs(id: TypeCheckId, element: TmplAstElement | TmplAstTemplate | TmplAstComponent | TmplAstDirective, directiveName: string, isComponent: boolean, inputAliases: string[]): void;
|
|
79
79
|
/**
|
|
@@ -136,6 +136,7 @@ export interface OutOfBandDiagnosticRecorder {
|
|
|
136
136
|
}
|
|
137
137
|
export declare class OutOfBandDiagnosticRecorderImpl implements OutOfBandDiagnosticRecorder {
|
|
138
138
|
private resolver;
|
|
139
|
+
private getSourceFile;
|
|
139
140
|
private readonly _diagnostics;
|
|
140
141
|
/**
|
|
141
142
|
* Tracks which `BindingPipe` nodes have already been recorded as invalid, so only one diagnostic
|
|
@@ -144,7 +145,7 @@ export declare class OutOfBandDiagnosticRecorderImpl implements OutOfBandDiagnos
|
|
|
144
145
|
private readonly recordedPipes;
|
|
145
146
|
/** Common pipes that can be suggested to users. */
|
|
146
147
|
private readonly pipeSuggestions;
|
|
147
|
-
constructor(resolver: TypeCheckSourceResolver);
|
|
148
|
+
constructor(resolver: TypeCheckSourceResolver, getSourceFile?: (fileName: string) => ts.SourceFile | undefined);
|
|
148
149
|
get diagnostics(): ReadonlyArray<TemplateDiagnostic>;
|
|
149
150
|
missingReferenceTarget(id: TypeCheckId, ref: TmplAstReference): void;
|
|
150
151
|
missingPipe(id: TypeCheckId, ast: BindingPipe, isStandalone: boolean): void;
|
|
@@ -154,7 +155,7 @@ export declare class OutOfBandDiagnosticRecorderImpl implements OutOfBandDiagnos
|
|
|
154
155
|
requiresInlineTcb(id: TypeCheckId, node: ClassDeclaration): void;
|
|
155
156
|
requiresInlineTypeConstructors(id: TypeCheckId, node: ClassDeclaration, directives: ClassDeclaration[]): void;
|
|
156
157
|
suboptimalTypeInference(id: TypeCheckId, variables: TmplAstVariable[]): void;
|
|
157
|
-
splitTwoWayBinding(id: TypeCheckId, input: TmplAstBoundAttribute, output: TmplAstBoundEvent, inputConsumer:
|
|
158
|
+
splitTwoWayBinding(id: TypeCheckId, input: TmplAstBoundAttribute, output: TmplAstBoundEvent, inputConsumer: Pick<TcbDirectiveMetadata, 'name' | 'isComponent' | 'ref'>, outputConsumer: Pick<TcbDirectiveMetadata, 'name' | 'isComponent' | 'ref'> | TmplAstElement): void;
|
|
158
159
|
missingRequiredInputs(id: TypeCheckId, element: TmplAstElement | TmplAstTemplate | TmplAstComponent | TmplAstDirective, directiveName: string, isComponent: boolean, inputAliases: string[]): void;
|
|
159
160
|
illegalForLoopTrackAccess(id: TypeCheckId, block: TmplAstForLoopBlock, access: PropertyRead): void;
|
|
160
161
|
inaccessibleDeferredTriggerElement(id: TypeCheckId, trigger: TmplAstHoverDeferredTrigger | TmplAstInteractionDeferredTrigger | TmplAstViewportDeferredTrigger): void;
|
|
@@ -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
|
|
8
|
+
import { TcbExpr } from './codegen';
|
|
9
9
|
/**
|
|
10
10
|
* A code generation operation that's involved in the construction of a Type Check Block.
|
|
11
11
|
*
|
|
@@ -30,7 +30,7 @@ export declare abstract class TcbOp {
|
|
|
30
30
|
* code to generate, parse and type-check, overall positively contributing to performance.
|
|
31
31
|
*/
|
|
32
32
|
abstract readonly optional: boolean;
|
|
33
|
-
abstract execute():
|
|
33
|
+
abstract execute(): TcbExpr | null;
|
|
34
34
|
/**
|
|
35
35
|
* Replacement value or operation used while this `TcbOp` is executing (i.e. to resolve circular
|
|
36
36
|
* references during its execution).
|
|
@@ -39,5 +39,5 @@ export declare abstract class TcbOp {
|
|
|
39
39
|
* `TcbOp` can be returned in cases where additional code generation is necessary to deal with
|
|
40
40
|
* circular references.
|
|
41
41
|
*/
|
|
42
|
-
circularFallback(): TcbOp |
|
|
42
|
+
circularFallback(): TcbOp | TcbExpr;
|
|
43
43
|
}
|
|
@@ -6,11 +6,10 @@
|
|
|
6
6
|
* found in the LICENSE file at https://angular.dev/license
|
|
7
7
|
*/
|
|
8
8
|
import { AST, ParseSourceSpan, TmplAstBoundAttribute, TmplAstBoundEvent, TmplAstComponent, TmplAstDirective, TmplAstElement, TmplAstTemplate } from '@angular/compiler';
|
|
9
|
-
import
|
|
10
|
-
import { TypeCheckableDirectiveMeta } from '../../api';
|
|
9
|
+
import { TcbDirectiveMetadata } from '../../api';
|
|
11
10
|
import { ClassPropertyName } from '../../../metadata';
|
|
12
|
-
import { Reference } from '../../../imports';
|
|
13
11
|
import { Context } from './context';
|
|
12
|
+
import { TcbExpr } from './codegen';
|
|
14
13
|
export interface TcbBoundAttribute {
|
|
15
14
|
value: AST | string;
|
|
16
15
|
sourceSpan: ParseSourceSpan;
|
|
@@ -19,7 +18,7 @@ export interface TcbBoundAttribute {
|
|
|
19
18
|
fieldName: ClassPropertyName;
|
|
20
19
|
required: boolean;
|
|
21
20
|
isSignal: boolean;
|
|
22
|
-
transformType
|
|
21
|
+
transformType?: string;
|
|
23
22
|
isTwoWayBinding: boolean;
|
|
24
23
|
}[];
|
|
25
24
|
}
|
|
@@ -33,9 +32,13 @@ export interface TcbDirectiveBoundInput {
|
|
|
33
32
|
*/
|
|
34
33
|
field: string;
|
|
35
34
|
/**
|
|
36
|
-
* The `
|
|
35
|
+
* The `TcbExpr` corresponding with the input binding expression.
|
|
37
36
|
*/
|
|
38
|
-
expression:
|
|
37
|
+
expression: TcbExpr;
|
|
38
|
+
/**
|
|
39
|
+
* The input's original value expression.
|
|
40
|
+
*/
|
|
41
|
+
originalExpression: AST | string;
|
|
39
42
|
/**
|
|
40
43
|
* The source span of the full attribute binding.
|
|
41
44
|
*/
|
|
@@ -56,9 +59,9 @@ export interface TcbDirectiveUnsetInput {
|
|
|
56
59
|
field: string;
|
|
57
60
|
}
|
|
58
61
|
export type TcbDirectiveInput = TcbDirectiveBoundInput | TcbDirectiveUnsetInput;
|
|
59
|
-
export declare function getBoundAttributes(directive:
|
|
62
|
+
export declare function getBoundAttributes(directive: TcbDirectiveMetadata, node: TmplAstTemplate | TmplAstElement | TmplAstComponent | TmplAstDirective): TcbBoundAttribute[];
|
|
60
63
|
export declare function checkSplitTwoWayBinding(inputName: string, output: TmplAstBoundEvent, inputs: TmplAstBoundAttribute[], tcb: Context): boolean;
|
|
61
64
|
/**
|
|
62
65
|
* Potentially widens the type of `expr` according to the type-checking configuration.
|
|
63
66
|
*/
|
|
64
|
-
export declare function widenBinding(expr:
|
|
67
|
+
export declare function widenBinding(expr: TcbExpr, tcb: Context, originalValue: string | AST): TcbExpr;
|
|
@@ -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 { AbsoluteSourceSpan, ParseSourceSpan } from '@angular/compiler';
|
|
9
|
+
import ts from 'typescript';
|
|
10
|
+
import { ExpressionIdentifier } from '../comments';
|
|
11
|
+
/** Represents an expression generated within a type check block. */
|
|
12
|
+
export declare class TcbExpr {
|
|
13
|
+
private source;
|
|
14
|
+
/** Text for the content containing the expression's location information. */
|
|
15
|
+
private spanComment;
|
|
16
|
+
/** Text for the content containing the expression's identifier. */
|
|
17
|
+
private identifierComment;
|
|
18
|
+
/**
|
|
19
|
+
* Text of the comment instructing the type checker to
|
|
20
|
+
* ignore diagnostics coming from this expression.
|
|
21
|
+
*/
|
|
22
|
+
private ignoreComment;
|
|
23
|
+
constructor(source: string);
|
|
24
|
+
/**
|
|
25
|
+
* Converts the node's current state to a string.
|
|
26
|
+
* @param ignoreComments Whether the comments associated with the expression should be skipped.
|
|
27
|
+
*/
|
|
28
|
+
print(ignoreComments?: boolean): string;
|
|
29
|
+
/**
|
|
30
|
+
* Adds a synthetic comment to the expression that represents the parse span of the provided node.
|
|
31
|
+
* This comment can later be retrieved as trivia of a node to recover original source locations.
|
|
32
|
+
* @param span Span from the parser containing the location information.
|
|
33
|
+
*/
|
|
34
|
+
addParseSpanInfo(span: AbsoluteSourceSpan | ParseSourceSpan): this;
|
|
35
|
+
/** Marks the expression to be ignored for diagnostics. */
|
|
36
|
+
markIgnoreDiagnostics(): this;
|
|
37
|
+
/**
|
|
38
|
+
* Wraps the expression in parenthesis such that inserted
|
|
39
|
+
* span comments become attached to the proper node.
|
|
40
|
+
*/
|
|
41
|
+
wrapForTypeChecker(): this;
|
|
42
|
+
/**
|
|
43
|
+
* Tags the expression with an identifier.
|
|
44
|
+
* @param identifier Identifier to apply to the expression.
|
|
45
|
+
*/
|
|
46
|
+
addExpressionIdentifier(identifier: ExpressionIdentifier): this;
|
|
47
|
+
/**
|
|
48
|
+
* `toString` implementation meant to catch errors like accidentally
|
|
49
|
+
* writing `foo ${expr} bar` instead of `foo ${expr.print()} bar`.
|
|
50
|
+
*/
|
|
51
|
+
toString(): never;
|
|
52
|
+
/** Format a comment string as a TypeScript comment. */
|
|
53
|
+
private formatComment;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Declares a variable with a specific type.
|
|
57
|
+
* @param identifier Identifier used to refer to the variable.
|
|
58
|
+
* @param type Type that the variable should be initialized to.
|
|
59
|
+
*/
|
|
60
|
+
export declare function declareVariable(identifier: TcbExpr, type: TcbExpr): TcbExpr;
|
|
61
|
+
/**
|
|
62
|
+
* Formats an array of `TcbExpr` as a block of single statements.
|
|
63
|
+
* @param expressions Expressions to format.
|
|
64
|
+
* @param singleLine Whether to print them on a single line or across multiple. Defaults to multiple.
|
|
65
|
+
*/
|
|
66
|
+
export declare function getStatementsBlock(expressions: TcbExpr[], singleLine?: boolean): string;
|
|
67
|
+
/** Wraps a string value in quotes and escapes relevant characters. */
|
|
68
|
+
export declare function quoteAndEscape(value: string): string;
|
|
69
|
+
/**
|
|
70
|
+
* Prints a TypeScript node as a string.
|
|
71
|
+
*
|
|
72
|
+
* @deprecated This is a temporary method until all code generation code has been migrated.
|
|
73
|
+
*/
|
|
74
|
+
export declare function tempPrint(node: ts.Node, sourceFile: ts.SourceFile): string;
|
|
@@ -6,11 +6,9 @@
|
|
|
6
6
|
* found in the LICENSE file at https://angular.dev/license
|
|
7
7
|
*/
|
|
8
8
|
import { BoundTarget, SchemaMetadata } from '@angular/compiler';
|
|
9
|
-
import ts from 'typescript';
|
|
10
9
|
import { DomSchemaChecker } from '../dom';
|
|
11
10
|
import { OutOfBandDiagnosticRecorder } from '../oob';
|
|
12
|
-
import {
|
|
13
|
-
import { PipeMeta } from '../../../metadata';
|
|
11
|
+
import { TypeCheckId, TcbDirectiveMetadata, TcbPipeMetadata } from '../../api';
|
|
14
12
|
import { Environment } from '../environment';
|
|
15
13
|
/**
|
|
16
14
|
* Controls how generics for the component context class will be handled during TCB generation.
|
|
@@ -49,19 +47,19 @@ export declare class Context {
|
|
|
49
47
|
readonly domSchemaChecker: DomSchemaChecker;
|
|
50
48
|
readonly oobRecorder: OutOfBandDiagnosticRecorder;
|
|
51
49
|
readonly id: TypeCheckId;
|
|
52
|
-
readonly boundTarget: BoundTarget<
|
|
50
|
+
readonly boundTarget: BoundTarget<TcbDirectiveMetadata>;
|
|
53
51
|
private pipes;
|
|
54
52
|
readonly schemas: SchemaMetadata[];
|
|
55
53
|
readonly hostIsStandalone: boolean;
|
|
56
54
|
readonly hostPreserveWhitespaces: boolean;
|
|
57
55
|
private nextId;
|
|
58
|
-
constructor(env: Environment, domSchemaChecker: DomSchemaChecker, oobRecorder: OutOfBandDiagnosticRecorder, id: TypeCheckId, boundTarget: BoundTarget<
|
|
56
|
+
constructor(env: Environment, domSchemaChecker: DomSchemaChecker, oobRecorder: OutOfBandDiagnosticRecorder, id: TypeCheckId, boundTarget: BoundTarget<TcbDirectiveMetadata>, pipes: Map<string, TcbPipeMetadata> | null, schemas: SchemaMetadata[], hostIsStandalone: boolean, hostPreserveWhitespaces: boolean);
|
|
59
57
|
/**
|
|
60
58
|
* Allocate a new variable name for use within the `Context`.
|
|
61
59
|
*
|
|
62
60
|
* Currently this uses a monotonically increasing counter, but in the future the variable name
|
|
63
61
|
* might change depending on the type of data being stored.
|
|
64
62
|
*/
|
|
65
|
-
allocateId():
|
|
66
|
-
getPipeByName(name: string):
|
|
63
|
+
allocateId(): string;
|
|
64
|
+
getPipeByName(name: string): TcbPipeMetadata | null;
|
|
67
65
|
}
|