@angular/compiler-cli 21.0.0-rc.1 → 21.0.0-rc.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-5UJIUEKT.js → chunk-3UWOVJPM.js} +20 -3
- package/bundles/{chunk-VBBJY6IR.js → chunk-67N3I5R2.js} +1675 -1523
- package/bundles/{chunk-DBAV4W4V.js → chunk-EZPRBQ4S.js} +2 -2
- package/bundles/{chunk-YVYYMXOI.js → chunk-IUWOX36C.js} +1 -1
- package/bundles/{chunk-DT6FD4OE.js → chunk-ZJZNLTWN.js} +1 -2
- package/bundles/index.js +4 -4
- package/bundles/linker/babel/index.js +1 -1
- package/bundles/linker/index.js +1 -1
- 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/docs/src/entities.d.ts +8 -2
- package/src/ngtsc/docs/src/extractor.d.ts +1 -0
- package/src/ngtsc/docs/src/type_alias_extractor.d.ts +1 -0
- package/src/ngtsc/typecheck/src/ops/base.d.ts +43 -0
- package/src/ngtsc/typecheck/src/ops/bindings.d.ts +64 -0
- package/src/ngtsc/typecheck/src/ops/completions.d.ts +22 -0
- package/src/ngtsc/typecheck/src/ops/content_projection.d.ts +34 -0
- package/src/ngtsc/typecheck/src/ops/context.d.ts +67 -0
- package/src/ngtsc/typecheck/src/ops/directive_constructor.d.ts +59 -0
- package/src/ngtsc/typecheck/src/ops/directive_type.d.ts +53 -0
- package/src/ngtsc/typecheck/src/ops/element.d.ts +26 -0
- package/src/ngtsc/typecheck/src/ops/events.d.ts +55 -0
- package/src/ngtsc/typecheck/src/ops/expression.d.ts +49 -0
- package/src/ngtsc/typecheck/src/ops/for_block.d.ts +32 -0
- package/src/ngtsc/typecheck/src/ops/host.d.ts +25 -0
- package/src/ngtsc/typecheck/src/ops/if_block.d.ts +28 -0
- package/src/ngtsc/typecheck/src/ops/inputs.d.ts +56 -0
- package/src/ngtsc/typecheck/src/ops/intersection_observer.d.ts +22 -0
- package/src/ngtsc/typecheck/src/ops/let.d.ts +29 -0
- package/src/ngtsc/typecheck/src/ops/references.d.ts +57 -0
- package/src/ngtsc/typecheck/src/ops/schema.d.ts +31 -0
- package/src/ngtsc/typecheck/src/ops/scope.d.ts +187 -0
- package/src/ngtsc/typecheck/src/ops/selectorless.d.ts +26 -0
- package/src/ngtsc/typecheck/src/ops/signal_forms.d.ts +40 -0
- package/src/ngtsc/typecheck/src/ops/switch_block.d.ts +25 -0
- package/src/ngtsc/typecheck/src/ops/template.d.ts +40 -0
- package/src/ngtsc/typecheck/src/ops/variables.d.ts +56 -0
- package/src/ngtsc/typecheck/src/type_check_block.d.ts +2 -274
- package/src/ngtsc/typecheck/src/type_check_file.d.ts +1 -1
|
@@ -8261,7 +8261,6 @@ function extractDirectiveMetadata(clazz, decorator, reflector, importTracker, ev
|
|
|
8261
8261
|
queries: contentQueries,
|
|
8262
8262
|
viewQueries,
|
|
8263
8263
|
selector,
|
|
8264
|
-
fullInheritance: false,
|
|
8265
8264
|
type,
|
|
8266
8265
|
typeArgumentCount: reflector.getGenericArityOfClass(clazz) || 0,
|
|
8267
8266
|
typeSourceSpan: createSourceSpan(clazz.name),
|
|
@@ -9791,7 +9790,7 @@ function _extractTemplateStyleUrls(template) {
|
|
|
9791
9790
|
|
|
9792
9791
|
// packages/compiler-cli/src/ngtsc/annotations/component/src/handler.js
|
|
9793
9792
|
import { compileClassDebugInfo, compileHmrInitializer, compileComponentClassMetadata, compileComponentDeclareClassMetadata, compileComponentFromMetadata, compileDeclareComponentFromMetadata, compileDeferResolverFunction, ConstantPool as ConstantPool2, CssSelector as CssSelector5, DomElementSchemaRegistry as DomElementSchemaRegistry3, ExternalExpr as ExternalExpr10, FactoryTarget as FactoryTarget3, makeBindingParser as makeBindingParser3, outputAst as o5, R3TargetBinder as R3TargetBinder2, R3TemplateDependencyKind, SelectorMatcher as SelectorMatcher3, ViewEncapsulation as ViewEncapsulation2, SelectorlessMatcher as SelectorlessMatcher2 } from "@angular/compiler";
|
|
9794
|
-
import
|
|
9793
|
+
import ts94 from "typescript";
|
|
9795
9794
|
|
|
9796
9795
|
// packages/compiler-cli/src/ngtsc/incremental/semantic_graph/src/api.js
|
|
9797
9796
|
import ts43 from "typescript";
|
|
@@ -10910,7 +10909,7 @@ var TypeCheckScopeRegistry = class {
|
|
|
10910
10909
|
|
|
10911
10910
|
// packages/compiler-cli/src/ngtsc/annotations/directive/src/handler.js
|
|
10912
10911
|
import { compileClassMetadata, compileDeclareClassMetadata, compileDeclareDirectiveFromMetadata, compileDirectiveFromMetadata, FactoryTarget, makeBindingParser as makeBindingParser2, R3TargetBinder, WrappedNodeExpr as WrappedNodeExpr9 } from "@angular/compiler";
|
|
10913
|
-
import
|
|
10912
|
+
import ts87 from "typescript";
|
|
10914
10913
|
|
|
10915
10914
|
// packages/compiler-cli/src/ngtsc/annotations/directive/src/symbol.js
|
|
10916
10915
|
var DirectiveSymbol = class _DirectiveSymbol extends SemanticSymbol {
|
|
@@ -11271,7 +11270,7 @@ function isSymbolAliasOf(firstSymbol, lastSymbol, typeChecker) {
|
|
|
11271
11270
|
}
|
|
11272
11271
|
|
|
11273
11272
|
// packages/compiler-cli/src/ngtsc/typecheck/src/checker.js
|
|
11274
|
-
import
|
|
11273
|
+
import ts86 from "typescript";
|
|
11275
11274
|
|
|
11276
11275
|
// packages/compiler-cli/src/ngtsc/program_driver/src/api.js
|
|
11277
11276
|
var NgOriginalFile = Symbol("NgOriginalFile");
|
|
@@ -12863,7 +12862,7 @@ var MagicString = class _MagicString {
|
|
|
12863
12862
|
};
|
|
12864
12863
|
|
|
12865
12864
|
// packages/compiler-cli/src/ngtsc/typecheck/src/context.js
|
|
12866
|
-
import
|
|
12865
|
+
import ts84 from "typescript";
|
|
12867
12866
|
|
|
12868
12867
|
// packages/compiler-cli/src/ngtsc/typecheck/src/dom.js
|
|
12869
12868
|
import { DomElementSchemaRegistry } from "@angular/compiler";
|
|
@@ -13994,8 +13993,7 @@ var TypeCheckShimGenerator = class {
|
|
|
13994
13993
|
};
|
|
13995
13994
|
|
|
13996
13995
|
// packages/compiler-cli/src/ngtsc/typecheck/src/type_check_block.js
|
|
13997
|
-
import
|
|
13998
|
-
import ts62 from "typescript";
|
|
13996
|
+
import ts82 from "typescript";
|
|
13999
13997
|
|
|
14000
13998
|
// packages/compiler-cli/src/ngtsc/typecheck/src/diagnostics.js
|
|
14001
13999
|
import { AbsoluteSourceSpan as AbsoluteSourceSpan4 } from "@angular/compiler";
|
|
@@ -14058,11 +14056,86 @@ function translateDiagnostic(diagnostic, resolver) {
|
|
|
14058
14056
|
} : void 0);
|
|
14059
14057
|
}
|
|
14060
14058
|
|
|
14059
|
+
// packages/compiler-cli/src/ngtsc/typecheck/src/ops/context.js
|
|
14060
|
+
import ts61 from "typescript";
|
|
14061
|
+
var TcbGenericContextBehavior;
|
|
14062
|
+
(function(TcbGenericContextBehavior2) {
|
|
14063
|
+
TcbGenericContextBehavior2[TcbGenericContextBehavior2["UseEmitter"] = 0] = "UseEmitter";
|
|
14064
|
+
TcbGenericContextBehavior2[TcbGenericContextBehavior2["CopyClassNodes"] = 1] = "CopyClassNodes";
|
|
14065
|
+
TcbGenericContextBehavior2[TcbGenericContextBehavior2["FallbackToAny"] = 2] = "FallbackToAny";
|
|
14066
|
+
})(TcbGenericContextBehavior || (TcbGenericContextBehavior = {}));
|
|
14067
|
+
var Context2 = class {
|
|
14068
|
+
env;
|
|
14069
|
+
domSchemaChecker;
|
|
14070
|
+
oobRecorder;
|
|
14071
|
+
id;
|
|
14072
|
+
boundTarget;
|
|
14073
|
+
pipes;
|
|
14074
|
+
schemas;
|
|
14075
|
+
hostIsStandalone;
|
|
14076
|
+
hostPreserveWhitespaces;
|
|
14077
|
+
nextId = 1;
|
|
14078
|
+
constructor(env, domSchemaChecker, oobRecorder, id, boundTarget, pipes, schemas, hostIsStandalone, hostPreserveWhitespaces) {
|
|
14079
|
+
this.env = env;
|
|
14080
|
+
this.domSchemaChecker = domSchemaChecker;
|
|
14081
|
+
this.oobRecorder = oobRecorder;
|
|
14082
|
+
this.id = id;
|
|
14083
|
+
this.boundTarget = boundTarget;
|
|
14084
|
+
this.pipes = pipes;
|
|
14085
|
+
this.schemas = schemas;
|
|
14086
|
+
this.hostIsStandalone = hostIsStandalone;
|
|
14087
|
+
this.hostPreserveWhitespaces = hostPreserveWhitespaces;
|
|
14088
|
+
}
|
|
14089
|
+
/**
|
|
14090
|
+
* Allocate a new variable name for use within the `Context`.
|
|
14091
|
+
*
|
|
14092
|
+
* Currently this uses a monotonically increasing counter, but in the future the variable name
|
|
14093
|
+
* might change depending on the type of data being stored.
|
|
14094
|
+
*/
|
|
14095
|
+
allocateId() {
|
|
14096
|
+
return ts61.factory.createIdentifier(`_t${this.nextId++}`);
|
|
14097
|
+
}
|
|
14098
|
+
getPipeByName(name) {
|
|
14099
|
+
if (this.pipes === null || !this.pipes.has(name)) {
|
|
14100
|
+
return null;
|
|
14101
|
+
}
|
|
14102
|
+
return this.pipes.get(name);
|
|
14103
|
+
}
|
|
14104
|
+
};
|
|
14105
|
+
|
|
14106
|
+
// packages/compiler-cli/src/ngtsc/typecheck/src/ops/scope.js
|
|
14107
|
+
import { TmplAstBoundText, TmplAstComponent as TmplAstComponent3, TmplAstContent, TmplAstDeferredBlock, TmplAstDirective as TmplAstDirective2, TmplAstElement as TmplAstElement8, TmplAstForLoopBlock as TmplAstForLoopBlock2, TmplAstHostElement as TmplAstHostElement5, TmplAstIcu, TmplAstIfBlock as TmplAstIfBlock2, TmplAstIfBlockBranch, TmplAstLetDeclaration as TmplAstLetDeclaration3, TmplAstReference as TmplAstReference2, TmplAstSwitchBlock as TmplAstSwitchBlock2, TmplAstTemplate as TmplAstTemplate5, TmplAstText as TmplAstText2, TmplAstVariable as TmplAstVariable2 } from "@angular/compiler";
|
|
14108
|
+
import ts81 from "typescript";
|
|
14109
|
+
|
|
14110
|
+
// packages/compiler-cli/src/ngtsc/typecheck/src/ops/base.js
|
|
14111
|
+
import ts62 from "typescript";
|
|
14112
|
+
var TcbOp = class {
|
|
14113
|
+
/**
|
|
14114
|
+
* Replacement value or operation used while this `TcbOp` is executing (i.e. to resolve circular
|
|
14115
|
+
* references during its execution).
|
|
14116
|
+
*
|
|
14117
|
+
* This is usually a `null!` expression (which asks TS to infer an appropriate type), but another
|
|
14118
|
+
* `TcbOp` can be returned in cases where additional code generation is necessary to deal with
|
|
14119
|
+
* circular references.
|
|
14120
|
+
*/
|
|
14121
|
+
circularFallback() {
|
|
14122
|
+
return ts62.factory.createNonNullExpression(ts62.factory.createNull());
|
|
14123
|
+
}
|
|
14124
|
+
};
|
|
14125
|
+
|
|
14126
|
+
// packages/compiler-cli/src/ngtsc/typecheck/src/ops/template.js
|
|
14127
|
+
import { TmplAstBoundAttribute as TmplAstBoundAttribute3, TmplAstTemplate } from "@angular/compiler";
|
|
14128
|
+
import ts65 from "typescript";
|
|
14129
|
+
|
|
14130
|
+
// packages/compiler-cli/src/ngtsc/typecheck/src/ops/expression.js
|
|
14131
|
+
import { Binary, BindingPipe, Call as Call3, ImplicitReceiver as ImplicitReceiver3, PropertyRead as PropertyRead4, R3Identifiers as R3Identifiers4, SafeCall as SafeCall2, SafePropertyRead as SafePropertyRead3, ThisReceiver as ThisReceiver2, TmplAstLetDeclaration as TmplAstLetDeclaration2 } from "@angular/compiler";
|
|
14132
|
+
import ts64 from "typescript";
|
|
14133
|
+
|
|
14061
14134
|
// packages/compiler-cli/src/ngtsc/typecheck/src/expression.js
|
|
14062
14135
|
import { ASTWithSource, Call as Call2, EmptyExpr as EmptyExpr2, PropertyRead as PropertyRead3, SafeKeyedRead, SafePropertyRead as SafePropertyRead2 } from "@angular/compiler";
|
|
14063
|
-
import
|
|
14136
|
+
import ts63 from "typescript";
|
|
14064
14137
|
function getAnyExpression() {
|
|
14065
|
-
return
|
|
14138
|
+
return ts63.factory.createAsExpression(ts63.factory.createNumericLiteral("0"), ts63.factory.createKeywordTypeNode(ts63.SyntaxKind.AnyKeyword));
|
|
14066
14139
|
}
|
|
14067
14140
|
function astToTypescript(ast, maybeResolve, config) {
|
|
14068
14141
|
const translator = new AstTranslator(maybeResolve, config);
|
|
@@ -14071,43 +14144,43 @@ function astToTypescript(ast, maybeResolve, config) {
|
|
|
14071
14144
|
var AstTranslator = class {
|
|
14072
14145
|
maybeResolve;
|
|
14073
14146
|
config;
|
|
14074
|
-
UNDEFINED =
|
|
14147
|
+
UNDEFINED = ts63.factory.createIdentifier("undefined");
|
|
14075
14148
|
UNARY_OPS = /* @__PURE__ */ new Map([
|
|
14076
|
-
["+",
|
|
14077
|
-
["-",
|
|
14149
|
+
["+", ts63.SyntaxKind.PlusToken],
|
|
14150
|
+
["-", ts63.SyntaxKind.MinusToken]
|
|
14078
14151
|
]);
|
|
14079
14152
|
BINARY_OPS = /* @__PURE__ */ new Map([
|
|
14080
|
-
["+",
|
|
14081
|
-
["-",
|
|
14082
|
-
["<",
|
|
14083
|
-
[">",
|
|
14084
|
-
["<=",
|
|
14085
|
-
[">=",
|
|
14086
|
-
["=",
|
|
14087
|
-
["==",
|
|
14088
|
-
["===",
|
|
14089
|
-
["*",
|
|
14090
|
-
["**",
|
|
14091
|
-
["/",
|
|
14092
|
-
["%",
|
|
14093
|
-
["!=",
|
|
14094
|
-
["!==",
|
|
14095
|
-
["||",
|
|
14096
|
-
["&&",
|
|
14097
|
-
["&",
|
|
14098
|
-
["|",
|
|
14099
|
-
["??",
|
|
14100
|
-
["in",
|
|
14101
|
-
["=",
|
|
14102
|
-
["+=",
|
|
14103
|
-
["-=",
|
|
14104
|
-
["*=",
|
|
14105
|
-
["/=",
|
|
14106
|
-
["%=",
|
|
14107
|
-
["**=",
|
|
14108
|
-
["&&=",
|
|
14109
|
-
["||=",
|
|
14110
|
-
["??=",
|
|
14153
|
+
["+", ts63.SyntaxKind.PlusToken],
|
|
14154
|
+
["-", ts63.SyntaxKind.MinusToken],
|
|
14155
|
+
["<", ts63.SyntaxKind.LessThanToken],
|
|
14156
|
+
[">", ts63.SyntaxKind.GreaterThanToken],
|
|
14157
|
+
["<=", ts63.SyntaxKind.LessThanEqualsToken],
|
|
14158
|
+
[">=", ts63.SyntaxKind.GreaterThanEqualsToken],
|
|
14159
|
+
["=", ts63.SyntaxKind.EqualsToken],
|
|
14160
|
+
["==", ts63.SyntaxKind.EqualsEqualsToken],
|
|
14161
|
+
["===", ts63.SyntaxKind.EqualsEqualsEqualsToken],
|
|
14162
|
+
["*", ts63.SyntaxKind.AsteriskToken],
|
|
14163
|
+
["**", ts63.SyntaxKind.AsteriskAsteriskToken],
|
|
14164
|
+
["/", ts63.SyntaxKind.SlashToken],
|
|
14165
|
+
["%", ts63.SyntaxKind.PercentToken],
|
|
14166
|
+
["!=", ts63.SyntaxKind.ExclamationEqualsToken],
|
|
14167
|
+
["!==", ts63.SyntaxKind.ExclamationEqualsEqualsToken],
|
|
14168
|
+
["||", ts63.SyntaxKind.BarBarToken],
|
|
14169
|
+
["&&", ts63.SyntaxKind.AmpersandAmpersandToken],
|
|
14170
|
+
["&", ts63.SyntaxKind.AmpersandToken],
|
|
14171
|
+
["|", ts63.SyntaxKind.BarToken],
|
|
14172
|
+
["??", ts63.SyntaxKind.QuestionQuestionToken],
|
|
14173
|
+
["in", ts63.SyntaxKind.InKeyword],
|
|
14174
|
+
["=", ts63.SyntaxKind.EqualsToken],
|
|
14175
|
+
["+=", ts63.SyntaxKind.PlusEqualsToken],
|
|
14176
|
+
["-=", ts63.SyntaxKind.MinusEqualsToken],
|
|
14177
|
+
["*=", ts63.SyntaxKind.AsteriskEqualsToken],
|
|
14178
|
+
["/=", ts63.SyntaxKind.SlashEqualsToken],
|
|
14179
|
+
["%=", ts63.SyntaxKind.PercentEqualsToken],
|
|
14180
|
+
["**=", ts63.SyntaxKind.AsteriskAsteriskEqualsToken],
|
|
14181
|
+
["&&=", ts63.SyntaxKind.AmpersandAmpersandEqualsToken],
|
|
14182
|
+
["||=", ts63.SyntaxKind.BarBarEqualsToken],
|
|
14183
|
+
["??=", ts63.SyntaxKind.QuestionQuestionEqualsToken]
|
|
14111
14184
|
]);
|
|
14112
14185
|
constructor(maybeResolve, config) {
|
|
14113
14186
|
this.maybeResolve = maybeResolve;
|
|
@@ -14118,7 +14191,7 @@ var AstTranslator = class {
|
|
|
14118
14191
|
ast = ast.ast;
|
|
14119
14192
|
}
|
|
14120
14193
|
if (ast instanceof EmptyExpr2) {
|
|
14121
|
-
const res =
|
|
14194
|
+
const res = ts63.factory.createIdentifier("undefined");
|
|
14122
14195
|
addParseSpanInfo(res, ast.sourceSpan);
|
|
14123
14196
|
return res;
|
|
14124
14197
|
}
|
|
@@ -14134,7 +14207,7 @@ var AstTranslator = class {
|
|
|
14134
14207
|
if (op === void 0) {
|
|
14135
14208
|
throw new Error(`Unsupported Unary.operator: ${ast.operator}`);
|
|
14136
14209
|
}
|
|
14137
|
-
const node = wrapForDiagnostics(
|
|
14210
|
+
const node = wrapForDiagnostics(ts63.factory.createPrefixUnaryExpression(op, expr));
|
|
14138
14211
|
addParseSpanInfo(node, ast.sourceSpan);
|
|
14139
14212
|
return node;
|
|
14140
14213
|
}
|
|
@@ -14145,13 +14218,13 @@ var AstTranslator = class {
|
|
|
14145
14218
|
if (op === void 0) {
|
|
14146
14219
|
throw new Error(`Unsupported Binary.operation: ${ast.operation}`);
|
|
14147
14220
|
}
|
|
14148
|
-
const node =
|
|
14221
|
+
const node = ts63.factory.createBinaryExpression(lhs, op, rhs);
|
|
14149
14222
|
addParseSpanInfo(node, ast.sourceSpan);
|
|
14150
14223
|
return node;
|
|
14151
14224
|
}
|
|
14152
14225
|
visitChain(ast) {
|
|
14153
14226
|
const elements = ast.expressions.map((expr) => this.translate(expr));
|
|
14154
|
-
const node = wrapForDiagnostics(
|
|
14227
|
+
const node = wrapForDiagnostics(ts63.factory.createCommaListExpression(elements));
|
|
14155
14228
|
addParseSpanInfo(node, ast.sourceSpan);
|
|
14156
14229
|
return node;
|
|
14157
14230
|
}
|
|
@@ -14159,7 +14232,7 @@ var AstTranslator = class {
|
|
|
14159
14232
|
const condExpr = this.translate(ast.condition);
|
|
14160
14233
|
const trueExpr = this.translate(ast.trueExp);
|
|
14161
14234
|
const falseExpr = wrapForTypeChecker(this.translate(ast.falseExp));
|
|
14162
|
-
const node =
|
|
14235
|
+
const node = ts63.factory.createParenthesizedExpression(ts63.factory.createConditionalExpression(condExpr, void 0, trueExpr, void 0, falseExpr));
|
|
14163
14236
|
addParseSpanInfo(node, ast.sourceSpan);
|
|
14164
14237
|
return node;
|
|
14165
14238
|
}
|
|
@@ -14170,21 +14243,21 @@ var AstTranslator = class {
|
|
|
14170
14243
|
throw new Error("Method not implemented.");
|
|
14171
14244
|
}
|
|
14172
14245
|
visitRegularExpressionLiteral(ast, context) {
|
|
14173
|
-
return wrapForTypeChecker(
|
|
14246
|
+
return wrapForTypeChecker(ts63.factory.createRegularExpressionLiteral(`/${ast.body}/${ast.flags ?? ""}`));
|
|
14174
14247
|
}
|
|
14175
14248
|
visitInterpolation(ast) {
|
|
14176
|
-
return ast.expressions.reduce((lhs, ast2) =>
|
|
14249
|
+
return ast.expressions.reduce((lhs, ast2) => ts63.factory.createBinaryExpression(lhs, ts63.SyntaxKind.PlusToken, wrapForTypeChecker(this.translate(ast2))), ts63.factory.createStringLiteral(""));
|
|
14177
14250
|
}
|
|
14178
14251
|
visitKeyedRead(ast) {
|
|
14179
14252
|
const receiver = wrapForDiagnostics(this.translate(ast.receiver));
|
|
14180
14253
|
const key = this.translate(ast.key);
|
|
14181
|
-
const node =
|
|
14254
|
+
const node = ts63.factory.createElementAccessExpression(receiver, key);
|
|
14182
14255
|
addParseSpanInfo(node, ast.sourceSpan);
|
|
14183
14256
|
return node;
|
|
14184
14257
|
}
|
|
14185
14258
|
visitLiteralArray(ast) {
|
|
14186
14259
|
const elements = ast.expressions.map((expr) => this.translate(expr));
|
|
14187
|
-
const literal4 =
|
|
14260
|
+
const literal4 = ts63.factory.createArrayLiteralExpression(elements);
|
|
14188
14261
|
const node = this.config.strictLiteralTypes ? literal4 : tsCastToAny(literal4);
|
|
14189
14262
|
addParseSpanInfo(node, ast.sourceSpan);
|
|
14190
14263
|
return node;
|
|
@@ -14192,9 +14265,9 @@ var AstTranslator = class {
|
|
|
14192
14265
|
visitLiteralMap(ast) {
|
|
14193
14266
|
const properties = ast.keys.map(({ key }, idx) => {
|
|
14194
14267
|
const value = this.translate(ast.values[idx]);
|
|
14195
|
-
return
|
|
14268
|
+
return ts63.factory.createPropertyAssignment(ts63.factory.createStringLiteral(key), value);
|
|
14196
14269
|
});
|
|
14197
|
-
const literal4 =
|
|
14270
|
+
const literal4 = ts63.factory.createObjectLiteralExpression(properties, true);
|
|
14198
14271
|
const node = this.config.strictLiteralTypes ? literal4 : tsCastToAny(literal4);
|
|
14199
14272
|
addParseSpanInfo(node, ast.sourceSpan);
|
|
14200
14273
|
return node;
|
|
@@ -14202,15 +14275,15 @@ var AstTranslator = class {
|
|
|
14202
14275
|
visitLiteralPrimitive(ast) {
|
|
14203
14276
|
let node;
|
|
14204
14277
|
if (ast.value === void 0) {
|
|
14205
|
-
node =
|
|
14278
|
+
node = ts63.factory.createIdentifier("undefined");
|
|
14206
14279
|
} else if (ast.value === null) {
|
|
14207
|
-
node =
|
|
14280
|
+
node = ts63.factory.createNull();
|
|
14208
14281
|
} else if (typeof ast.value === "string") {
|
|
14209
|
-
node =
|
|
14282
|
+
node = ts63.factory.createStringLiteral(ast.value);
|
|
14210
14283
|
} else if (typeof ast.value === "number") {
|
|
14211
14284
|
node = tsNumericExpression2(ast.value);
|
|
14212
14285
|
} else if (typeof ast.value === "boolean") {
|
|
14213
|
-
node = ast.value ?
|
|
14286
|
+
node = ast.value ? ts63.factory.createTrue() : ts63.factory.createFalse();
|
|
14214
14287
|
} else {
|
|
14215
14288
|
throw Error(`Unsupported AST value of type ${typeof ast.value}`);
|
|
14216
14289
|
}
|
|
@@ -14219,7 +14292,7 @@ var AstTranslator = class {
|
|
|
14219
14292
|
}
|
|
14220
14293
|
visitNonNullAssert(ast) {
|
|
14221
14294
|
const expr = wrapForDiagnostics(this.translate(ast.expression));
|
|
14222
|
-
const node =
|
|
14295
|
+
const node = ts63.factory.createNonNullExpression(expr);
|
|
14223
14296
|
addParseSpanInfo(node, ast.sourceSpan);
|
|
14224
14297
|
return node;
|
|
14225
14298
|
}
|
|
@@ -14228,25 +14301,25 @@ var AstTranslator = class {
|
|
|
14228
14301
|
}
|
|
14229
14302
|
visitPrefixNot(ast) {
|
|
14230
14303
|
const expression = wrapForDiagnostics(this.translate(ast.expression));
|
|
14231
|
-
const node =
|
|
14304
|
+
const node = ts63.factory.createLogicalNot(expression);
|
|
14232
14305
|
addParseSpanInfo(node, ast.sourceSpan);
|
|
14233
14306
|
return node;
|
|
14234
14307
|
}
|
|
14235
14308
|
visitTypeofExpression(ast) {
|
|
14236
14309
|
const expression = wrapForDiagnostics(this.translate(ast.expression));
|
|
14237
|
-
const node =
|
|
14310
|
+
const node = ts63.factory.createTypeOfExpression(expression);
|
|
14238
14311
|
addParseSpanInfo(node, ast.sourceSpan);
|
|
14239
14312
|
return node;
|
|
14240
14313
|
}
|
|
14241
14314
|
visitVoidExpression(ast) {
|
|
14242
14315
|
const expression = wrapForDiagnostics(this.translate(ast.expression));
|
|
14243
|
-
const node =
|
|
14316
|
+
const node = ts63.factory.createVoidExpression(expression);
|
|
14244
14317
|
addParseSpanInfo(node, ast.sourceSpan);
|
|
14245
14318
|
return node;
|
|
14246
14319
|
}
|
|
14247
14320
|
visitPropertyRead(ast) {
|
|
14248
14321
|
const receiver = wrapForDiagnostics(this.translate(ast.receiver));
|
|
14249
|
-
const name =
|
|
14322
|
+
const name = ts63.factory.createPropertyAccessExpression(receiver, ast.name);
|
|
14250
14323
|
addParseSpanInfo(name, ast.nameSpan);
|
|
14251
14324
|
const node = wrapForDiagnostics(name);
|
|
14252
14325
|
addParseSpanInfo(node, ast.sourceSpan);
|
|
@@ -14256,13 +14329,13 @@ var AstTranslator = class {
|
|
|
14256
14329
|
let node;
|
|
14257
14330
|
const receiver = wrapForDiagnostics(this.translate(ast.receiver));
|
|
14258
14331
|
if (this.config.strictSafeNavigationTypes) {
|
|
14259
|
-
const expr =
|
|
14332
|
+
const expr = ts63.factory.createPropertyAccessExpression(ts63.factory.createNonNullExpression(receiver), ast.name);
|
|
14260
14333
|
addParseSpanInfo(expr, ast.nameSpan);
|
|
14261
|
-
node =
|
|
14334
|
+
node = ts63.factory.createParenthesizedExpression(ts63.factory.createConditionalExpression(getAnyExpression(), void 0, expr, void 0, this.UNDEFINED));
|
|
14262
14335
|
} else if (VeSafeLhsInferenceBugDetector.veWillInferAnyFor(ast)) {
|
|
14263
|
-
node =
|
|
14336
|
+
node = ts63.factory.createPropertyAccessExpression(tsCastToAny(receiver), ast.name);
|
|
14264
14337
|
} else {
|
|
14265
|
-
const expr =
|
|
14338
|
+
const expr = ts63.factory.createPropertyAccessExpression(ts63.factory.createNonNullExpression(receiver), ast.name);
|
|
14266
14339
|
addParseSpanInfo(expr, ast.nameSpan);
|
|
14267
14340
|
node = tsCastToAny(expr);
|
|
14268
14341
|
}
|
|
@@ -14274,13 +14347,13 @@ var AstTranslator = class {
|
|
|
14274
14347
|
const key = this.translate(ast.key);
|
|
14275
14348
|
let node;
|
|
14276
14349
|
if (this.config.strictSafeNavigationTypes) {
|
|
14277
|
-
const expr =
|
|
14350
|
+
const expr = ts63.factory.createElementAccessExpression(ts63.factory.createNonNullExpression(receiver), key);
|
|
14278
14351
|
addParseSpanInfo(expr, ast.sourceSpan);
|
|
14279
|
-
node =
|
|
14352
|
+
node = ts63.factory.createParenthesizedExpression(ts63.factory.createConditionalExpression(getAnyExpression(), void 0, expr, void 0, this.UNDEFINED));
|
|
14280
14353
|
} else if (VeSafeLhsInferenceBugDetector.veWillInferAnyFor(ast)) {
|
|
14281
|
-
node =
|
|
14354
|
+
node = ts63.factory.createElementAccessExpression(tsCastToAny(receiver), key);
|
|
14282
14355
|
} else {
|
|
14283
|
-
const expr =
|
|
14356
|
+
const expr = ts63.factory.createElementAccessExpression(ts63.factory.createNonNullExpression(receiver), key);
|
|
14284
14357
|
addParseSpanInfo(expr, ast.sourceSpan);
|
|
14285
14358
|
node = tsCastToAny(expr);
|
|
14286
14359
|
}
|
|
@@ -14297,7 +14370,7 @@ var AstTranslator = class {
|
|
|
14297
14370
|
expr = resolved;
|
|
14298
14371
|
} else {
|
|
14299
14372
|
const propertyReceiver = wrapForDiagnostics(this.translate(receiver.receiver));
|
|
14300
|
-
expr =
|
|
14373
|
+
expr = ts63.factory.createPropertyAccessExpression(propertyReceiver, receiver.name);
|
|
14301
14374
|
addParseSpanInfo(expr, receiver.nameSpan);
|
|
14302
14375
|
}
|
|
14303
14376
|
} else {
|
|
@@ -14307,7 +14380,7 @@ var AstTranslator = class {
|
|
|
14307
14380
|
if (ast.receiver instanceof SafePropertyRead2 || ast.receiver instanceof SafeKeyedRead) {
|
|
14308
14381
|
node = this.convertToSafeCall(ast, expr, args);
|
|
14309
14382
|
} else {
|
|
14310
|
-
node =
|
|
14383
|
+
node = ts63.factory.createCallExpression(expr, void 0, args);
|
|
14311
14384
|
}
|
|
14312
14385
|
addParseSpanInfo(node, ast.sourceSpan);
|
|
14313
14386
|
return node;
|
|
@@ -14324,18 +14397,18 @@ var AstTranslator = class {
|
|
|
14324
14397
|
const head = ast.elements[0];
|
|
14325
14398
|
let result;
|
|
14326
14399
|
if (length === 1) {
|
|
14327
|
-
result =
|
|
14400
|
+
result = ts63.factory.createNoSubstitutionTemplateLiteral(head.text);
|
|
14328
14401
|
} else {
|
|
14329
14402
|
const spans = [];
|
|
14330
14403
|
const tailIndex = length - 1;
|
|
14331
14404
|
for (let i = 1; i < tailIndex; i++) {
|
|
14332
|
-
const middle =
|
|
14333
|
-
spans.push(
|
|
14405
|
+
const middle = ts63.factory.createTemplateMiddle(ast.elements[i].text);
|
|
14406
|
+
spans.push(ts63.factory.createTemplateSpan(this.translate(ast.expressions[i - 1]), middle));
|
|
14334
14407
|
}
|
|
14335
14408
|
const resolvedExpression = this.translate(ast.expressions[tailIndex - 1]);
|
|
14336
|
-
const templateTail =
|
|
14337
|
-
spans.push(
|
|
14338
|
-
result =
|
|
14409
|
+
const templateTail = ts63.factory.createTemplateTail(ast.elements[tailIndex].text);
|
|
14410
|
+
spans.push(ts63.factory.createTemplateSpan(resolvedExpression, templateTail));
|
|
14411
|
+
result = ts63.factory.createTemplateExpression(ts63.factory.createTemplateHead(head.text), spans);
|
|
14339
14412
|
}
|
|
14340
14413
|
return result;
|
|
14341
14414
|
}
|
|
@@ -14343,20 +14416,20 @@ var AstTranslator = class {
|
|
|
14343
14416
|
throw new Error("Method not implemented");
|
|
14344
14417
|
}
|
|
14345
14418
|
visitTaggedTemplateLiteral(ast) {
|
|
14346
|
-
return
|
|
14419
|
+
return ts63.factory.createTaggedTemplateExpression(this.translate(ast.tag), void 0, this.visitTemplateLiteral(ast.template));
|
|
14347
14420
|
}
|
|
14348
14421
|
visitParenthesizedExpression(ast) {
|
|
14349
|
-
return
|
|
14422
|
+
return ts63.factory.createParenthesizedExpression(this.translate(ast.expression));
|
|
14350
14423
|
}
|
|
14351
14424
|
convertToSafeCall(ast, expr, args) {
|
|
14352
14425
|
if (this.config.strictSafeNavigationTypes) {
|
|
14353
|
-
const call =
|
|
14354
|
-
return
|
|
14426
|
+
const call = ts63.factory.createCallExpression(ts63.factory.createNonNullExpression(expr), void 0, args);
|
|
14427
|
+
return ts63.factory.createParenthesizedExpression(ts63.factory.createConditionalExpression(getAnyExpression(), void 0, call, void 0, this.UNDEFINED));
|
|
14355
14428
|
}
|
|
14356
14429
|
if (VeSafeLhsInferenceBugDetector.veWillInferAnyFor(ast)) {
|
|
14357
|
-
return
|
|
14430
|
+
return ts63.factory.createCallExpression(tsCastToAny(expr), void 0, args);
|
|
14358
14431
|
}
|
|
14359
|
-
return tsCastToAny(
|
|
14432
|
+
return tsCastToAny(ts63.factory.createCallExpression(ts63.factory.createNonNullExpression(expr), void 0, args));
|
|
14360
14433
|
}
|
|
14361
14434
|
};
|
|
14362
14435
|
var VeSafeLhsInferenceBugDetector = class _VeSafeLhsInferenceBugDetector {
|
|
@@ -14445,207 +14518,174 @@ var VeSafeLhsInferenceBugDetector = class _VeSafeLhsInferenceBugDetector {
|
|
|
14445
14518
|
}
|
|
14446
14519
|
};
|
|
14447
14520
|
|
|
14448
|
-
// packages/compiler-cli/src/ngtsc/typecheck/src/
|
|
14449
|
-
|
|
14450
|
-
(
|
|
14451
|
-
|
|
14452
|
-
TcbGenericContextBehavior2[TcbGenericContextBehavior2["CopyClassNodes"] = 1] = "CopyClassNodes";
|
|
14453
|
-
TcbGenericContextBehavior2[TcbGenericContextBehavior2["FallbackToAny"] = 2] = "FallbackToAny";
|
|
14454
|
-
})(TcbGenericContextBehavior || (TcbGenericContextBehavior = {}));
|
|
14455
|
-
function generateTypeCheckBlock(env, ref, name, meta, domSchemaChecker, oobRecorder, genericContextBehavior) {
|
|
14456
|
-
const tcb = new Context2(env, domSchemaChecker, oobRecorder, meta.id, meta.boundTarget, meta.pipes, meta.schemas, meta.isStandalone, meta.preserveWhitespaces);
|
|
14457
|
-
const ctxRawType = env.referenceType(ref);
|
|
14458
|
-
if (!ts62.isTypeReferenceNode(ctxRawType)) {
|
|
14459
|
-
throw new Error(`Expected TypeReferenceNode when referencing the ctx param for ${ref.debugName}`);
|
|
14460
|
-
}
|
|
14461
|
-
let typeParameters = void 0;
|
|
14462
|
-
let typeArguments = void 0;
|
|
14463
|
-
if (ref.node.typeParameters !== void 0) {
|
|
14464
|
-
if (!env.config.useContextGenericType) {
|
|
14465
|
-
genericContextBehavior = TcbGenericContextBehavior.FallbackToAny;
|
|
14466
|
-
}
|
|
14467
|
-
switch (genericContextBehavior) {
|
|
14468
|
-
case TcbGenericContextBehavior.UseEmitter:
|
|
14469
|
-
typeParameters = new TypeParameterEmitter(ref.node.typeParameters, env.reflector).emit((typeRef) => env.referenceType(typeRef));
|
|
14470
|
-
typeArguments = typeParameters.map((param) => ts62.factory.createTypeReferenceNode(param.name));
|
|
14471
|
-
break;
|
|
14472
|
-
case TcbGenericContextBehavior.CopyClassNodes:
|
|
14473
|
-
typeParameters = [...ref.node.typeParameters];
|
|
14474
|
-
typeArguments = typeParameters.map((param) => ts62.factory.createTypeReferenceNode(param.name));
|
|
14475
|
-
break;
|
|
14476
|
-
case TcbGenericContextBehavior.FallbackToAny:
|
|
14477
|
-
typeArguments = ref.node.typeParameters.map(() => ts62.factory.createKeywordTypeNode(ts62.SyntaxKind.AnyKeyword));
|
|
14478
|
-
break;
|
|
14479
|
-
}
|
|
14480
|
-
}
|
|
14481
|
-
const paramList = [tcbThisParam(ctxRawType.typeName, typeArguments)];
|
|
14482
|
-
const statements = [];
|
|
14483
|
-
if (tcb.boundTarget.target.template !== void 0) {
|
|
14484
|
-
const templateScope = Scope.forNodes(
|
|
14485
|
-
tcb,
|
|
14486
|
-
null,
|
|
14487
|
-
null,
|
|
14488
|
-
tcb.boundTarget.target.template,
|
|
14489
|
-
/* guard */
|
|
14490
|
-
null
|
|
14491
|
-
);
|
|
14492
|
-
statements.push(renderBlockStatements(env, templateScope, ts62.factory.createTrue()));
|
|
14493
|
-
}
|
|
14494
|
-
if (tcb.boundTarget.target.host !== void 0) {
|
|
14495
|
-
const hostScope = Scope.forNodes(tcb, null, tcb.boundTarget.target.host.node, null, null);
|
|
14496
|
-
statements.push(renderBlockStatements(env, hostScope, createHostBindingsBlockGuard()));
|
|
14497
|
-
}
|
|
14498
|
-
const body = ts62.factory.createBlock(statements);
|
|
14499
|
-
const fnDecl = ts62.factory.createFunctionDeclaration(
|
|
14500
|
-
/* modifiers */
|
|
14501
|
-
void 0,
|
|
14502
|
-
/* asteriskToken */
|
|
14503
|
-
void 0,
|
|
14504
|
-
/* name */
|
|
14505
|
-
name,
|
|
14506
|
-
/* typeParameters */
|
|
14507
|
-
env.config.useContextGenericType ? typeParameters : void 0,
|
|
14508
|
-
/* parameters */
|
|
14509
|
-
paramList,
|
|
14510
|
-
/* type */
|
|
14511
|
-
void 0,
|
|
14512
|
-
/* body */
|
|
14513
|
-
body
|
|
14514
|
-
);
|
|
14515
|
-
addTypeCheckId(fnDecl, meta.id);
|
|
14516
|
-
return fnDecl;
|
|
14521
|
+
// packages/compiler-cli/src/ngtsc/typecheck/src/ops/expression.js
|
|
14522
|
+
function tcbExpression(ast, tcb, scope) {
|
|
14523
|
+
const translator = new TcbExpressionTranslator(tcb, scope);
|
|
14524
|
+
return translator.translate(ast);
|
|
14517
14525
|
}
|
|
14518
|
-
function
|
|
14519
|
-
const
|
|
14520
|
-
|
|
14521
|
-
return ts62.factory.createIfStatement(wrapperExpression, innerBody);
|
|
14526
|
+
function unwrapWritableSignal(expression, tcb) {
|
|
14527
|
+
const unwrapRef = tcb.env.referenceExternalSymbol(R3Identifiers4.unwrapWritableSignal.moduleName, R3Identifiers4.unwrapWritableSignal.name);
|
|
14528
|
+
return ts64.factory.createCallExpression(unwrapRef, void 0, [expression]);
|
|
14522
14529
|
}
|
|
14523
|
-
var
|
|
14524
|
-
/**
|
|
14525
|
-
* Replacement value or operation used while this `TcbOp` is executing (i.e. to resolve circular
|
|
14526
|
-
* references during its execution).
|
|
14527
|
-
*
|
|
14528
|
-
* This is usually a `null!` expression (which asks TS to infer an appropriate type), but another
|
|
14529
|
-
* `TcbOp` can be returned in cases where additional code generation is necessary to deal with
|
|
14530
|
-
* circular references.
|
|
14531
|
-
*/
|
|
14532
|
-
circularFallback() {
|
|
14533
|
-
return ts62.factory.createNonNullExpression(ts62.factory.createNull());
|
|
14534
|
-
}
|
|
14535
|
-
};
|
|
14536
|
-
var TcbElementOp = class extends TcbOp {
|
|
14537
|
-
tcb;
|
|
14538
|
-
scope;
|
|
14539
|
-
element;
|
|
14540
|
-
constructor(tcb, scope, element) {
|
|
14541
|
-
super();
|
|
14542
|
-
this.tcb = tcb;
|
|
14543
|
-
this.scope = scope;
|
|
14544
|
-
this.element = element;
|
|
14545
|
-
}
|
|
14546
|
-
get optional() {
|
|
14547
|
-
return true;
|
|
14548
|
-
}
|
|
14549
|
-
execute() {
|
|
14550
|
-
const id = this.tcb.allocateId();
|
|
14551
|
-
const initializer = tsCreateElement(this.element.name);
|
|
14552
|
-
addParseSpanInfo(initializer, this.element.startSourceSpan || this.element.sourceSpan);
|
|
14553
|
-
this.scope.addStatement(tsCreateVariable(id, initializer));
|
|
14554
|
-
return id;
|
|
14555
|
-
}
|
|
14556
|
-
};
|
|
14557
|
-
var TcbTemplateVariableOp = class extends TcbOp {
|
|
14530
|
+
var TcbExpressionOp = class extends TcbOp {
|
|
14558
14531
|
tcb;
|
|
14559
14532
|
scope;
|
|
14560
|
-
|
|
14561
|
-
|
|
14562
|
-
constructor(tcb, scope, template, variable) {
|
|
14533
|
+
expression;
|
|
14534
|
+
constructor(tcb, scope, expression) {
|
|
14563
14535
|
super();
|
|
14564
14536
|
this.tcb = tcb;
|
|
14565
14537
|
this.scope = scope;
|
|
14566
|
-
this.
|
|
14567
|
-
this.variable = variable;
|
|
14538
|
+
this.expression = expression;
|
|
14568
14539
|
}
|
|
14569
14540
|
get optional() {
|
|
14570
14541
|
return false;
|
|
14571
14542
|
}
|
|
14572
14543
|
execute() {
|
|
14573
|
-
const
|
|
14574
|
-
|
|
14575
|
-
|
|
14576
|
-
/* expression */
|
|
14577
|
-
ctx,
|
|
14578
|
-
/* name */
|
|
14579
|
-
this.variable.value || "$implicit"
|
|
14580
|
-
);
|
|
14581
|
-
addParseSpanInfo(id, this.variable.keySpan);
|
|
14582
|
-
let variable;
|
|
14583
|
-
if (this.variable.valueSpan !== void 0) {
|
|
14584
|
-
addParseSpanInfo(initializer, this.variable.valueSpan);
|
|
14585
|
-
variable = tsCreateVariable(id, wrapForTypeChecker(initializer));
|
|
14586
|
-
} else {
|
|
14587
|
-
variable = tsCreateVariable(id, initializer);
|
|
14588
|
-
}
|
|
14589
|
-
addParseSpanInfo(variable.declarationList.declarations[0], this.variable.sourceSpan);
|
|
14590
|
-
this.scope.addStatement(variable);
|
|
14591
|
-
return id;
|
|
14544
|
+
const expr = tcbExpression(this.expression, this.tcb, this.scope);
|
|
14545
|
+
this.scope.addStatement(ts64.factory.createExpressionStatement(expr));
|
|
14546
|
+
return null;
|
|
14592
14547
|
}
|
|
14593
14548
|
};
|
|
14594
|
-
var
|
|
14549
|
+
var TcbExpressionTranslator = class {
|
|
14595
14550
|
tcb;
|
|
14596
14551
|
scope;
|
|
14597
14552
|
constructor(tcb, scope) {
|
|
14598
|
-
super();
|
|
14599
14553
|
this.tcb = tcb;
|
|
14600
14554
|
this.scope = scope;
|
|
14601
14555
|
}
|
|
14602
|
-
|
|
14603
|
-
|
|
14604
|
-
execute() {
|
|
14605
|
-
const ctx = this.tcb.allocateId();
|
|
14606
|
-
const type = ts62.factory.createKeywordTypeNode(ts62.SyntaxKind.AnyKeyword);
|
|
14607
|
-
this.scope.addStatement(tsDeclareVariable(ctx, type));
|
|
14608
|
-
return ctx;
|
|
14609
|
-
}
|
|
14610
|
-
};
|
|
14611
|
-
var TcbLetDeclarationOp = class extends TcbOp {
|
|
14612
|
-
tcb;
|
|
14613
|
-
scope;
|
|
14614
|
-
node;
|
|
14615
|
-
constructor(tcb, scope, node) {
|
|
14616
|
-
super();
|
|
14617
|
-
this.tcb = tcb;
|
|
14618
|
-
this.scope = scope;
|
|
14619
|
-
this.node = node;
|
|
14556
|
+
translate(ast) {
|
|
14557
|
+
return astToTypescript(ast, (ast2) => this.resolve(ast2), this.tcb.env.config);
|
|
14620
14558
|
}
|
|
14621
14559
|
/**
|
|
14622
|
-
*
|
|
14623
|
-
*
|
|
14560
|
+
* Resolve an `AST` expression within the given scope.
|
|
14561
|
+
*
|
|
14562
|
+
* Some `AST` expressions refer to top-level concepts (references, variables, the component
|
|
14563
|
+
* context). This method assists in resolving those.
|
|
14624
14564
|
*/
|
|
14625
|
-
|
|
14626
|
-
|
|
14627
|
-
|
|
14628
|
-
|
|
14629
|
-
|
|
14630
|
-
|
|
14631
|
-
|
|
14632
|
-
|
|
14633
|
-
|
|
14634
|
-
|
|
14635
|
-
|
|
14636
|
-
|
|
14637
|
-
|
|
14638
|
-
|
|
14639
|
-
|
|
14640
|
-
|
|
14641
|
-
|
|
14642
|
-
|
|
14643
|
-
|
|
14644
|
-
|
|
14645
|
-
|
|
14646
|
-
|
|
14647
|
-
|
|
14648
|
-
|
|
14565
|
+
resolve(ast) {
|
|
14566
|
+
if (ast instanceof PropertyRead4 && ast.receiver instanceof ImplicitReceiver3 && !(ast.receiver instanceof ThisReceiver2)) {
|
|
14567
|
+
const target = this.tcb.boundTarget.getExpressionTarget(ast);
|
|
14568
|
+
const targetExpression = target === null ? null : this.getTargetNodeExpression(target, ast);
|
|
14569
|
+
if (target instanceof TmplAstLetDeclaration2 && !this.isValidLetDeclarationAccess(target, ast)) {
|
|
14570
|
+
this.tcb.oobRecorder.letUsedBeforeDefinition(this.tcb.id, ast, target);
|
|
14571
|
+
if (targetExpression !== null) {
|
|
14572
|
+
return ts64.factory.createAsExpression(targetExpression, ts64.factory.createKeywordTypeNode(ts64.SyntaxKind.AnyKeyword));
|
|
14573
|
+
}
|
|
14574
|
+
}
|
|
14575
|
+
return targetExpression;
|
|
14576
|
+
} else if (ast instanceof Binary && Binary.isAssignmentOperation(ast.operation) && ast.left instanceof PropertyRead4 && ast.left.receiver instanceof ImplicitReceiver3) {
|
|
14577
|
+
const read = ast.left;
|
|
14578
|
+
const target = this.tcb.boundTarget.getExpressionTarget(read);
|
|
14579
|
+
if (target === null) {
|
|
14580
|
+
return null;
|
|
14581
|
+
}
|
|
14582
|
+
const targetExpression = this.getTargetNodeExpression(target, read);
|
|
14583
|
+
const expr = this.translate(ast.right);
|
|
14584
|
+
const result = ts64.factory.createParenthesizedExpression(ts64.factory.createBinaryExpression(targetExpression, ts64.SyntaxKind.EqualsToken, expr));
|
|
14585
|
+
addParseSpanInfo(result, read.sourceSpan);
|
|
14586
|
+
if (target instanceof TmplAstLetDeclaration2) {
|
|
14587
|
+
markIgnoreDiagnostics(result);
|
|
14588
|
+
this.tcb.oobRecorder.illegalWriteToLetDeclaration(this.tcb.id, read, target);
|
|
14589
|
+
}
|
|
14590
|
+
return result;
|
|
14591
|
+
} else if (ast instanceof ImplicitReceiver3) {
|
|
14592
|
+
return ts64.factory.createThis();
|
|
14593
|
+
} else if (ast instanceof BindingPipe) {
|
|
14594
|
+
const expr = this.translate(ast.exp);
|
|
14595
|
+
const pipeMeta = this.tcb.getPipeByName(ast.name);
|
|
14596
|
+
let pipe;
|
|
14597
|
+
if (pipeMeta === null) {
|
|
14598
|
+
this.tcb.oobRecorder.missingPipe(this.tcb.id, ast, this.tcb.hostIsStandalone);
|
|
14599
|
+
pipe = getAnyExpression();
|
|
14600
|
+
} else if (pipeMeta.isExplicitlyDeferred && this.tcb.boundTarget.getEagerlyUsedPipes().includes(ast.name)) {
|
|
14601
|
+
this.tcb.oobRecorder.deferredPipeUsedEagerly(this.tcb.id, ast);
|
|
14602
|
+
pipe = getAnyExpression();
|
|
14603
|
+
} else {
|
|
14604
|
+
pipe = this.tcb.env.pipeInst(pipeMeta.ref);
|
|
14605
|
+
}
|
|
14606
|
+
const args = ast.args.map((arg) => this.translate(arg));
|
|
14607
|
+
let methodAccess = ts64.factory.createPropertyAccessExpression(pipe, "transform");
|
|
14608
|
+
addParseSpanInfo(methodAccess, ast.nameSpan);
|
|
14609
|
+
if (!this.tcb.env.config.checkTypeOfPipes) {
|
|
14610
|
+
methodAccess = ts64.factory.createAsExpression(methodAccess, ts64.factory.createKeywordTypeNode(ts64.SyntaxKind.AnyKeyword));
|
|
14611
|
+
}
|
|
14612
|
+
const result = ts64.factory.createCallExpression(
|
|
14613
|
+
/* expression */
|
|
14614
|
+
methodAccess,
|
|
14615
|
+
/* typeArguments */
|
|
14616
|
+
void 0,
|
|
14617
|
+
/* argumentsArray */
|
|
14618
|
+
[expr, ...args]
|
|
14619
|
+
);
|
|
14620
|
+
addParseSpanInfo(result, ast.sourceSpan);
|
|
14621
|
+
return result;
|
|
14622
|
+
} else if ((ast instanceof Call3 || ast instanceof SafeCall2) && (ast.receiver instanceof PropertyRead4 || ast.receiver instanceof SafePropertyRead3)) {
|
|
14623
|
+
if (ast.receiver.receiver instanceof ImplicitReceiver3 && !(ast.receiver.receiver instanceof ThisReceiver2) && ast.receiver.name === "$any" && ast.args.length === 1) {
|
|
14624
|
+
const expr = this.translate(ast.args[0]);
|
|
14625
|
+
const exprAsAny = ts64.factory.createAsExpression(expr, ts64.factory.createKeywordTypeNode(ts64.SyntaxKind.AnyKeyword));
|
|
14626
|
+
const result = ts64.factory.createParenthesizedExpression(exprAsAny);
|
|
14627
|
+
addParseSpanInfo(result, ast.sourceSpan);
|
|
14628
|
+
return result;
|
|
14629
|
+
}
|
|
14630
|
+
const target = this.tcb.boundTarget.getExpressionTarget(ast);
|
|
14631
|
+
if (target === null) {
|
|
14632
|
+
return null;
|
|
14633
|
+
}
|
|
14634
|
+
const receiver = this.getTargetNodeExpression(target, ast);
|
|
14635
|
+
const method = wrapForDiagnostics(receiver);
|
|
14636
|
+
addParseSpanInfo(method, ast.receiver.nameSpan);
|
|
14637
|
+
const args = ast.args.map((arg) => this.translate(arg));
|
|
14638
|
+
const node = ts64.factory.createCallExpression(method, void 0, args);
|
|
14639
|
+
addParseSpanInfo(node, ast.sourceSpan);
|
|
14640
|
+
return node;
|
|
14641
|
+
} else {
|
|
14642
|
+
return null;
|
|
14643
|
+
}
|
|
14644
|
+
}
|
|
14645
|
+
getTargetNodeExpression(targetNode, expressionNode) {
|
|
14646
|
+
const expr = this.scope.resolve(targetNode);
|
|
14647
|
+
addParseSpanInfo(expr, expressionNode.sourceSpan);
|
|
14648
|
+
return expr;
|
|
14649
|
+
}
|
|
14650
|
+
isValidLetDeclarationAccess(target, ast) {
|
|
14651
|
+
const targetStart = target.sourceSpan.start.offset;
|
|
14652
|
+
const targetEnd = target.sourceSpan.end.offset;
|
|
14653
|
+
const astStart = ast.sourceSpan.start;
|
|
14654
|
+
return targetStart < astStart && astStart > targetEnd || !this.scope.isLocal(target);
|
|
14655
|
+
}
|
|
14656
|
+
};
|
|
14657
|
+
|
|
14658
|
+
// packages/compiler-cli/src/ngtsc/typecheck/src/ops/template.js
|
|
14659
|
+
var TcbTemplateContextOp = class extends TcbOp {
|
|
14660
|
+
tcb;
|
|
14661
|
+
scope;
|
|
14662
|
+
constructor(tcb, scope) {
|
|
14663
|
+
super();
|
|
14664
|
+
this.tcb = tcb;
|
|
14665
|
+
this.scope = scope;
|
|
14666
|
+
}
|
|
14667
|
+
// The declaration of the context variable is only needed when the context is actually referenced.
|
|
14668
|
+
optional = true;
|
|
14669
|
+
execute() {
|
|
14670
|
+
const ctx = this.tcb.allocateId();
|
|
14671
|
+
const type = ts65.factory.createKeywordTypeNode(ts65.SyntaxKind.AnyKeyword);
|
|
14672
|
+
this.scope.addStatement(tsDeclareVariable(ctx, type));
|
|
14673
|
+
return ctx;
|
|
14674
|
+
}
|
|
14675
|
+
};
|
|
14676
|
+
var TcbTemplateBodyOp = class extends TcbOp {
|
|
14677
|
+
tcb;
|
|
14678
|
+
scope;
|
|
14679
|
+
template;
|
|
14680
|
+
constructor(tcb, scope, template) {
|
|
14681
|
+
super();
|
|
14682
|
+
this.tcb = tcb;
|
|
14683
|
+
this.scope = scope;
|
|
14684
|
+
this.template = template;
|
|
14685
|
+
}
|
|
14686
|
+
get optional() {
|
|
14687
|
+
return false;
|
|
14688
|
+
}
|
|
14649
14689
|
execute() {
|
|
14650
14690
|
let guard = null;
|
|
14651
14691
|
const directiveGuards = [];
|
|
@@ -14654,16 +14694,16 @@ var TcbTemplateBodyOp = class extends TcbOp {
|
|
|
14654
14694
|
this.addDirectiveGuards(directiveGuards, directive, this.tcb.boundTarget.getDirectivesOfNode(directive));
|
|
14655
14695
|
}
|
|
14656
14696
|
if (directiveGuards.length > 0) {
|
|
14657
|
-
guard = directiveGuards.reduce((expr, dirGuard) =>
|
|
14697
|
+
guard = directiveGuards.reduce((expr, dirGuard) => ts65.factory.createBinaryExpression(expr, ts65.SyntaxKind.AmpersandAmpersandToken, dirGuard), directiveGuards.pop());
|
|
14658
14698
|
}
|
|
14659
|
-
const tmplScope =
|
|
14699
|
+
const tmplScope = this.scope.createChildScope(this.scope, this.template, this.template.children, guard);
|
|
14660
14700
|
const statements = tmplScope.render();
|
|
14661
14701
|
if (statements.length === 0) {
|
|
14662
14702
|
return null;
|
|
14663
14703
|
}
|
|
14664
|
-
let tmplBlock =
|
|
14704
|
+
let tmplBlock = ts65.factory.createBlock(statements);
|
|
14665
14705
|
if (guard !== null) {
|
|
14666
|
-
tmplBlock =
|
|
14706
|
+
tmplBlock = ts65.factory.createIfStatement(
|
|
14667
14707
|
/* expression */
|
|
14668
14708
|
guard,
|
|
14669
14709
|
/* thenStatement */
|
|
@@ -14714,250 +14754,138 @@ var TcbTemplateBodyOp = class extends TcbOp {
|
|
|
14714
14754
|
}
|
|
14715
14755
|
}
|
|
14716
14756
|
};
|
|
14717
|
-
|
|
14757
|
+
|
|
14758
|
+
// packages/compiler-cli/src/ngtsc/typecheck/src/ops/element.js
|
|
14759
|
+
var TcbElementOp = class extends TcbOp {
|
|
14718
14760
|
tcb;
|
|
14719
14761
|
scope;
|
|
14720
|
-
|
|
14721
|
-
constructor(tcb, scope,
|
|
14762
|
+
element;
|
|
14763
|
+
constructor(tcb, scope, element) {
|
|
14722
14764
|
super();
|
|
14723
14765
|
this.tcb = tcb;
|
|
14724
14766
|
this.scope = scope;
|
|
14725
|
-
this.
|
|
14767
|
+
this.element = element;
|
|
14726
14768
|
}
|
|
14727
14769
|
get optional() {
|
|
14728
|
-
return
|
|
14770
|
+
return true;
|
|
14729
14771
|
}
|
|
14730
14772
|
execute() {
|
|
14731
|
-
const
|
|
14732
|
-
this.
|
|
14733
|
-
|
|
14773
|
+
const id = this.tcb.allocateId();
|
|
14774
|
+
const initializer = tsCreateElement(this.element.name);
|
|
14775
|
+
addParseSpanInfo(initializer, this.element.startSourceSpan || this.element.sourceSpan);
|
|
14776
|
+
this.scope.addStatement(tsCreateVariable(id, initializer));
|
|
14777
|
+
return id;
|
|
14734
14778
|
}
|
|
14735
14779
|
};
|
|
14736
|
-
|
|
14780
|
+
|
|
14781
|
+
// packages/compiler-cli/src/ngtsc/typecheck/src/ops/variables.js
|
|
14782
|
+
import ts66 from "typescript";
|
|
14783
|
+
var TcbBlockImplicitVariableOp = class extends TcbOp {
|
|
14737
14784
|
tcb;
|
|
14738
14785
|
scope;
|
|
14739
|
-
|
|
14740
|
-
|
|
14741
|
-
constructor(tcb, scope,
|
|
14786
|
+
type;
|
|
14787
|
+
variable;
|
|
14788
|
+
constructor(tcb, scope, type, variable) {
|
|
14742
14789
|
super();
|
|
14743
14790
|
this.tcb = tcb;
|
|
14744
14791
|
this.scope = scope;
|
|
14745
|
-
this.
|
|
14746
|
-
this.
|
|
14747
|
-
}
|
|
14748
|
-
get optional() {
|
|
14749
|
-
return true;
|
|
14792
|
+
this.type = type;
|
|
14793
|
+
this.variable = variable;
|
|
14750
14794
|
}
|
|
14795
|
+
optional = true;
|
|
14751
14796
|
execute() {
|
|
14752
|
-
const dirRef = this.dir.ref;
|
|
14753
|
-
const rawType = this.tcb.env.referenceType(this.dir.ref);
|
|
14754
|
-
let type;
|
|
14755
|
-
let span;
|
|
14756
|
-
if (this.dir.isGeneric === false || dirRef.node.typeParameters === void 0) {
|
|
14757
|
-
type = rawType;
|
|
14758
|
-
} else {
|
|
14759
|
-
if (!ts62.isTypeReferenceNode(rawType)) {
|
|
14760
|
-
throw new Error(`Expected TypeReferenceNode when referencing the type for ${this.dir.ref.debugName}`);
|
|
14761
|
-
}
|
|
14762
|
-
const typeArguments = dirRef.node.typeParameters.map(() => ts62.factory.createKeywordTypeNode(ts62.SyntaxKind.AnyKeyword));
|
|
14763
|
-
type = ts62.factory.createTypeReferenceNode(rawType.typeName, typeArguments);
|
|
14764
|
-
}
|
|
14765
|
-
if (this.node instanceof TmplAstHostElement2) {
|
|
14766
|
-
span = this.node.sourceSpan;
|
|
14767
|
-
} else {
|
|
14768
|
-
span = this.node.startSourceSpan || this.node.sourceSpan;
|
|
14769
|
-
}
|
|
14770
14797
|
const id = this.tcb.allocateId();
|
|
14771
|
-
|
|
14772
|
-
|
|
14773
|
-
|
|
14798
|
+
addParseSpanInfo(id, this.variable.keySpan);
|
|
14799
|
+
const variable = tsDeclareVariable(id, this.type);
|
|
14800
|
+
addParseSpanInfo(variable.declarationList.declarations[0], this.variable.sourceSpan);
|
|
14801
|
+
this.scope.addStatement(variable);
|
|
14774
14802
|
return id;
|
|
14775
14803
|
}
|
|
14776
14804
|
};
|
|
14777
|
-
var
|
|
14778
|
-
|
|
14779
|
-
|
|
14780
|
-
|
|
14781
|
-
|
|
14782
|
-
|
|
14783
|
-
|
|
14784
|
-
|
|
14785
|
-
|
|
14786
|
-
|
|
14787
|
-
|
|
14805
|
+
var TcbTemplateVariableOp = class extends TcbOp {
|
|
14806
|
+
tcb;
|
|
14807
|
+
scope;
|
|
14808
|
+
template;
|
|
14809
|
+
variable;
|
|
14810
|
+
constructor(tcb, scope, template, variable) {
|
|
14811
|
+
super();
|
|
14812
|
+
this.tcb = tcb;
|
|
14813
|
+
this.scope = scope;
|
|
14814
|
+
this.template = template;
|
|
14815
|
+
this.variable = variable;
|
|
14816
|
+
}
|
|
14817
|
+
get optional() {
|
|
14818
|
+
return false;
|
|
14788
14819
|
}
|
|
14789
|
-
};
|
|
14790
|
-
var TcbGenericDirectiveTypeWithAnyParamsOp = class extends TcbDirectiveTypeOpBase {
|
|
14791
14820
|
execute() {
|
|
14792
|
-
const
|
|
14793
|
-
|
|
14794
|
-
|
|
14821
|
+
const ctx = this.scope.resolve(this.template);
|
|
14822
|
+
const id = this.tcb.allocateId();
|
|
14823
|
+
const initializer = ts66.factory.createPropertyAccessExpression(
|
|
14824
|
+
/* expression */
|
|
14825
|
+
ctx,
|
|
14826
|
+
/* name */
|
|
14827
|
+
this.variable.value || "$implicit"
|
|
14828
|
+
);
|
|
14829
|
+
addParseSpanInfo(id, this.variable.keySpan);
|
|
14830
|
+
let variable;
|
|
14831
|
+
if (this.variable.valueSpan !== void 0) {
|
|
14832
|
+
addParseSpanInfo(initializer, this.variable.valueSpan);
|
|
14833
|
+
variable = tsCreateVariable(id, wrapForTypeChecker(initializer));
|
|
14834
|
+
} else {
|
|
14835
|
+
variable = tsCreateVariable(id, initializer);
|
|
14795
14836
|
}
|
|
14796
|
-
|
|
14837
|
+
addParseSpanInfo(variable.declarationList.declarations[0], this.variable.sourceSpan);
|
|
14838
|
+
this.scope.addStatement(variable);
|
|
14839
|
+
return id;
|
|
14797
14840
|
}
|
|
14798
14841
|
};
|
|
14799
|
-
var
|
|
14842
|
+
var TcbBlockVariableOp = class extends TcbOp {
|
|
14800
14843
|
tcb;
|
|
14801
14844
|
scope;
|
|
14802
|
-
|
|
14803
|
-
|
|
14804
|
-
|
|
14805
|
-
unsupportedBindingFields;
|
|
14806
|
-
constructor(tcb, scope, node, dir) {
|
|
14845
|
+
initializer;
|
|
14846
|
+
variable;
|
|
14847
|
+
constructor(tcb, scope, initializer, variable) {
|
|
14807
14848
|
super();
|
|
14808
14849
|
this.tcb = tcb;
|
|
14809
14850
|
this.scope = scope;
|
|
14810
|
-
this.
|
|
14811
|
-
this.
|
|
14812
|
-
const commonUnsupportedNames = [
|
|
14813
|
-
"value",
|
|
14814
|
-
"checked",
|
|
14815
|
-
"errors",
|
|
14816
|
-
"invalid",
|
|
14817
|
-
"disabled",
|
|
14818
|
-
"disabledReasons",
|
|
14819
|
-
"name",
|
|
14820
|
-
"readonly",
|
|
14821
|
-
"touched",
|
|
14822
|
-
"max",
|
|
14823
|
-
"maxlength",
|
|
14824
|
-
"maxLength",
|
|
14825
|
-
"min",
|
|
14826
|
-
"minLength",
|
|
14827
|
-
"minlength",
|
|
14828
|
-
"pattern",
|
|
14829
|
-
"required",
|
|
14830
|
-
"type"
|
|
14831
|
-
];
|
|
14832
|
-
this.unsupportedBindingFields = new Set(commonUnsupportedNames);
|
|
14851
|
+
this.initializer = initializer;
|
|
14852
|
+
this.variable = variable;
|
|
14833
14853
|
}
|
|
14834
14854
|
get optional() {
|
|
14835
|
-
return
|
|
14855
|
+
return false;
|
|
14836
14856
|
}
|
|
14837
14857
|
execute() {
|
|
14838
|
-
const inputs = this.node instanceof TmplAstHostElement2 ? this.node.bindings : this.node.inputs;
|
|
14839
|
-
for (const input of inputs) {
|
|
14840
|
-
if (input.type === BindingType3.Property && this.unsupportedBindingFields.has(input.name)) {
|
|
14841
|
-
this.tcb.oobRecorder.formFieldUnsupportedBinding(this.tcb.id, input);
|
|
14842
|
-
} else if (input.type === BindingType3.Attribute && this.unsupportedBindingFields.has(input.name.toLowerCase())) {
|
|
14843
|
-
this.tcb.oobRecorder.formFieldUnsupportedBinding(this.tcb.id, input);
|
|
14844
|
-
}
|
|
14845
|
-
}
|
|
14846
|
-
if (!(this.node instanceof TmplAstHostElement2)) {
|
|
14847
|
-
for (const attr of this.node.attributes) {
|
|
14848
|
-
const name = attr.name.toLowerCase();
|
|
14849
|
-
if (name !== "type" && this.unsupportedBindingFields.has(name)) {
|
|
14850
|
-
this.tcb.oobRecorder.formFieldUnsupportedBinding(this.tcb.id, attr);
|
|
14851
|
-
}
|
|
14852
|
-
}
|
|
14853
|
-
}
|
|
14854
|
-
const refType = this.tcb.env.referenceType(this.dir.ref);
|
|
14855
|
-
if (!ts62.isTypeReferenceNode(refType)) {
|
|
14856
|
-
throw new Error(`Expected TypeReferenceNode when referencing the type for ${this.dir.ref.debugName}`);
|
|
14857
|
-
}
|
|
14858
|
-
const span = this.node instanceof TmplAstHostElement2 ? this.node.sourceSpan : this.node.startSourceSpan || this.node.sourceSpan;
|
|
14859
|
-
const type = ts62.factory.createTypeReferenceNode(refType.typeName, [this.getExpectedType()]);
|
|
14860
14858
|
const id = this.tcb.allocateId();
|
|
14861
|
-
|
|
14862
|
-
|
|
14863
|
-
|
|
14859
|
+
addParseSpanInfo(id, this.variable.keySpan);
|
|
14860
|
+
const variable = tsCreateVariable(id, wrapForTypeChecker(this.initializer));
|
|
14861
|
+
addParseSpanInfo(variable.declarationList.declarations[0], this.variable.sourceSpan);
|
|
14862
|
+
this.scope.addStatement(variable);
|
|
14864
14863
|
return id;
|
|
14865
14864
|
}
|
|
14866
14865
|
};
|
|
14867
|
-
|
|
14868
|
-
|
|
14869
|
-
|
|
14870
|
-
|
|
14871
|
-
|
|
14872
|
-
|
|
14873
|
-
|
|
14874
|
-
|
|
14875
|
-
if (node.name === "textarea" || node.name === "select") {
|
|
14876
|
-
return ts62.factory.createKeywordTypeNode(ts62.SyntaxKind.StringKeyword);
|
|
14877
|
-
}
|
|
14878
|
-
if (node.name !== "input") {
|
|
14879
|
-
return this.getUnsupportedType();
|
|
14880
|
-
}
|
|
14881
|
-
const inputType = node.attributes.find((attr) => attr.name === "type")?.value;
|
|
14882
|
-
switch (inputType) {
|
|
14883
|
-
case "checkbox":
|
|
14884
|
-
return ts62.factory.createKeywordTypeNode(ts62.SyntaxKind.BooleanKeyword);
|
|
14885
|
-
case "number":
|
|
14886
|
-
case "range":
|
|
14887
|
-
case "datetime-local":
|
|
14888
|
-
return ts62.factory.createUnionTypeNode([
|
|
14889
|
-
ts62.factory.createKeywordTypeNode(ts62.SyntaxKind.StringKeyword),
|
|
14890
|
-
ts62.factory.createKeywordTypeNode(ts62.SyntaxKind.NumberKeyword)
|
|
14891
|
-
]);
|
|
14892
|
-
case "date":
|
|
14893
|
-
case "month":
|
|
14894
|
-
case "time":
|
|
14895
|
-
case "week":
|
|
14896
|
-
return ts62.factory.createUnionTypeNode([
|
|
14897
|
-
ts62.factory.createKeywordTypeNode(ts62.SyntaxKind.StringKeyword),
|
|
14898
|
-
ts62.factory.createKeywordTypeNode(ts62.SyntaxKind.NumberKeyword),
|
|
14899
|
-
ts62.factory.createTypeReferenceNode("Date"),
|
|
14900
|
-
ts62.factory.createLiteralTypeNode(ts62.factory.createNull())
|
|
14901
|
-
]);
|
|
14902
|
-
}
|
|
14903
|
-
return ts62.factory.createKeywordTypeNode(ts62.SyntaxKind.StringKeyword);
|
|
14904
|
-
}
|
|
14905
|
-
getUnsupportedType() {
|
|
14906
|
-
return ts62.factory.createKeywordTypeNode(ts62.SyntaxKind.UnknownKeyword);
|
|
14907
|
-
}
|
|
14908
|
-
};
|
|
14909
|
-
var TcbCustomFieldDirectiveTypeOp = class extends TcbFieldDirectiveTypeBaseOp {
|
|
14910
|
-
customFieldDir;
|
|
14911
|
-
constructor(tcb, scope, node, dir, customFieldDir) {
|
|
14912
|
-
super(tcb, scope, node, dir);
|
|
14913
|
-
this.customFieldDir = customFieldDir;
|
|
14866
|
+
|
|
14867
|
+
// packages/compiler-cli/src/ngtsc/typecheck/src/ops/completions.js
|
|
14868
|
+
import ts67 from "typescript";
|
|
14869
|
+
var TcbComponentContextCompletionOp = class extends TcbOp {
|
|
14870
|
+
scope;
|
|
14871
|
+
constructor(scope) {
|
|
14872
|
+
super();
|
|
14873
|
+
this.scope = scope;
|
|
14914
14874
|
}
|
|
14875
|
+
optional = false;
|
|
14915
14876
|
execute() {
|
|
14916
|
-
const
|
|
14917
|
-
|
|
14918
|
-
|
|
14919
|
-
|
|
14920
|
-
|
|
14921
|
-
|
|
14922
|
-
const extractRef = this.tcb.env.referenceExternalType(id.moduleName, id.name);
|
|
14923
|
-
if (!ts62.isTypeReferenceNode(extractRef)) {
|
|
14924
|
-
throw new Error(`Expected TypeReferenceNode when referencing the type for ${id.name}`);
|
|
14925
|
-
}
|
|
14926
|
-
return ts62.factory.createTypeReferenceNode(extractRef.typeName, [
|
|
14927
|
-
this.getCustomFieldTypeReference()
|
|
14928
|
-
]);
|
|
14929
|
-
}
|
|
14930
|
-
getCustomFieldTypeReference() {
|
|
14931
|
-
const customFieldRef = this.tcb.env.referenceType(this.customFieldDir.meta.ref);
|
|
14932
|
-
if (!ts62.isTypeReferenceNode(customFieldRef)) {
|
|
14933
|
-
throw new Error(`Expected TypeReferenceNode when referencing the type for ${this.customFieldDir.meta.ref.debugName}`);
|
|
14934
|
-
}
|
|
14935
|
-
return customFieldRef;
|
|
14936
|
-
}
|
|
14937
|
-
appendFormFieldConformanceStatements() {
|
|
14938
|
-
let span;
|
|
14939
|
-
if (this.node instanceof TmplAstHostElement2) {
|
|
14940
|
-
span = this.node.sourceSpan;
|
|
14941
|
-
} else {
|
|
14942
|
-
span = this.node.inputs.find((input) => {
|
|
14943
|
-
return input.type === BindingType3.Property && input.name === "field";
|
|
14944
|
-
})?.sourceSpan ?? this.node.startSourceSpan;
|
|
14945
|
-
}
|
|
14946
|
-
const isCheckbox = this.customFieldDir.type === "checkbox";
|
|
14947
|
-
const symbolName = isCheckbox ? "FormCheckboxControl" : "FormValueControl";
|
|
14948
|
-
const targetTypeRef = this.tcb.env.referenceExternalType("@angular/forms/signals", symbolName);
|
|
14949
|
-
if (!ts62.isTypeReferenceNode(targetTypeRef)) {
|
|
14950
|
-
throw new Error(`Expected TypeReferenceNode when referencing the type for ${symbolName}`);
|
|
14951
|
-
}
|
|
14952
|
-
const id = this.tcb.allocateId();
|
|
14953
|
-
const targetType = ts62.factory.createTypeReferenceNode(targetTypeRef.typeName, isCheckbox ? void 0 : [ts62.factory.createKeywordTypeNode(ts62.SyntaxKind.UnknownKeyword)]);
|
|
14954
|
-
this.scope.addStatement(tsDeclareVariable(id, targetType));
|
|
14955
|
-
const controlType = ts62.factory.createAsExpression(ts62.factory.createNonNullExpression(ts62.factory.createNull()), this.getCustomFieldTypeReference());
|
|
14956
|
-
const assignment = ts62.factory.createBinaryExpression(id, ts62.SyntaxKind.EqualsToken, controlType);
|
|
14957
|
-
addParseSpanInfo(assignment, span);
|
|
14958
|
-
this.scope.addStatement(ts62.factory.createIfStatement(id, ts62.factory.createExpressionStatement(assignment)));
|
|
14877
|
+
const ctx = ts67.factory.createThis();
|
|
14878
|
+
const ctxDot = ts67.factory.createPropertyAccessExpression(ctx, "");
|
|
14879
|
+
markIgnoreDiagnostics(ctxDot);
|
|
14880
|
+
addExpressionIdentifier(ctxDot, ExpressionIdentifier.COMPONENT_COMPLETION);
|
|
14881
|
+
this.scope.addStatement(ts67.factory.createExpressionStatement(ctxDot));
|
|
14882
|
+
return null;
|
|
14959
14883
|
}
|
|
14960
14884
|
};
|
|
14885
|
+
|
|
14886
|
+
// packages/compiler-cli/src/ngtsc/typecheck/src/ops/references.js
|
|
14887
|
+
import { DYNAMIC_TYPE, TmplAstElement as TmplAstElement2, TmplAstTemplate as TmplAstTemplate2 } from "@angular/compiler";
|
|
14888
|
+
import ts68 from "typescript";
|
|
14961
14889
|
var TcbReferenceOp = class extends TcbOp {
|
|
14962
14890
|
tcb;
|
|
14963
14891
|
scope;
|
|
@@ -14977,13 +14905,13 @@ var TcbReferenceOp = class extends TcbOp {
|
|
|
14977
14905
|
optional = true;
|
|
14978
14906
|
execute() {
|
|
14979
14907
|
const id = this.tcb.allocateId();
|
|
14980
|
-
let initializer = this.target instanceof
|
|
14908
|
+
let initializer = this.target instanceof TmplAstTemplate2 || this.target instanceof TmplAstElement2 ? this.scope.resolve(this.target) : this.scope.resolve(this.host, this.target);
|
|
14981
14909
|
if (this.target instanceof TmplAstElement2 && !this.tcb.env.config.checkTypeOfDomReferences || !this.tcb.env.config.checkTypeOfNonDomReferences) {
|
|
14982
|
-
initializer =
|
|
14983
|
-
} else if (this.target instanceof
|
|
14984
|
-
initializer =
|
|
14985
|
-
initializer =
|
|
14986
|
-
initializer =
|
|
14910
|
+
initializer = ts68.factory.createAsExpression(initializer, ts68.factory.createKeywordTypeNode(ts68.SyntaxKind.AnyKeyword));
|
|
14911
|
+
} else if (this.target instanceof TmplAstTemplate2) {
|
|
14912
|
+
initializer = ts68.factory.createAsExpression(initializer, ts68.factory.createKeywordTypeNode(ts68.SyntaxKind.AnyKeyword));
|
|
14913
|
+
initializer = ts68.factory.createAsExpression(initializer, this.tcb.env.referenceExternalType("@angular/core", "TemplateRef", [DYNAMIC_TYPE]));
|
|
14914
|
+
initializer = ts68.factory.createParenthesizedExpression(initializer);
|
|
14987
14915
|
}
|
|
14988
14916
|
addParseSpanInfo(initializer, this.node.sourceSpan);
|
|
14989
14917
|
addParseSpanInfo(id, this.node.keySpan);
|
|
@@ -15007,330 +14935,667 @@ var TcbInvalidReferenceOp = class extends TcbOp {
|
|
|
15007
14935
|
return id;
|
|
15008
14936
|
}
|
|
15009
14937
|
};
|
|
15010
|
-
|
|
14938
|
+
|
|
14939
|
+
// packages/compiler-cli/src/ngtsc/typecheck/src/ops/if_block.js
|
|
14940
|
+
import ts69 from "typescript";
|
|
14941
|
+
var TcbIfOp = class extends TcbOp {
|
|
15011
14942
|
tcb;
|
|
15012
14943
|
scope;
|
|
15013
|
-
|
|
15014
|
-
|
|
15015
|
-
constructor(tcb, scope,
|
|
14944
|
+
block;
|
|
14945
|
+
expressionScopes = /* @__PURE__ */ new Map();
|
|
14946
|
+
constructor(tcb, scope, block) {
|
|
15016
14947
|
super();
|
|
15017
14948
|
this.tcb = tcb;
|
|
15018
14949
|
this.scope = scope;
|
|
15019
|
-
this.
|
|
15020
|
-
this.dir = dir;
|
|
14950
|
+
this.block = block;
|
|
15021
14951
|
}
|
|
15022
14952
|
get optional() {
|
|
15023
|
-
return
|
|
14953
|
+
return false;
|
|
15024
14954
|
}
|
|
15025
14955
|
execute() {
|
|
15026
|
-
const
|
|
15027
|
-
|
|
15028
|
-
|
|
15029
|
-
|
|
15030
|
-
|
|
15031
|
-
|
|
15032
|
-
|
|
15033
|
-
|
|
15034
|
-
boundAttrs = getBoundAttributes(this.dir, this.node);
|
|
15035
|
-
span = this.node.startSourceSpan || this.node.sourceSpan;
|
|
14956
|
+
const root = this.generateBranch(0);
|
|
14957
|
+
root && this.scope.addStatement(root);
|
|
14958
|
+
return null;
|
|
14959
|
+
}
|
|
14960
|
+
generateBranch(index) {
|
|
14961
|
+
const branch = this.block.branches[index];
|
|
14962
|
+
if (!branch) {
|
|
14963
|
+
return void 0;
|
|
15036
14964
|
}
|
|
15037
|
-
|
|
15038
|
-
|
|
15039
|
-
|
|
15040
|
-
|
|
14965
|
+
if (branch.expression === null) {
|
|
14966
|
+
const branchScope = this.getBranchScope(this.scope, branch, index);
|
|
14967
|
+
return ts69.factory.createBlock(branchScope.render());
|
|
14968
|
+
}
|
|
14969
|
+
const outerScope = this.scope.createChildScope(this.scope, branch, [], null);
|
|
14970
|
+
outerScope.render().forEach((stmt) => this.scope.addStatement(stmt));
|
|
14971
|
+
this.expressionScopes.set(branch, outerScope);
|
|
14972
|
+
let expression = tcbExpression(branch.expression, this.tcb, this.scope);
|
|
14973
|
+
if (branch.expressionAlias !== null) {
|
|
14974
|
+
expression = ts69.factory.createBinaryExpression(ts69.factory.createParenthesizedExpression(expression), ts69.SyntaxKind.AmpersandAmpersandToken, outerScope.resolve(branch.expressionAlias));
|
|
14975
|
+
}
|
|
14976
|
+
const bodyScope = this.getBranchScope(outerScope, branch, index);
|
|
14977
|
+
return ts69.factory.createIfStatement(expression, ts69.factory.createBlock(bodyScope.render()), this.generateBranch(index + 1));
|
|
14978
|
+
}
|
|
14979
|
+
getBranchScope(parentScope, branch, index) {
|
|
14980
|
+
const checkBody = this.tcb.env.config.checkControlFlowBodies;
|
|
14981
|
+
return this.scope.createChildScope(parentScope, null, checkBody ? branch.children : [], checkBody ? this.generateBranchGuard(index) : null);
|
|
14982
|
+
}
|
|
14983
|
+
generateBranchGuard(index) {
|
|
14984
|
+
let guard = null;
|
|
14985
|
+
for (let i = 0; i <= index; i++) {
|
|
14986
|
+
const branch = this.block.branches[i];
|
|
14987
|
+
if (branch.expression === null) {
|
|
15041
14988
|
continue;
|
|
15042
14989
|
}
|
|
15043
|
-
|
|
15044
|
-
|
|
15045
|
-
continue;
|
|
15046
|
-
}
|
|
15047
|
-
const expression = translateInput(attr.attribute, this.tcb, this.scope);
|
|
15048
|
-
genericInputs.set(fieldName, {
|
|
15049
|
-
type: "binding",
|
|
15050
|
-
field: fieldName,
|
|
15051
|
-
expression,
|
|
15052
|
-
sourceSpan: attr.attribute.sourceSpan,
|
|
15053
|
-
isTwoWayBinding
|
|
15054
|
-
});
|
|
14990
|
+
if (!this.expressionScopes.has(branch)) {
|
|
14991
|
+
throw new Error(`Could not determine expression scope of branch at index ${i}`);
|
|
15055
14992
|
}
|
|
15056
|
-
|
|
15057
|
-
|
|
15058
|
-
|
|
15059
|
-
|
|
14993
|
+
const expressionScope = this.expressionScopes.get(branch);
|
|
14994
|
+
let expression;
|
|
14995
|
+
expression = tcbExpression(branch.expression, this.tcb, expressionScope);
|
|
14996
|
+
if (branch.expressionAlias !== null) {
|
|
14997
|
+
expression = ts69.factory.createBinaryExpression(ts69.factory.createParenthesizedExpression(expression), ts69.SyntaxKind.AmpersandAmpersandToken, expressionScope.resolve(branch.expressionAlias));
|
|
15060
14998
|
}
|
|
14999
|
+
markIgnoreDiagnostics(expression);
|
|
15000
|
+
const comparisonExpression = i === index ? expression : ts69.factory.createPrefixUnaryExpression(ts69.SyntaxKind.ExclamationToken, ts69.factory.createParenthesizedExpression(expression));
|
|
15001
|
+
guard = guard === null ? comparisonExpression : ts69.factory.createBinaryExpression(guard, ts69.SyntaxKind.AmpersandAmpersandToken, comparisonExpression);
|
|
15061
15002
|
}
|
|
15062
|
-
|
|
15063
|
-
markIgnoreDiagnostics(typeCtor);
|
|
15064
|
-
this.scope.addStatement(tsCreateVariable(id, typeCtor));
|
|
15065
|
-
return id;
|
|
15066
|
-
}
|
|
15067
|
-
circularFallback() {
|
|
15068
|
-
return new TcbDirectiveCtorCircularFallbackOp(this.tcb, this.scope, this.dir);
|
|
15003
|
+
return guard;
|
|
15069
15004
|
}
|
|
15070
15005
|
};
|
|
15071
|
-
|
|
15006
|
+
|
|
15007
|
+
// packages/compiler-cli/src/ngtsc/typecheck/src/ops/switch_block.js
|
|
15008
|
+
import ts70 from "typescript";
|
|
15009
|
+
var TcbSwitchOp = class extends TcbOp {
|
|
15072
15010
|
tcb;
|
|
15073
15011
|
scope;
|
|
15074
|
-
|
|
15075
|
-
|
|
15076
|
-
constructor(tcb, scope, node, dir) {
|
|
15012
|
+
block;
|
|
15013
|
+
constructor(tcb, scope, block) {
|
|
15077
15014
|
super();
|
|
15078
15015
|
this.tcb = tcb;
|
|
15079
15016
|
this.scope = scope;
|
|
15080
|
-
this.
|
|
15081
|
-
this.dir = dir;
|
|
15017
|
+
this.block = block;
|
|
15082
15018
|
}
|
|
15083
15019
|
get optional() {
|
|
15084
15020
|
return false;
|
|
15085
15021
|
}
|
|
15086
15022
|
execute() {
|
|
15087
|
-
|
|
15088
|
-
const
|
|
15089
|
-
|
|
15090
|
-
|
|
15091
|
-
const
|
|
15092
|
-
|
|
15093
|
-
|
|
15094
|
-
|
|
15095
|
-
if (required) {
|
|
15096
|
-
seenRequiredInputs.add(fieldName);
|
|
15097
|
-
}
|
|
15098
|
-
if (this.dir.coercedInputFields.has(fieldName)) {
|
|
15099
|
-
let type;
|
|
15100
|
-
if (transformType !== null) {
|
|
15101
|
-
type = this.tcb.env.referenceTransplantedType(new TransplantedType(transformType));
|
|
15102
|
-
} else {
|
|
15103
|
-
const dirTypeRef = this.tcb.env.referenceType(this.dir.ref);
|
|
15104
|
-
if (!ts62.isTypeReferenceNode(dirTypeRef)) {
|
|
15105
|
-
throw new Error(`Expected TypeReferenceNode from reference to ${this.dir.ref.debugName}`);
|
|
15106
|
-
}
|
|
15107
|
-
type = tsCreateTypeQueryForCoercedInput(dirTypeRef.typeName, fieldName);
|
|
15108
|
-
}
|
|
15109
|
-
const id = this.tcb.allocateId();
|
|
15110
|
-
this.scope.addStatement(tsDeclareVariable(id, type));
|
|
15111
|
-
target = id;
|
|
15112
|
-
} else if (this.dir.undeclaredInputFields.has(fieldName)) {
|
|
15113
|
-
continue;
|
|
15114
|
-
} else if (!this.tcb.env.config.honorAccessModifiersForInputBindings && this.dir.restrictedInputFields.has(fieldName)) {
|
|
15115
|
-
if (dirId === null) {
|
|
15116
|
-
dirId = this.scope.resolve(this.node, this.dir);
|
|
15117
|
-
}
|
|
15118
|
-
const id = this.tcb.allocateId();
|
|
15119
|
-
const dirTypeRef = this.tcb.env.referenceType(this.dir.ref);
|
|
15120
|
-
if (!ts62.isTypeReferenceNode(dirTypeRef)) {
|
|
15121
|
-
throw new Error(`Expected TypeReferenceNode from reference to ${this.dir.ref.debugName}`);
|
|
15122
|
-
}
|
|
15123
|
-
const type = ts62.factory.createIndexedAccessTypeNode(ts62.factory.createTypeQueryNode(dirId), ts62.factory.createLiteralTypeNode(ts62.factory.createStringLiteral(fieldName)));
|
|
15124
|
-
const temp = tsDeclareVariable(id, type);
|
|
15125
|
-
this.scope.addStatement(temp);
|
|
15126
|
-
target = id;
|
|
15127
|
-
} else {
|
|
15128
|
-
if (dirId === null) {
|
|
15129
|
-
dirId = this.scope.resolve(this.node, this.dir);
|
|
15130
|
-
}
|
|
15131
|
-
target = this.dir.stringLiteralInputFields.has(fieldName) ? ts62.factory.createElementAccessExpression(dirId, ts62.factory.createStringLiteral(fieldName)) : ts62.factory.createPropertyAccessExpression(dirId, ts62.factory.createIdentifier(fieldName));
|
|
15132
|
-
}
|
|
15133
|
-
if (isSignal) {
|
|
15134
|
-
const inputSignalBrandWriteSymbol = this.tcb.env.referenceExternalSymbol(R3Identifiers4.InputSignalBrandWriteType.moduleName, R3Identifiers4.InputSignalBrandWriteType.name);
|
|
15135
|
-
if (!ts62.isIdentifier(inputSignalBrandWriteSymbol) && !ts62.isPropertyAccessExpression(inputSignalBrandWriteSymbol)) {
|
|
15136
|
-
throw new Error(`Expected identifier or property access for reference to ${R3Identifiers4.InputSignalBrandWriteType.name}`);
|
|
15137
|
-
}
|
|
15138
|
-
target = ts62.factory.createElementAccessExpression(target, inputSignalBrandWriteSymbol);
|
|
15139
|
-
}
|
|
15140
|
-
if (attr.attribute.keySpan !== void 0) {
|
|
15141
|
-
addParseSpanInfo(target, attr.attribute.keySpan);
|
|
15142
|
-
}
|
|
15143
|
-
if (isTwoWayBinding && this.tcb.env.config.allowSignalsInTwoWayBindings) {
|
|
15144
|
-
assignment = unwrapWritableSignal(assignment, this.tcb);
|
|
15145
|
-
}
|
|
15146
|
-
assignment = ts62.factory.createBinaryExpression(target, ts62.SyntaxKind.EqualsToken, assignment);
|
|
15147
|
-
}
|
|
15148
|
-
addParseSpanInfo(assignment, attr.attribute.sourceSpan);
|
|
15149
|
-
if (!this.tcb.env.config.checkTypeOfAttributes && attr.attribute instanceof TmplAstTextAttribute2) {
|
|
15150
|
-
markIgnoreDiagnostics(assignment);
|
|
15151
|
-
}
|
|
15152
|
-
this.scope.addStatement(ts62.factory.createExpressionStatement(assignment));
|
|
15153
|
-
}
|
|
15154
|
-
this.checkRequiredInputs(seenRequiredInputs);
|
|
15023
|
+
const switchExpression = tcbExpression(this.block.expression, this.tcb, this.scope);
|
|
15024
|
+
const clauses = this.block.cases.map((current) => {
|
|
15025
|
+
const checkBody = this.tcb.env.config.checkControlFlowBodies;
|
|
15026
|
+
const clauseScope = this.scope.createChildScope(this.scope, null, checkBody ? current.children : [], checkBody ? this.generateGuard(current, switchExpression) : null);
|
|
15027
|
+
const statements = [...clauseScope.render(), ts70.factory.createBreakStatement()];
|
|
15028
|
+
return current.expression === null ? ts70.factory.createDefaultClause(statements) : ts70.factory.createCaseClause(tcbExpression(current.expression, this.tcb, clauseScope), statements);
|
|
15029
|
+
});
|
|
15030
|
+
this.scope.addStatement(ts70.factory.createSwitchStatement(switchExpression, ts70.factory.createCaseBlock(clauses)));
|
|
15155
15031
|
return null;
|
|
15156
15032
|
}
|
|
15157
|
-
|
|
15158
|
-
|
|
15159
|
-
|
|
15160
|
-
|
|
15161
|
-
|
|
15162
|
-
}
|
|
15033
|
+
generateGuard(node, switchValue) {
|
|
15034
|
+
if (node.expression !== null) {
|
|
15035
|
+
const expression = tcbExpression(node.expression, this.tcb, this.scope);
|
|
15036
|
+
markIgnoreDiagnostics(expression);
|
|
15037
|
+
return ts70.factory.createBinaryExpression(switchValue, ts70.SyntaxKind.EqualsEqualsEqualsToken, expression);
|
|
15163
15038
|
}
|
|
15164
|
-
|
|
15165
|
-
|
|
15039
|
+
let guard = null;
|
|
15040
|
+
for (const current of this.block.cases) {
|
|
15041
|
+
if (current.expression === null) {
|
|
15042
|
+
continue;
|
|
15043
|
+
}
|
|
15044
|
+
const expression = tcbExpression(current.expression, this.tcb, this.scope);
|
|
15045
|
+
markIgnoreDiagnostics(expression);
|
|
15046
|
+
const comparison = ts70.factory.createBinaryExpression(switchValue, ts70.SyntaxKind.ExclamationEqualsEqualsToken, expression);
|
|
15047
|
+
if (guard === null) {
|
|
15048
|
+
guard = comparison;
|
|
15049
|
+
} else {
|
|
15050
|
+
guard = ts70.factory.createBinaryExpression(guard, ts70.SyntaxKind.AmpersandAmpersandToken, comparison);
|
|
15051
|
+
}
|
|
15166
15052
|
}
|
|
15053
|
+
return guard;
|
|
15167
15054
|
}
|
|
15168
15055
|
};
|
|
15169
|
-
|
|
15056
|
+
|
|
15057
|
+
// packages/compiler-cli/src/ngtsc/typecheck/src/ops/for_block.js
|
|
15058
|
+
import { ImplicitReceiver as ImplicitReceiver4, PropertyRead as PropertyRead5, TmplAstVariable } from "@angular/compiler";
|
|
15059
|
+
import ts71 from "typescript";
|
|
15060
|
+
var TcbForOfOp = class extends TcbOp {
|
|
15170
15061
|
tcb;
|
|
15171
15062
|
scope;
|
|
15172
|
-
|
|
15173
|
-
constructor(tcb, scope,
|
|
15063
|
+
block;
|
|
15064
|
+
constructor(tcb, scope, block) {
|
|
15174
15065
|
super();
|
|
15175
15066
|
this.tcb = tcb;
|
|
15176
15067
|
this.scope = scope;
|
|
15177
|
-
this.
|
|
15068
|
+
this.block = block;
|
|
15178
15069
|
}
|
|
15179
15070
|
get optional() {
|
|
15180
15071
|
return false;
|
|
15181
15072
|
}
|
|
15182
15073
|
execute() {
|
|
15183
|
-
const
|
|
15184
|
-
const
|
|
15185
|
-
|
|
15186
|
-
|
|
15187
|
-
|
|
15188
|
-
|
|
15189
|
-
|
|
15190
|
-
);
|
|
15191
|
-
this.
|
|
15192
|
-
|
|
15074
|
+
const loopScope = this.scope.createChildScope(this.scope, this.block, this.tcb.env.config.checkControlFlowBodies ? this.block.children : [], null);
|
|
15075
|
+
const initializerId = loopScope.resolve(this.block.item);
|
|
15076
|
+
if (!ts71.isIdentifier(initializerId)) {
|
|
15077
|
+
throw new Error(`Could not resolve for loop variable ${this.block.item.name} to an identifier`);
|
|
15078
|
+
}
|
|
15079
|
+
const initializer = ts71.factory.createVariableDeclarationList([ts71.factory.createVariableDeclaration(initializerId)], ts71.NodeFlags.Const);
|
|
15080
|
+
addParseSpanInfo(initializer, this.block.item.keySpan);
|
|
15081
|
+
const expression = ts71.factory.createNonNullExpression(tcbExpression(this.block.expression, this.tcb, this.scope));
|
|
15082
|
+
const trackTranslator = new TcbForLoopTrackTranslator(this.tcb, loopScope, this.block);
|
|
15083
|
+
const trackExpression = trackTranslator.translate(this.block.trackBy);
|
|
15084
|
+
const statements = [
|
|
15085
|
+
...loopScope.render(),
|
|
15086
|
+
ts71.factory.createExpressionStatement(trackExpression)
|
|
15087
|
+
];
|
|
15088
|
+
this.scope.addStatement(ts71.factory.createForOfStatement(void 0, initializer, expression, ts71.factory.createBlock(statements)));
|
|
15089
|
+
return null;
|
|
15193
15090
|
}
|
|
15194
15091
|
};
|
|
15195
|
-
var
|
|
15196
|
-
|
|
15197
|
-
|
|
15198
|
-
|
|
15199
|
-
|
|
15200
|
-
|
|
15201
|
-
|
|
15202
|
-
|
|
15203
|
-
|
|
15204
|
-
|
|
15205
|
-
this.claimedInputs = claimedInputs;
|
|
15206
|
-
}
|
|
15207
|
-
get optional() {
|
|
15208
|
-
return false;
|
|
15209
|
-
}
|
|
15210
|
-
execute() {
|
|
15211
|
-
const element = this.element;
|
|
15212
|
-
const isTemplateElement = element instanceof TmplAstElement2 || element instanceof TmplAstComponent2;
|
|
15213
|
-
const bindings = isTemplateElement ? element.inputs : element.bindings;
|
|
15214
|
-
if (this.checkElement && isTemplateElement) {
|
|
15215
|
-
this.tcb.domSchemaChecker.checkElement(this.tcb.id, this.getTagName(element), element.startSourceSpan, this.tcb.schemas, this.tcb.hostIsStandalone);
|
|
15216
|
-
}
|
|
15217
|
-
for (const binding of bindings) {
|
|
15218
|
-
const isPropertyBinding = binding.type === BindingType3.Property || binding.type === BindingType3.TwoWay;
|
|
15219
|
-
if (isPropertyBinding && this.claimedInputs?.has(binding.name)) {
|
|
15220
|
-
continue;
|
|
15221
|
-
}
|
|
15222
|
-
if (isPropertyBinding && binding.name !== "style" && binding.name !== "class") {
|
|
15223
|
-
const propertyName = REGISTRY.getMappedPropName(binding.name);
|
|
15224
|
-
if (isTemplateElement) {
|
|
15225
|
-
this.tcb.domSchemaChecker.checkTemplateElementProperty(this.tcb.id, this.getTagName(element), propertyName, binding.sourceSpan, this.tcb.schemas, this.tcb.hostIsStandalone);
|
|
15226
|
-
} else {
|
|
15227
|
-
this.tcb.domSchemaChecker.checkHostElementProperty(this.tcb.id, element, propertyName, binding.keySpan, this.tcb.schemas);
|
|
15228
|
-
}
|
|
15092
|
+
var TcbForLoopTrackTranslator = class extends TcbExpressionTranslator {
|
|
15093
|
+
block;
|
|
15094
|
+
allowedVariables;
|
|
15095
|
+
constructor(tcb, scope, block) {
|
|
15096
|
+
super(tcb, scope);
|
|
15097
|
+
this.block = block;
|
|
15098
|
+
this.allowedVariables = /* @__PURE__ */ new Set([block.item]);
|
|
15099
|
+
for (const variable of block.contextVariables) {
|
|
15100
|
+
if (variable.value === "$index") {
|
|
15101
|
+
this.allowedVariables.add(variable);
|
|
15229
15102
|
}
|
|
15230
15103
|
}
|
|
15231
|
-
return null;
|
|
15232
15104
|
}
|
|
15233
|
-
|
|
15234
|
-
|
|
15105
|
+
resolve(ast) {
|
|
15106
|
+
if (ast instanceof PropertyRead5 && ast.receiver instanceof ImplicitReceiver4) {
|
|
15107
|
+
const target = this.tcb.boundTarget.getExpressionTarget(ast);
|
|
15108
|
+
if (target !== null && (!(target instanceof TmplAstVariable) || !this.allowedVariables.has(target))) {
|
|
15109
|
+
this.tcb.oobRecorder.illegalForLoopTrackAccess(this.tcb.id, this.block, ast);
|
|
15110
|
+
}
|
|
15111
|
+
}
|
|
15112
|
+
return super.resolve(ast);
|
|
15235
15113
|
}
|
|
15236
15114
|
};
|
|
15237
|
-
|
|
15115
|
+
|
|
15116
|
+
// packages/compiler-cli/src/ngtsc/typecheck/src/ops/let.js
|
|
15117
|
+
import ts72 from "typescript";
|
|
15118
|
+
var TcbLetDeclarationOp = class extends TcbOp {
|
|
15238
15119
|
tcb;
|
|
15239
|
-
|
|
15240
|
-
|
|
15241
|
-
|
|
15242
|
-
category;
|
|
15243
|
-
constructor(tcb, element, ngContentSelectors, componentName) {
|
|
15120
|
+
scope;
|
|
15121
|
+
node;
|
|
15122
|
+
constructor(tcb, scope, node) {
|
|
15244
15123
|
super();
|
|
15245
15124
|
this.tcb = tcb;
|
|
15246
|
-
this.
|
|
15247
|
-
this.
|
|
15248
|
-
this.componentName = componentName;
|
|
15249
|
-
this.category = tcb.env.config.controlFlowPreventingContentProjection === "error" ? ts62.DiagnosticCategory.Error : ts62.DiagnosticCategory.Warning;
|
|
15125
|
+
this.scope = scope;
|
|
15126
|
+
this.node = node;
|
|
15250
15127
|
}
|
|
15128
|
+
/**
|
|
15129
|
+
* `@let` declarations are mandatory, because their expressions
|
|
15130
|
+
* should be checked even if they aren't referenced anywhere.
|
|
15131
|
+
*/
|
|
15251
15132
|
optional = false;
|
|
15252
15133
|
execute() {
|
|
15253
|
-
const
|
|
15254
|
-
|
|
15255
|
-
|
|
15256
|
-
|
|
15257
|
-
|
|
15258
|
-
|
|
15259
|
-
|
|
15260
|
-
|
|
15261
|
-
|
|
15262
|
-
|
|
15263
|
-
|
|
15264
|
-
|
|
15265
|
-
|
|
15266
|
-
|
|
15267
|
-
|
|
15268
|
-
|
|
15269
|
-
|
|
15134
|
+
const id = this.tcb.allocateId();
|
|
15135
|
+
addParseSpanInfo(id, this.node.nameSpan);
|
|
15136
|
+
const value = tcbExpression(this.node.value, this.tcb, this.scope);
|
|
15137
|
+
const varStatement = tsCreateVariable(id, wrapForTypeChecker(value), ts72.NodeFlags.Const);
|
|
15138
|
+
addParseSpanInfo(varStatement.declarationList.declarations[0], this.node.sourceSpan);
|
|
15139
|
+
this.scope.addStatement(varStatement);
|
|
15140
|
+
return id;
|
|
15141
|
+
}
|
|
15142
|
+
};
|
|
15143
|
+
|
|
15144
|
+
// packages/compiler-cli/src/ngtsc/typecheck/src/ops/inputs.js
|
|
15145
|
+
import { BindingType as BindingType5, R3Identifiers as R3Identifiers5, TransplantedType } from "@angular/compiler";
|
|
15146
|
+
import ts75 from "typescript";
|
|
15147
|
+
|
|
15148
|
+
// packages/compiler-cli/src/ngtsc/typecheck/src/ops/signal_forms.js
|
|
15149
|
+
import { BindingType as BindingType3, Call as Call4, PropertyRead as PropertyRead6, SafeCall as SafeCall3, TmplAstElement as TmplAstElement3, TmplAstHostElement as TmplAstHostElement2 } from "@angular/compiler";
|
|
15150
|
+
import ts73 from "typescript";
|
|
15151
|
+
var formControlInputFields = [
|
|
15152
|
+
// Should be kept in sync with the `FormUiControl` bindings,
|
|
15153
|
+
// defined in `packages/forms/signals/src/api/control.ts`.
|
|
15154
|
+
"errors",
|
|
15155
|
+
"invalid",
|
|
15156
|
+
"disabled",
|
|
15157
|
+
"disabledReasons",
|
|
15158
|
+
"name",
|
|
15159
|
+
"readonly",
|
|
15160
|
+
"touched",
|
|
15161
|
+
"max",
|
|
15162
|
+
"maxLength",
|
|
15163
|
+
"min",
|
|
15164
|
+
"minLength",
|
|
15165
|
+
"pattern",
|
|
15166
|
+
"required"
|
|
15167
|
+
];
|
|
15168
|
+
var customFormControlBannedInputFields = /* @__PURE__ */ new Set([
|
|
15169
|
+
...formControlInputFields,
|
|
15170
|
+
"value",
|
|
15171
|
+
"checked"
|
|
15172
|
+
]);
|
|
15173
|
+
var formControlOptionalFields = /* @__PURE__ */ new Set([
|
|
15174
|
+
// Should be kept in sync with the `FormUiControl` bindings,
|
|
15175
|
+
// defined in `packages/forms/signals/src/api/control.ts`.
|
|
15176
|
+
"max",
|
|
15177
|
+
"maxLength",
|
|
15178
|
+
"min",
|
|
15179
|
+
"minLength"
|
|
15180
|
+
]);
|
|
15181
|
+
var TcbNativeFieldDirectiveTypeOp = class extends TcbOp {
|
|
15182
|
+
tcb;
|
|
15183
|
+
scope;
|
|
15184
|
+
node;
|
|
15185
|
+
/** Bindings that aren't supported on signal form fields. */
|
|
15186
|
+
unsupportedBindingFields = /* @__PURE__ */ new Set([
|
|
15187
|
+
...formControlInputFields,
|
|
15188
|
+
"value",
|
|
15189
|
+
"checked",
|
|
15190
|
+
"type",
|
|
15191
|
+
"maxlength",
|
|
15192
|
+
"minlength"
|
|
15193
|
+
]);
|
|
15194
|
+
inputType;
|
|
15195
|
+
get optional() {
|
|
15196
|
+
return false;
|
|
15197
|
+
}
|
|
15198
|
+
constructor(tcb, scope, node) {
|
|
15199
|
+
super();
|
|
15200
|
+
this.tcb = tcb;
|
|
15201
|
+
this.scope = scope;
|
|
15202
|
+
this.node = node;
|
|
15203
|
+
this.inputType = node.name === "input" && node.attributes.find((attr) => attr.name === "type")?.value || null;
|
|
15204
|
+
if (this.inputType === "radio") {
|
|
15205
|
+
this.unsupportedBindingFields.delete("value");
|
|
15270
15206
|
}
|
|
15207
|
+
}
|
|
15208
|
+
execute() {
|
|
15209
|
+
const inputs = this.node instanceof TmplAstHostElement2 ? this.node.bindings : this.node.inputs;
|
|
15210
|
+
const fieldBinding = inputs.find((input) => input.type === BindingType3.Property && input.name === "field") ?? null;
|
|
15211
|
+
if (fieldBinding === null) {
|
|
15212
|
+
return null;
|
|
15213
|
+
}
|
|
15214
|
+
checkUnsupportedFieldBindings(this.node, this.unsupportedBindingFields, this.tcb);
|
|
15215
|
+
const expectedType = this.node instanceof TmplAstElement3 ? this.getExpectedTypeFromDomNode(this.node) : this.getUnsupportedType();
|
|
15216
|
+
const value = extractFieldValue(fieldBinding.value, this.tcb, this.scope);
|
|
15217
|
+
const id = this.tcb.allocateId();
|
|
15218
|
+
const assignment = ts73.factory.createBinaryExpression(id, ts73.SyntaxKind.EqualsToken, value);
|
|
15219
|
+
addParseSpanInfo(assignment, fieldBinding.valueSpan ?? fieldBinding.sourceSpan);
|
|
15220
|
+
this.scope.addStatement(tsDeclareVariable(id, expectedType));
|
|
15221
|
+
this.scope.addStatement(ts73.factory.createExpressionStatement(assignment));
|
|
15271
15222
|
return null;
|
|
15272
15223
|
}
|
|
15273
|
-
|
|
15274
|
-
|
|
15275
|
-
|
|
15276
|
-
|
|
15277
|
-
|
|
15278
|
-
|
|
15279
|
-
|
|
15280
|
-
|
|
15281
|
-
|
|
15224
|
+
getExpectedTypeFromDomNode(node) {
|
|
15225
|
+
if (node.name === "textarea" || node.name === "select") {
|
|
15226
|
+
return ts73.factory.createKeywordTypeNode(ts73.SyntaxKind.StringKeyword);
|
|
15227
|
+
}
|
|
15228
|
+
if (node.name !== "input") {
|
|
15229
|
+
return this.getUnsupportedType();
|
|
15230
|
+
}
|
|
15231
|
+
switch (this.inputType) {
|
|
15232
|
+
case "checkbox":
|
|
15233
|
+
return ts73.factory.createKeywordTypeNode(ts73.SyntaxKind.BooleanKeyword);
|
|
15234
|
+
case "number":
|
|
15235
|
+
case "range":
|
|
15236
|
+
case "datetime-local":
|
|
15237
|
+
return ts73.factory.createUnionTypeNode([
|
|
15238
|
+
ts73.factory.createKeywordTypeNode(ts73.SyntaxKind.StringKeyword),
|
|
15239
|
+
ts73.factory.createKeywordTypeNode(ts73.SyntaxKind.NumberKeyword)
|
|
15240
|
+
]);
|
|
15241
|
+
case "date":
|
|
15242
|
+
case "month":
|
|
15243
|
+
case "time":
|
|
15244
|
+
case "week":
|
|
15245
|
+
return ts73.factory.createUnionTypeNode([
|
|
15246
|
+
ts73.factory.createKeywordTypeNode(ts73.SyntaxKind.StringKeyword),
|
|
15247
|
+
ts73.factory.createKeywordTypeNode(ts73.SyntaxKind.NumberKeyword),
|
|
15248
|
+
ts73.factory.createTypeReferenceNode("Date"),
|
|
15249
|
+
ts73.factory.createLiteralTypeNode(ts73.factory.createNull())
|
|
15250
|
+
]);
|
|
15251
|
+
}
|
|
15252
|
+
return ts73.factory.createKeywordTypeNode(ts73.SyntaxKind.StringKeyword);
|
|
15253
|
+
}
|
|
15254
|
+
getUnsupportedType() {
|
|
15255
|
+
return ts73.factory.createKeywordTypeNode(ts73.SyntaxKind.NeverKeyword);
|
|
15256
|
+
}
|
|
15257
|
+
};
|
|
15258
|
+
function expandBoundAttributesForField(directive, node, customFieldType) {
|
|
15259
|
+
const fieldBinding = node.inputs.find((input) => input.type === BindingType3.Property && input.name === "field");
|
|
15260
|
+
if (!fieldBinding) {
|
|
15261
|
+
return null;
|
|
15262
|
+
}
|
|
15263
|
+
let boundInputs = null;
|
|
15264
|
+
let primaryInput;
|
|
15265
|
+
if (customFieldType === "value") {
|
|
15266
|
+
primaryInput = getSyntheticFieldBoundInput(directive, "value", "value", fieldBinding, customFieldType);
|
|
15267
|
+
} else if (customFieldType === "checkbox") {
|
|
15268
|
+
primaryInput = getSyntheticFieldBoundInput(directive, "checked", "value", fieldBinding, customFieldType);
|
|
15269
|
+
} else {
|
|
15270
|
+
primaryInput = null;
|
|
15271
|
+
}
|
|
15272
|
+
if (primaryInput !== null) {
|
|
15273
|
+
boundInputs ??= [];
|
|
15274
|
+
boundInputs.push(primaryInput);
|
|
15275
|
+
}
|
|
15276
|
+
for (const name of formControlInputFields) {
|
|
15277
|
+
const input = getSyntheticFieldBoundInput(directive, name, name, fieldBinding, customFieldType);
|
|
15278
|
+
if (input !== null) {
|
|
15279
|
+
boundInputs ??= [];
|
|
15280
|
+
boundInputs.push(input);
|
|
15281
|
+
}
|
|
15282
|
+
}
|
|
15283
|
+
return boundInputs;
|
|
15284
|
+
}
|
|
15285
|
+
function isFieldDirective(meta) {
|
|
15286
|
+
if (meta.name !== "Field") {
|
|
15287
|
+
return false;
|
|
15288
|
+
}
|
|
15289
|
+
if (meta.ref.bestGuessOwningModule?.specifier === "@angular/forms/signals") {
|
|
15290
|
+
return true;
|
|
15291
|
+
}
|
|
15292
|
+
return ts73.isClassDeclaration(meta.ref.node) && meta.ref.node.members.some((member) => ts73.isPropertyDeclaration(member) && ts73.isComputedPropertyName(member.name) && ts73.isIdentifier(member.name.expression) && member.name.expression.text === "\u0275CONTROL");
|
|
15293
|
+
}
|
|
15294
|
+
function getSyntheticFieldBoundInput(dir, inputName, fieldPropertyName, fieldBinding, customFieldType) {
|
|
15295
|
+
const inputs = dir.inputs.getByBindingPropertyName(inputName);
|
|
15296
|
+
if (inputs === null || inputs.length === 0) {
|
|
15297
|
+
return null;
|
|
15298
|
+
}
|
|
15299
|
+
const { span, sourceSpan } = fieldBinding.value;
|
|
15300
|
+
const outerCall = new Call4(span, sourceSpan, fieldBinding.value, [], sourceSpan);
|
|
15301
|
+
const read = new PropertyRead6(span, sourceSpan, sourceSpan, outerCall, fieldPropertyName);
|
|
15302
|
+
const isTwoWayBinding = customFieldType === "value" && inputName === "value" || customFieldType === "checkbox" && inputName === "checked";
|
|
15303
|
+
let value;
|
|
15304
|
+
if (isTwoWayBinding) {
|
|
15305
|
+
value = read;
|
|
15306
|
+
} else if (formControlOptionalFields.has(fieldPropertyName)) {
|
|
15307
|
+
value = new SafeCall3(span, sourceSpan, read, [], sourceSpan);
|
|
15308
|
+
} else {
|
|
15309
|
+
value = new Call4(span, sourceSpan, read, [], sourceSpan);
|
|
15310
|
+
}
|
|
15311
|
+
return {
|
|
15312
|
+
value,
|
|
15313
|
+
sourceSpan: fieldBinding.sourceSpan,
|
|
15314
|
+
keySpan: fieldBinding.keySpan ?? null,
|
|
15315
|
+
inputs: inputs.map((input) => ({
|
|
15316
|
+
fieldName: input.classPropertyName,
|
|
15317
|
+
required: input.required,
|
|
15318
|
+
transformType: input.transform?.type || null,
|
|
15319
|
+
isSignal: input.isSignal,
|
|
15320
|
+
isTwoWayBinding
|
|
15321
|
+
}))
|
|
15322
|
+
};
|
|
15323
|
+
}
|
|
15324
|
+
function getCustomFieldDirectiveType(meta) {
|
|
15325
|
+
if (hasModelInput("value", meta)) {
|
|
15326
|
+
return "value";
|
|
15327
|
+
} else if (hasModelInput("checked", meta)) {
|
|
15328
|
+
return "checkbox";
|
|
15329
|
+
}
|
|
15330
|
+
return null;
|
|
15331
|
+
}
|
|
15332
|
+
function checkUnsupportedFieldBindings(node, unsupportedBindingFields, tcb) {
|
|
15333
|
+
const inputs = node instanceof TmplAstHostElement2 ? node.bindings : node.inputs;
|
|
15334
|
+
for (const input of inputs) {
|
|
15335
|
+
if (input.type === BindingType3.Property && unsupportedBindingFields.has(input.name)) {
|
|
15336
|
+
tcb.oobRecorder.formFieldUnsupportedBinding(tcb.id, input);
|
|
15337
|
+
} else if (input.type === BindingType3.Attribute && unsupportedBindingFields.has(input.name.toLowerCase())) {
|
|
15338
|
+
tcb.oobRecorder.formFieldUnsupportedBinding(tcb.id, input);
|
|
15339
|
+
}
|
|
15340
|
+
}
|
|
15341
|
+
if (!(node instanceof TmplAstHostElement2)) {
|
|
15342
|
+
for (const attr of node.attributes) {
|
|
15343
|
+
const name = attr.name.toLowerCase();
|
|
15344
|
+
if (name !== "type" && unsupportedBindingFields.has(name)) {
|
|
15345
|
+
tcb.oobRecorder.formFieldUnsupportedBinding(tcb.id, attr);
|
|
15346
|
+
}
|
|
15347
|
+
}
|
|
15348
|
+
}
|
|
15349
|
+
}
|
|
15350
|
+
function extractFieldValue(expression, tcb, scope) {
|
|
15351
|
+
const innerCall = ts73.factory.createCallExpression(tcbExpression(expression, tcb, scope), void 0, void 0);
|
|
15352
|
+
markIgnoreDiagnostics(innerCall);
|
|
15353
|
+
return ts73.factory.createCallExpression(ts73.factory.createPropertyAccessExpression(innerCall, "value"), void 0, void 0);
|
|
15354
|
+
}
|
|
15355
|
+
function hasModelInput(name, meta) {
|
|
15356
|
+
return !!meta.inputs.getByBindingPropertyName(name)?.some((v) => v.isSignal) && meta.outputs.hasBindingPropertyName(name + "Change");
|
|
15357
|
+
}
|
|
15358
|
+
|
|
15359
|
+
// packages/compiler-cli/src/ngtsc/typecheck/src/ops/bindings.js
|
|
15360
|
+
import { BindingType as BindingType4, TmplAstBoundAttribute as TmplAstBoundAttribute4, TmplAstElement as TmplAstElement4, TmplAstTemplate as TmplAstTemplate3 } from "@angular/compiler";
|
|
15361
|
+
import ts74 from "typescript";
|
|
15362
|
+
function getBoundAttributes(directive, node) {
|
|
15363
|
+
const boundInputs = [];
|
|
15364
|
+
const processAttribute = (attr) => {
|
|
15365
|
+
if (attr instanceof TmplAstBoundAttribute4 && attr.type !== BindingType4.Property && attr.type !== BindingType4.TwoWay) {
|
|
15366
|
+
return;
|
|
15367
|
+
}
|
|
15368
|
+
const inputs = directive.inputs.getByBindingPropertyName(attr.name);
|
|
15369
|
+
if (inputs !== null) {
|
|
15370
|
+
boundInputs.push({
|
|
15371
|
+
value: attr.value,
|
|
15372
|
+
sourceSpan: attr.sourceSpan,
|
|
15373
|
+
keySpan: attr.keySpan ?? null,
|
|
15374
|
+
inputs: inputs.map((input) => {
|
|
15375
|
+
return {
|
|
15376
|
+
fieldName: input.classPropertyName,
|
|
15377
|
+
required: input.required,
|
|
15378
|
+
transformType: input.transform?.type || null,
|
|
15379
|
+
isSignal: input.isSignal,
|
|
15380
|
+
isTwoWayBinding: attr instanceof TmplAstBoundAttribute4 && attr.type === BindingType4.TwoWay
|
|
15381
|
+
};
|
|
15382
|
+
})
|
|
15383
|
+
});
|
|
15384
|
+
}
|
|
15385
|
+
};
|
|
15386
|
+
if (node instanceof TmplAstTemplate3) {
|
|
15387
|
+
if (node.tagName === "ng-template") {
|
|
15388
|
+
node.inputs.forEach(processAttribute);
|
|
15389
|
+
node.attributes.forEach(processAttribute);
|
|
15390
|
+
}
|
|
15391
|
+
node.templateAttrs.forEach(processAttribute);
|
|
15392
|
+
} else {
|
|
15393
|
+
node.inputs.forEach(processAttribute);
|
|
15394
|
+
node.attributes.forEach(processAttribute);
|
|
15395
|
+
}
|
|
15396
|
+
return boundInputs;
|
|
15397
|
+
}
|
|
15398
|
+
function checkSplitTwoWayBinding(inputName, output, inputs, tcb) {
|
|
15399
|
+
const input = inputs.find((input2) => input2.name === inputName);
|
|
15400
|
+
if (input === void 0 || input.sourceSpan !== output.sourceSpan) {
|
|
15401
|
+
return false;
|
|
15402
|
+
}
|
|
15403
|
+
const inputConsumer = tcb.boundTarget.getConsumerOfBinding(input);
|
|
15404
|
+
const outputConsumer = tcb.boundTarget.getConsumerOfBinding(output);
|
|
15405
|
+
if (outputConsumer === null || inputConsumer.ref === void 0 || outputConsumer instanceof TmplAstTemplate3) {
|
|
15406
|
+
return false;
|
|
15407
|
+
}
|
|
15408
|
+
if (outputConsumer instanceof TmplAstElement4) {
|
|
15409
|
+
tcb.oobRecorder.splitTwoWayBinding(tcb.id, input, output, inputConsumer.ref.node, outputConsumer);
|
|
15410
|
+
return true;
|
|
15411
|
+
} else if (outputConsumer.ref !== inputConsumer.ref) {
|
|
15412
|
+
tcb.oobRecorder.splitTwoWayBinding(tcb.id, input, output, inputConsumer.ref.node, outputConsumer.ref.node);
|
|
15413
|
+
return true;
|
|
15414
|
+
}
|
|
15415
|
+
return false;
|
|
15416
|
+
}
|
|
15417
|
+
function widenBinding(expr, tcb) {
|
|
15418
|
+
if (!tcb.env.config.checkTypeOfInputBindings) {
|
|
15419
|
+
return tsCastToAny(expr);
|
|
15420
|
+
} else if (!tcb.env.config.strictNullInputBindings) {
|
|
15421
|
+
if (ts74.isObjectLiteralExpression(expr) || ts74.isArrayLiteralExpression(expr)) {
|
|
15422
|
+
return expr;
|
|
15423
|
+
} else {
|
|
15424
|
+
return ts74.factory.createNonNullExpression(expr);
|
|
15425
|
+
}
|
|
15426
|
+
} else {
|
|
15427
|
+
return expr;
|
|
15428
|
+
}
|
|
15429
|
+
}
|
|
15430
|
+
|
|
15431
|
+
// packages/compiler-cli/src/ngtsc/typecheck/src/ops/inputs.js
|
|
15432
|
+
function translateInput(value, tcb, scope) {
|
|
15433
|
+
if (typeof value === "string") {
|
|
15434
|
+
return ts75.factory.createStringLiteral(value);
|
|
15435
|
+
} else {
|
|
15436
|
+
return tcbExpression(value, tcb, scope);
|
|
15437
|
+
}
|
|
15438
|
+
}
|
|
15439
|
+
var TcbDirectiveInputsOp = class extends TcbOp {
|
|
15440
|
+
tcb;
|
|
15441
|
+
scope;
|
|
15442
|
+
node;
|
|
15443
|
+
dir;
|
|
15444
|
+
customControlType;
|
|
15445
|
+
constructor(tcb, scope, node, dir, customControlType) {
|
|
15446
|
+
super();
|
|
15447
|
+
this.tcb = tcb;
|
|
15448
|
+
this.scope = scope;
|
|
15449
|
+
this.node = node;
|
|
15450
|
+
this.dir = dir;
|
|
15451
|
+
this.customControlType = customControlType;
|
|
15452
|
+
}
|
|
15453
|
+
get optional() {
|
|
15454
|
+
return false;
|
|
15455
|
+
}
|
|
15456
|
+
execute() {
|
|
15457
|
+
let dirId = null;
|
|
15458
|
+
const seenRequiredInputs = /* @__PURE__ */ new Set();
|
|
15459
|
+
const boundAttrs = getBoundAttributes(this.dir, this.node);
|
|
15460
|
+
if (this.customControlType !== null) {
|
|
15461
|
+
checkUnsupportedFieldBindings(this.node, customFormControlBannedInputFields, this.tcb);
|
|
15462
|
+
const additionalBindings = expandBoundAttributesForField(this.dir, this.node, this.customControlType);
|
|
15463
|
+
if (additionalBindings !== null) {
|
|
15464
|
+
boundAttrs.push(...additionalBindings);
|
|
15465
|
+
}
|
|
15466
|
+
}
|
|
15467
|
+
for (const attr of boundAttrs) {
|
|
15468
|
+
const expr = widenBinding(translateInput(attr.value, this.tcb, this.scope), this.tcb);
|
|
15469
|
+
let assignment = wrapForDiagnostics(expr);
|
|
15470
|
+
for (const { fieldName, required, transformType, isSignal, isTwoWayBinding } of attr.inputs) {
|
|
15471
|
+
let target;
|
|
15472
|
+
if (required) {
|
|
15473
|
+
seenRequiredInputs.add(fieldName);
|
|
15282
15474
|
}
|
|
15283
|
-
|
|
15284
|
-
|
|
15285
|
-
if (
|
|
15286
|
-
|
|
15475
|
+
if (this.dir.coercedInputFields.has(fieldName)) {
|
|
15476
|
+
let type;
|
|
15477
|
+
if (transformType !== null) {
|
|
15478
|
+
type = this.tcb.env.referenceTransplantedType(new TransplantedType(transformType));
|
|
15479
|
+
} else {
|
|
15480
|
+
const dirTypeRef = this.tcb.env.referenceType(this.dir.ref);
|
|
15481
|
+
if (!ts75.isTypeReferenceNode(dirTypeRef)) {
|
|
15482
|
+
throw new Error(`Expected TypeReferenceNode from reference to ${this.dir.ref.debugName}`);
|
|
15483
|
+
}
|
|
15484
|
+
type = tsCreateTypeQueryForCoercedInput(dirTypeRef.typeName, fieldName);
|
|
15485
|
+
}
|
|
15486
|
+
const id = this.tcb.allocateId();
|
|
15487
|
+
this.scope.addStatement(tsDeclareVariable(id, type));
|
|
15488
|
+
target = id;
|
|
15489
|
+
} else if (this.dir.undeclaredInputFields.has(fieldName)) {
|
|
15490
|
+
continue;
|
|
15491
|
+
} else if (!this.tcb.env.config.honorAccessModifiersForInputBindings && this.dir.restrictedInputFields.has(fieldName)) {
|
|
15492
|
+
if (dirId === null) {
|
|
15493
|
+
dirId = this.scope.resolve(this.node, this.dir);
|
|
15494
|
+
}
|
|
15495
|
+
const id = this.tcb.allocateId();
|
|
15496
|
+
const dirTypeRef = this.tcb.env.referenceType(this.dir.ref);
|
|
15497
|
+
if (!ts75.isTypeReferenceNode(dirTypeRef)) {
|
|
15498
|
+
throw new Error(`Expected TypeReferenceNode from reference to ${this.dir.ref.debugName}`);
|
|
15499
|
+
}
|
|
15500
|
+
const type = ts75.factory.createIndexedAccessTypeNode(ts75.factory.createTypeQueryNode(dirId), ts75.factory.createLiteralTypeNode(ts75.factory.createStringLiteral(fieldName)));
|
|
15501
|
+
const temp = tsDeclareVariable(id, type);
|
|
15502
|
+
this.scope.addStatement(temp);
|
|
15503
|
+
target = id;
|
|
15504
|
+
} else {
|
|
15505
|
+
if (dirId === null) {
|
|
15506
|
+
dirId = this.scope.resolve(this.node, this.dir);
|
|
15287
15507
|
}
|
|
15508
|
+
target = this.dir.stringLiteralInputFields.has(fieldName) ? ts75.factory.createElementAccessExpression(dirId, ts75.factory.createStringLiteral(fieldName)) : ts75.factory.createPropertyAccessExpression(dirId, ts75.factory.createIdentifier(fieldName));
|
|
15288
15509
|
}
|
|
15289
|
-
|
|
15290
|
-
|
|
15291
|
-
if (
|
|
15292
|
-
|
|
15510
|
+
if (isSignal) {
|
|
15511
|
+
const inputSignalBrandWriteSymbol = this.tcb.env.referenceExternalSymbol(R3Identifiers5.InputSignalBrandWriteType.moduleName, R3Identifiers5.InputSignalBrandWriteType.name);
|
|
15512
|
+
if (!ts75.isIdentifier(inputSignalBrandWriteSymbol) && !ts75.isPropertyAccessExpression(inputSignalBrandWriteSymbol)) {
|
|
15513
|
+
throw new Error(`Expected identifier or property access for reference to ${R3Identifiers5.InputSignalBrandWriteType.name}`);
|
|
15293
15514
|
}
|
|
15515
|
+
target = ts75.factory.createElementAccessExpression(target, inputSignalBrandWriteSymbol);
|
|
15516
|
+
}
|
|
15517
|
+
if (attr.keySpan !== null) {
|
|
15518
|
+
addParseSpanInfo(target, attr.keySpan);
|
|
15294
15519
|
}
|
|
15520
|
+
if (isTwoWayBinding && this.tcb.env.config.allowSignalsInTwoWayBindings) {
|
|
15521
|
+
assignment = unwrapWritableSignal(assignment, this.tcb);
|
|
15522
|
+
}
|
|
15523
|
+
assignment = ts75.factory.createBinaryExpression(target, ts75.SyntaxKind.EqualsToken, assignment);
|
|
15524
|
+
}
|
|
15525
|
+
addParseSpanInfo(assignment, attr.sourceSpan);
|
|
15526
|
+
if (!this.tcb.env.config.checkTypeOfAttributes && typeof attr.value === "string") {
|
|
15527
|
+
markIgnoreDiagnostics(assignment);
|
|
15295
15528
|
}
|
|
15529
|
+
this.scope.addStatement(ts75.factory.createExpressionStatement(assignment));
|
|
15296
15530
|
}
|
|
15297
|
-
|
|
15531
|
+
this.checkRequiredInputs(seenRequiredInputs);
|
|
15532
|
+
return null;
|
|
15298
15533
|
}
|
|
15299
|
-
|
|
15300
|
-
|
|
15301
|
-
|
|
15302
|
-
|
|
15303
|
-
|
|
15304
|
-
for (const child of node.children) {
|
|
15305
|
-
if (!(child instanceof TmplAstText) || this.tcb.hostPreserveWhitespaces || child.value.trim().length > 0) {
|
|
15306
|
-
if (hasSeenRootNode) {
|
|
15307
|
-
return true;
|
|
15308
|
-
}
|
|
15309
|
-
hasSeenRootNode = true;
|
|
15534
|
+
checkRequiredInputs(seenRequiredInputs) {
|
|
15535
|
+
const missing = [];
|
|
15536
|
+
for (const input of this.dir.inputs) {
|
|
15537
|
+
if (input.required && !seenRequiredInputs.has(input.classPropertyName)) {
|
|
15538
|
+
missing.push(input.bindingPropertyName);
|
|
15310
15539
|
}
|
|
15311
15540
|
}
|
|
15312
|
-
|
|
15541
|
+
if (missing.length > 0) {
|
|
15542
|
+
this.tcb.oobRecorder.missingRequiredInputs(this.tcb.id, this.node, this.dir.name, this.dir.isComponent, missing);
|
|
15543
|
+
}
|
|
15313
15544
|
}
|
|
15314
15545
|
};
|
|
15315
|
-
var
|
|
15546
|
+
var TcbUnclaimedInputsOp = class extends TcbOp {
|
|
15316
15547
|
tcb;
|
|
15317
15548
|
scope;
|
|
15318
|
-
|
|
15319
|
-
|
|
15320
|
-
|
|
15549
|
+
inputs;
|
|
15550
|
+
target;
|
|
15551
|
+
claimedInputs;
|
|
15552
|
+
constructor(tcb, scope, inputs, target, claimedInputs) {
|
|
15321
15553
|
super();
|
|
15322
15554
|
this.tcb = tcb;
|
|
15323
15555
|
this.scope = scope;
|
|
15324
|
-
this.
|
|
15556
|
+
this.inputs = inputs;
|
|
15557
|
+
this.target = target;
|
|
15558
|
+
this.claimedInputs = claimedInputs;
|
|
15559
|
+
}
|
|
15560
|
+
get optional() {
|
|
15561
|
+
return false;
|
|
15325
15562
|
}
|
|
15326
15563
|
execute() {
|
|
15327
|
-
|
|
15328
|
-
const
|
|
15329
|
-
|
|
15330
|
-
|
|
15331
|
-
|
|
15564
|
+
let elId = null;
|
|
15565
|
+
for (const binding of this.inputs) {
|
|
15566
|
+
const isPropertyBinding = binding.type === BindingType5.Property || binding.type === BindingType5.TwoWay;
|
|
15567
|
+
if (isPropertyBinding && this.claimedInputs?.has(binding.name)) {
|
|
15568
|
+
continue;
|
|
15569
|
+
}
|
|
15570
|
+
const expr = widenBinding(tcbExpression(binding.value, this.tcb, this.scope), this.tcb);
|
|
15571
|
+
if (this.tcb.env.config.checkTypeOfDomBindings && isPropertyBinding) {
|
|
15572
|
+
if (binding.name !== "style" && binding.name !== "class") {
|
|
15573
|
+
if (elId === null) {
|
|
15574
|
+
elId = this.scope.resolve(this.target);
|
|
15575
|
+
}
|
|
15576
|
+
const propertyName = REGISTRY.getMappedPropName(binding.name);
|
|
15577
|
+
const prop = ts75.factory.createElementAccessExpression(elId, ts75.factory.createStringLiteral(propertyName));
|
|
15578
|
+
const stmt = ts75.factory.createBinaryExpression(prop, ts75.SyntaxKind.EqualsToken, wrapForDiagnostics(expr));
|
|
15579
|
+
addParseSpanInfo(stmt, binding.sourceSpan);
|
|
15580
|
+
this.scope.addStatement(ts75.factory.createExpressionStatement(stmt));
|
|
15581
|
+
} else {
|
|
15582
|
+
this.scope.addStatement(ts75.factory.createExpressionStatement(expr));
|
|
15583
|
+
}
|
|
15584
|
+
} else {
|
|
15585
|
+
this.scope.addStatement(ts75.factory.createExpressionStatement(expr));
|
|
15586
|
+
}
|
|
15587
|
+
}
|
|
15588
|
+
return null;
|
|
15332
15589
|
}
|
|
15333
15590
|
};
|
|
15591
|
+
|
|
15592
|
+
// packages/compiler-cli/src/ngtsc/typecheck/src/ops/schema.js
|
|
15593
|
+
import { BindingType as BindingType6, TmplAstComponent as TmplAstComponent2, TmplAstElement as TmplAstElement5 } from "@angular/compiler";
|
|
15594
|
+
|
|
15595
|
+
// packages/compiler-cli/src/ngtsc/typecheck/src/ops/selectorless.js
|
|
15596
|
+
function getComponentTagName(node) {
|
|
15597
|
+
return node.tagName || "ng-component";
|
|
15598
|
+
}
|
|
15334
15599
|
var TcbComponentNodeOp = class extends TcbOp {
|
|
15335
15600
|
tcb;
|
|
15336
15601
|
scope;
|
|
@@ -15350,51 +15615,59 @@ var TcbComponentNodeOp = class extends TcbOp {
|
|
|
15350
15615
|
return id;
|
|
15351
15616
|
}
|
|
15352
15617
|
};
|
|
15353
|
-
|
|
15618
|
+
|
|
15619
|
+
// packages/compiler-cli/src/ngtsc/typecheck/src/ops/schema.js
|
|
15620
|
+
var TcbDomSchemaCheckerOp = class extends TcbOp {
|
|
15354
15621
|
tcb;
|
|
15355
|
-
|
|
15356
|
-
|
|
15357
|
-
target;
|
|
15622
|
+
element;
|
|
15623
|
+
checkElement;
|
|
15358
15624
|
claimedInputs;
|
|
15359
|
-
constructor(tcb,
|
|
15625
|
+
constructor(tcb, element, checkElement, claimedInputs) {
|
|
15360
15626
|
super();
|
|
15361
15627
|
this.tcb = tcb;
|
|
15362
|
-
this.
|
|
15363
|
-
this.
|
|
15364
|
-
this.target = target;
|
|
15628
|
+
this.element = element;
|
|
15629
|
+
this.checkElement = checkElement;
|
|
15365
15630
|
this.claimedInputs = claimedInputs;
|
|
15366
15631
|
}
|
|
15367
15632
|
get optional() {
|
|
15368
15633
|
return false;
|
|
15369
15634
|
}
|
|
15370
15635
|
execute() {
|
|
15371
|
-
|
|
15372
|
-
|
|
15373
|
-
|
|
15636
|
+
const element = this.element;
|
|
15637
|
+
const isTemplateElement = element instanceof TmplAstElement5 || element instanceof TmplAstComponent2;
|
|
15638
|
+
const bindings = isTemplateElement ? element.inputs : element.bindings;
|
|
15639
|
+
if (this.checkElement && isTemplateElement) {
|
|
15640
|
+
this.tcb.domSchemaChecker.checkElement(this.tcb.id, this.getTagName(element), element.startSourceSpan, this.tcb.schemas, this.tcb.hostIsStandalone);
|
|
15641
|
+
}
|
|
15642
|
+
for (const binding of bindings) {
|
|
15643
|
+
const isPropertyBinding = binding.type === BindingType6.Property || binding.type === BindingType6.TwoWay;
|
|
15374
15644
|
if (isPropertyBinding && this.claimedInputs?.has(binding.name)) {
|
|
15375
15645
|
continue;
|
|
15376
15646
|
}
|
|
15377
|
-
|
|
15378
|
-
|
|
15379
|
-
if (
|
|
15380
|
-
|
|
15381
|
-
elId = this.scope.resolve(this.target);
|
|
15382
|
-
}
|
|
15383
|
-
const propertyName = REGISTRY.getMappedPropName(binding.name);
|
|
15384
|
-
const prop = ts62.factory.createElementAccessExpression(elId, ts62.factory.createStringLiteral(propertyName));
|
|
15385
|
-
const stmt = ts62.factory.createBinaryExpression(prop, ts62.SyntaxKind.EqualsToken, wrapForDiagnostics(expr));
|
|
15386
|
-
addParseSpanInfo(stmt, binding.sourceSpan);
|
|
15387
|
-
this.scope.addStatement(ts62.factory.createExpressionStatement(stmt));
|
|
15647
|
+
if (isPropertyBinding && binding.name !== "style" && binding.name !== "class") {
|
|
15648
|
+
const propertyName = REGISTRY.getMappedPropName(binding.name);
|
|
15649
|
+
if (isTemplateElement) {
|
|
15650
|
+
this.tcb.domSchemaChecker.checkTemplateElementProperty(this.tcb.id, this.getTagName(element), propertyName, binding.sourceSpan, this.tcb.schemas, this.tcb.hostIsStandalone);
|
|
15388
15651
|
} else {
|
|
15389
|
-
this.
|
|
15652
|
+
this.tcb.domSchemaChecker.checkHostElementProperty(this.tcb.id, element, propertyName, binding.keySpan, this.tcb.schemas);
|
|
15390
15653
|
}
|
|
15391
|
-
} else {
|
|
15392
|
-
this.scope.addStatement(ts62.factory.createExpressionStatement(expr));
|
|
15393
15654
|
}
|
|
15394
15655
|
}
|
|
15395
15656
|
return null;
|
|
15396
15657
|
}
|
|
15658
|
+
getTagName(node) {
|
|
15659
|
+
return node instanceof TmplAstElement5 ? node.name : getComponentTagName(node);
|
|
15660
|
+
}
|
|
15397
15661
|
};
|
|
15662
|
+
|
|
15663
|
+
// packages/compiler-cli/src/ngtsc/typecheck/src/ops/events.js
|
|
15664
|
+
import { ImplicitReceiver as ImplicitReceiver5, ParsedEventType as ParsedEventType2, PropertyRead as PropertyRead7, ThisReceiver as ThisReceiver3, TmplAstElement as TmplAstElement6 } from "@angular/compiler";
|
|
15665
|
+
import ts76 from "typescript";
|
|
15666
|
+
var EVENT_PARAMETER = "$event";
|
|
15667
|
+
function tcbEventHandlerExpression(ast, tcb, scope) {
|
|
15668
|
+
const translator = new TcbEventHandlerTranslator(tcb, scope);
|
|
15669
|
+
return translator.translate(ast);
|
|
15670
|
+
}
|
|
15398
15671
|
var TcbDirectiveOutputsOp = class extends TcbOp {
|
|
15399
15672
|
tcb;
|
|
15400
15673
|
scope;
|
|
@@ -15429,7 +15702,7 @@ var TcbDirectiveOutputsOp = class extends TcbOp {
|
|
|
15429
15702
|
if (dirId === null) {
|
|
15430
15703
|
dirId = this.scope.resolve(this.node, this.dir);
|
|
15431
15704
|
}
|
|
15432
|
-
const outputField =
|
|
15705
|
+
const outputField = ts76.factory.createElementAccessExpression(dirId, ts76.factory.createStringLiteral(field));
|
|
15433
15706
|
addParseSpanInfo(outputField, output.keySpan);
|
|
15434
15707
|
if (this.tcb.env.config.checkTypeOfOutputEvents) {
|
|
15435
15708
|
const handler = tcbCreateEventHandler(
|
|
@@ -15439,8 +15712,8 @@ var TcbDirectiveOutputsOp = class extends TcbOp {
|
|
|
15439
15712
|
0
|
|
15440
15713
|
/* EventParamType.Infer */
|
|
15441
15714
|
);
|
|
15442
|
-
const subscribeFn =
|
|
15443
|
-
const call =
|
|
15715
|
+
const subscribeFn = ts76.factory.createPropertyAccessExpression(outputField, "subscribe");
|
|
15716
|
+
const call = ts76.factory.createCallExpression(
|
|
15444
15717
|
subscribeFn,
|
|
15445
15718
|
/* typeArguments */
|
|
15446
15719
|
void 0,
|
|
@@ -15449,9 +15722,9 @@ var TcbDirectiveOutputsOp = class extends TcbOp {
|
|
|
15449
15722
|
]
|
|
15450
15723
|
);
|
|
15451
15724
|
addParseSpanInfo(call, output.sourceSpan);
|
|
15452
|
-
this.scope.addStatement(
|
|
15725
|
+
this.scope.addStatement(ts76.factory.createExpressionStatement(call));
|
|
15453
15726
|
} else {
|
|
15454
|
-
this.scope.addStatement(
|
|
15727
|
+
this.scope.addStatement(ts76.factory.createExpressionStatement(outputField));
|
|
15455
15728
|
const handler = tcbCreateEventHandler(
|
|
15456
15729
|
output,
|
|
15457
15730
|
this.tcb,
|
|
@@ -15459,7 +15732,7 @@ var TcbDirectiveOutputsOp = class extends TcbOp {
|
|
|
15459
15732
|
1
|
|
15460
15733
|
/* EventParamType.Any */
|
|
15461
15734
|
);
|
|
15462
|
-
this.scope.addStatement(
|
|
15735
|
+
this.scope.addStatement(ts76.factory.createExpressionStatement(handler));
|
|
15463
15736
|
}
|
|
15464
15737
|
}
|
|
15465
15738
|
return null;
|
|
@@ -15499,39 +15772,39 @@ var TcbUnclaimedOutputsOp = class extends TcbOp {
|
|
|
15499
15772
|
if (output.type === ParsedEventType2.LegacyAnimation) {
|
|
15500
15773
|
const eventType = this.tcb.env.config.checkTypeOfAnimationEvents ? this.tcb.env.referenceExternalType("@angular/animations", "AnimationEvent") : 1;
|
|
15501
15774
|
const handler = tcbCreateEventHandler(output, this.tcb, this.scope, eventType);
|
|
15502
|
-
this.scope.addStatement(
|
|
15775
|
+
this.scope.addStatement(ts76.factory.createExpressionStatement(handler));
|
|
15503
15776
|
} else if (output.type === ParsedEventType2.Animation) {
|
|
15504
15777
|
const eventType = this.tcb.env.referenceExternalType("@angular/core", "AnimationCallbackEvent");
|
|
15505
15778
|
const handler = tcbCreateEventHandler(output, this.tcb, this.scope, eventType);
|
|
15506
|
-
this.scope.addStatement(
|
|
15779
|
+
this.scope.addStatement(ts76.factory.createExpressionStatement(handler));
|
|
15507
15780
|
} else if (this.tcb.env.config.checkTypeOfDomEvents) {
|
|
15508
15781
|
let target;
|
|
15509
15782
|
let domEventAssertion;
|
|
15510
15783
|
if (output.target === "window" || output.target === "document") {
|
|
15511
|
-
target =
|
|
15784
|
+
target = ts76.factory.createIdentifier(output.target);
|
|
15512
15785
|
} else if (elId === null) {
|
|
15513
15786
|
target = elId = this.scope.resolve(this.target);
|
|
15514
15787
|
} else {
|
|
15515
15788
|
target = elId;
|
|
15516
15789
|
}
|
|
15517
|
-
if (this.target instanceof
|
|
15518
|
-
domEventAssertion =
|
|
15519
|
-
|
|
15790
|
+
if (this.target instanceof TmplAstElement6 && this.target.isVoid && ts76.isIdentifier(target) && this.tcb.env.config.allowDomEventAssertion) {
|
|
15791
|
+
domEventAssertion = ts76.factory.createCallExpression(this.tcb.env.referenceExternalSymbol("@angular/core", "\u0275assertType"), [ts76.factory.createTypeQueryNode(target)], [
|
|
15792
|
+
ts76.factory.createPropertyAccessExpression(ts76.factory.createIdentifier(EVENT_PARAMETER), "target")
|
|
15520
15793
|
]);
|
|
15521
15794
|
}
|
|
15522
|
-
const propertyAccess =
|
|
15795
|
+
const propertyAccess = ts76.factory.createPropertyAccessExpression(target, "addEventListener");
|
|
15523
15796
|
addParseSpanInfo(propertyAccess, output.keySpan);
|
|
15524
15797
|
const handler = tcbCreateEventHandler(output, this.tcb, this.scope, 0, domEventAssertion);
|
|
15525
|
-
const call =
|
|
15798
|
+
const call = ts76.factory.createCallExpression(
|
|
15526
15799
|
/* expression */
|
|
15527
15800
|
propertyAccess,
|
|
15528
15801
|
/* typeArguments */
|
|
15529
15802
|
void 0,
|
|
15530
15803
|
/* arguments */
|
|
15531
|
-
[
|
|
15804
|
+
[ts76.factory.createStringLiteral(output.name), handler]
|
|
15532
15805
|
);
|
|
15533
15806
|
addParseSpanInfo(call, output.sourceSpan);
|
|
15534
|
-
this.scope.addStatement(
|
|
15807
|
+
this.scope.addStatement(ts76.factory.createExpressionStatement(call));
|
|
15535
15808
|
} else {
|
|
15536
15809
|
const handler = tcbCreateEventHandler(
|
|
15537
15810
|
output,
|
|
@@ -15540,218 +15813,355 @@ var TcbUnclaimedOutputsOp = class extends TcbOp {
|
|
|
15540
15813
|
1
|
|
15541
15814
|
/* EventParamType.Any */
|
|
15542
15815
|
);
|
|
15543
|
-
this.scope.addStatement(
|
|
15816
|
+
this.scope.addStatement(ts76.factory.createExpressionStatement(handler));
|
|
15544
15817
|
}
|
|
15545
15818
|
}
|
|
15546
15819
|
return null;
|
|
15547
15820
|
}
|
|
15548
15821
|
};
|
|
15549
|
-
var
|
|
15550
|
-
|
|
15551
|
-
|
|
15552
|
-
|
|
15553
|
-
|
|
15822
|
+
var TcbEventHandlerTranslator = class extends TcbExpressionTranslator {
|
|
15823
|
+
resolve(ast) {
|
|
15824
|
+
if (ast instanceof PropertyRead7 && ast.receiver instanceof ImplicitReceiver5 && !(ast.receiver instanceof ThisReceiver3) && ast.name === EVENT_PARAMETER) {
|
|
15825
|
+
const event = ts76.factory.createIdentifier(EVENT_PARAMETER);
|
|
15826
|
+
addParseSpanInfo(event, ast.nameSpan);
|
|
15827
|
+
return event;
|
|
15828
|
+
}
|
|
15829
|
+
return super.resolve(ast);
|
|
15554
15830
|
}
|
|
15555
|
-
|
|
15556
|
-
|
|
15557
|
-
const ctx = ts62.factory.createThis();
|
|
15558
|
-
const ctxDot = ts62.factory.createPropertyAccessExpression(ctx, "");
|
|
15559
|
-
markIgnoreDiagnostics(ctxDot);
|
|
15560
|
-
addExpressionIdentifier(ctxDot, ExpressionIdentifier.COMPONENT_COMPLETION);
|
|
15561
|
-
this.scope.addStatement(ts62.factory.createExpressionStatement(ctxDot));
|
|
15562
|
-
return null;
|
|
15831
|
+
isValidLetDeclarationAccess() {
|
|
15832
|
+
return true;
|
|
15563
15833
|
}
|
|
15564
15834
|
};
|
|
15565
|
-
|
|
15835
|
+
function tcbCreateEventHandler(event, tcb, scope, eventType, assertionExpression) {
|
|
15836
|
+
const handler = tcbEventHandlerExpression(event.handler, tcb, scope);
|
|
15837
|
+
const statements = [];
|
|
15838
|
+
if (assertionExpression !== void 0) {
|
|
15839
|
+
statements.push(ts76.factory.createExpressionStatement(assertionExpression));
|
|
15840
|
+
}
|
|
15841
|
+
if (event.type === ParsedEventType2.TwoWay && tcb.env.config.checkTwoWayBoundEvents) {
|
|
15842
|
+
const target = tcb.allocateId();
|
|
15843
|
+
const assignment = ts76.factory.createBinaryExpression(target, ts76.SyntaxKind.EqualsToken, ts76.factory.createIdentifier(EVENT_PARAMETER));
|
|
15844
|
+
statements.push(tsCreateVariable(target, tcb.env.config.allowSignalsInTwoWayBindings ? unwrapWritableSignal(handler, tcb) : handler), ts76.factory.createExpressionStatement(assignment));
|
|
15845
|
+
} else {
|
|
15846
|
+
statements.push(ts76.factory.createExpressionStatement(handler));
|
|
15847
|
+
}
|
|
15848
|
+
let eventParamType;
|
|
15849
|
+
if (eventType === 0) {
|
|
15850
|
+
eventParamType = void 0;
|
|
15851
|
+
} else if (eventType === 1) {
|
|
15852
|
+
eventParamType = ts76.factory.createKeywordTypeNode(ts76.SyntaxKind.AnyKeyword);
|
|
15853
|
+
} else {
|
|
15854
|
+
eventParamType = eventType;
|
|
15855
|
+
}
|
|
15856
|
+
const guards = scope.guards();
|
|
15857
|
+
let body = ts76.factory.createBlock(statements);
|
|
15858
|
+
if (guards !== null) {
|
|
15859
|
+
body = ts76.factory.createBlock([ts76.factory.createIfStatement(guards, body)]);
|
|
15860
|
+
}
|
|
15861
|
+
const eventParam = ts76.factory.createParameterDeclaration(
|
|
15862
|
+
/* modifiers */
|
|
15863
|
+
void 0,
|
|
15864
|
+
/* dotDotDotToken */
|
|
15865
|
+
void 0,
|
|
15866
|
+
/* name */
|
|
15867
|
+
EVENT_PARAMETER,
|
|
15868
|
+
/* questionToken */
|
|
15869
|
+
void 0,
|
|
15870
|
+
/* type */
|
|
15871
|
+
eventParamType
|
|
15872
|
+
);
|
|
15873
|
+
addExpressionIdentifier(eventParam, ExpressionIdentifier.EVENT_PARAMETER);
|
|
15874
|
+
return ts76.factory.createArrowFunction(
|
|
15875
|
+
/* modifiers */
|
|
15876
|
+
void 0,
|
|
15877
|
+
/* typeParameters */
|
|
15878
|
+
void 0,
|
|
15879
|
+
/* parameters */
|
|
15880
|
+
[eventParam],
|
|
15881
|
+
/* type */
|
|
15882
|
+
ts76.factory.createKeywordTypeNode(ts76.SyntaxKind.AnyKeyword),
|
|
15883
|
+
/* equalsGreaterThanToken */
|
|
15884
|
+
void 0,
|
|
15885
|
+
/* body */
|
|
15886
|
+
body
|
|
15887
|
+
);
|
|
15888
|
+
}
|
|
15889
|
+
|
|
15890
|
+
// packages/compiler-cli/src/ngtsc/typecheck/src/ops/directive_type.js
|
|
15891
|
+
import { TmplAstHostElement as TmplAstHostElement3 } from "@angular/compiler";
|
|
15892
|
+
import ts77 from "typescript";
|
|
15893
|
+
var TcbDirectiveTypeOpBase = class extends TcbOp {
|
|
15566
15894
|
tcb;
|
|
15567
15895
|
scope;
|
|
15568
|
-
|
|
15569
|
-
|
|
15570
|
-
constructor(tcb, scope,
|
|
15896
|
+
node;
|
|
15897
|
+
dir;
|
|
15898
|
+
constructor(tcb, scope, node, dir) {
|
|
15571
15899
|
super();
|
|
15572
15900
|
this.tcb = tcb;
|
|
15573
15901
|
this.scope = scope;
|
|
15574
|
-
this.
|
|
15575
|
-
this.
|
|
15902
|
+
this.node = node;
|
|
15903
|
+
this.dir = dir;
|
|
15576
15904
|
}
|
|
15577
15905
|
get optional() {
|
|
15578
|
-
return
|
|
15906
|
+
return true;
|
|
15579
15907
|
}
|
|
15580
15908
|
execute() {
|
|
15581
|
-
const
|
|
15582
|
-
|
|
15583
|
-
|
|
15584
|
-
|
|
15585
|
-
this.
|
|
15909
|
+
const dirRef = this.dir.ref;
|
|
15910
|
+
const rawType = this.tcb.env.referenceType(this.dir.ref);
|
|
15911
|
+
let type;
|
|
15912
|
+
let span;
|
|
15913
|
+
if (this.dir.isGeneric === false || dirRef.node.typeParameters === void 0) {
|
|
15914
|
+
type = rawType;
|
|
15915
|
+
} else {
|
|
15916
|
+
if (!ts77.isTypeReferenceNode(rawType)) {
|
|
15917
|
+
throw new Error(`Expected TypeReferenceNode when referencing the type for ${this.dir.ref.debugName}`);
|
|
15918
|
+
}
|
|
15919
|
+
const typeArguments = dirRef.node.typeParameters.map(() => ts77.factory.createKeywordTypeNode(ts77.SyntaxKind.AnyKeyword));
|
|
15920
|
+
type = ts77.factory.createTypeReferenceNode(rawType.typeName, typeArguments);
|
|
15921
|
+
}
|
|
15922
|
+
if (this.node instanceof TmplAstHostElement3) {
|
|
15923
|
+
span = this.node.sourceSpan;
|
|
15924
|
+
} else {
|
|
15925
|
+
span = this.node.startSourceSpan || this.node.sourceSpan;
|
|
15926
|
+
}
|
|
15927
|
+
const id = this.tcb.allocateId();
|
|
15928
|
+
addExpressionIdentifier(id, ExpressionIdentifier.DIRECTIVE);
|
|
15929
|
+
addParseSpanInfo(id, span);
|
|
15930
|
+
this.scope.addStatement(tsDeclareVariable(id, type));
|
|
15586
15931
|
return id;
|
|
15587
15932
|
}
|
|
15588
15933
|
};
|
|
15589
|
-
var
|
|
15590
|
-
|
|
15591
|
-
|
|
15592
|
-
|
|
15593
|
-
|
|
15594
|
-
|
|
15595
|
-
|
|
15596
|
-
this.
|
|
15597
|
-
|
|
15598
|
-
|
|
15599
|
-
|
|
15934
|
+
var TcbNonGenericDirectiveTypeOp = class extends TcbDirectiveTypeOpBase {
|
|
15935
|
+
/**
|
|
15936
|
+
* Creates a variable declaration for this op's directive of the argument type. Returns the id of
|
|
15937
|
+
* the newly created variable.
|
|
15938
|
+
*/
|
|
15939
|
+
execute() {
|
|
15940
|
+
const dirRef = this.dir.ref;
|
|
15941
|
+
if (this.dir.isGeneric) {
|
|
15942
|
+
throw new Error(`Assertion Error: expected ${dirRef.debugName} not to be generic.`);
|
|
15943
|
+
}
|
|
15944
|
+
return super.execute();
|
|
15600
15945
|
}
|
|
15601
|
-
|
|
15946
|
+
};
|
|
15947
|
+
var TcbGenericDirectiveTypeWithAnyParamsOp = class extends TcbDirectiveTypeOpBase {
|
|
15602
15948
|
execute() {
|
|
15603
|
-
const
|
|
15604
|
-
|
|
15605
|
-
|
|
15606
|
-
|
|
15607
|
-
|
|
15608
|
-
return id;
|
|
15949
|
+
const dirRef = this.dir.ref;
|
|
15950
|
+
if (dirRef.node.typeParameters === void 0) {
|
|
15951
|
+
throw new Error(`Assertion Error: expected typeParameters when creating a declaration for ${dirRef.debugName}`);
|
|
15952
|
+
}
|
|
15953
|
+
return super.execute();
|
|
15609
15954
|
}
|
|
15610
15955
|
};
|
|
15611
|
-
|
|
15956
|
+
|
|
15957
|
+
// packages/compiler-cli/src/ngtsc/typecheck/src/ops/directive_constructor.js
|
|
15958
|
+
import { TmplAstHostElement as TmplAstHostElement4 } from "@angular/compiler";
|
|
15959
|
+
import ts78 from "typescript";
|
|
15960
|
+
var TcbDirectiveCtorOp = class extends TcbOp {
|
|
15612
15961
|
tcb;
|
|
15613
15962
|
scope;
|
|
15614
|
-
|
|
15615
|
-
|
|
15616
|
-
|
|
15963
|
+
node;
|
|
15964
|
+
dir;
|
|
15965
|
+
customControlType;
|
|
15966
|
+
constructor(tcb, scope, node, dir, customControlType) {
|
|
15617
15967
|
super();
|
|
15618
15968
|
this.tcb = tcb;
|
|
15619
15969
|
this.scope = scope;
|
|
15620
|
-
this.
|
|
15970
|
+
this.node = node;
|
|
15971
|
+
this.dir = dir;
|
|
15972
|
+
this.customControlType = customControlType;
|
|
15621
15973
|
}
|
|
15622
15974
|
get optional() {
|
|
15623
|
-
return
|
|
15975
|
+
return true;
|
|
15624
15976
|
}
|
|
15625
15977
|
execute() {
|
|
15626
|
-
const
|
|
15627
|
-
|
|
15628
|
-
|
|
15629
|
-
|
|
15630
|
-
|
|
15631
|
-
|
|
15632
|
-
|
|
15633
|
-
|
|
15634
|
-
|
|
15635
|
-
|
|
15636
|
-
|
|
15637
|
-
|
|
15638
|
-
|
|
15639
|
-
|
|
15640
|
-
|
|
15641
|
-
|
|
15642
|
-
let expression = tcbExpression(branch.expression, this.tcb, this.scope);
|
|
15643
|
-
if (branch.expressionAlias !== null) {
|
|
15644
|
-
expression = ts62.factory.createBinaryExpression(ts62.factory.createParenthesizedExpression(expression), ts62.SyntaxKind.AmpersandAmpersandToken, outerScope.resolve(branch.expressionAlias));
|
|
15978
|
+
const genericInputs = /* @__PURE__ */ new Map();
|
|
15979
|
+
const id = this.tcb.allocateId();
|
|
15980
|
+
let boundAttrs;
|
|
15981
|
+
let span;
|
|
15982
|
+
if (this.node instanceof TmplAstHostElement4) {
|
|
15983
|
+
boundAttrs = [];
|
|
15984
|
+
span = this.node.sourceSpan;
|
|
15985
|
+
} else {
|
|
15986
|
+
span = this.node.startSourceSpan || this.node.sourceSpan;
|
|
15987
|
+
boundAttrs = getBoundAttributes(this.dir, this.node);
|
|
15988
|
+
if (this.customControlType !== null) {
|
|
15989
|
+
const additionalBindings = expandBoundAttributesForField(this.dir, this.node, this.customControlType);
|
|
15990
|
+
if (additionalBindings !== null) {
|
|
15991
|
+
boundAttrs.push(...additionalBindings);
|
|
15992
|
+
}
|
|
15993
|
+
}
|
|
15645
15994
|
}
|
|
15646
|
-
|
|
15647
|
-
|
|
15648
|
-
|
|
15649
|
-
|
|
15650
|
-
const checkBody = this.tcb.env.config.checkControlFlowBodies;
|
|
15651
|
-
return Scope.forNodes(this.tcb, parentScope, null, checkBody ? branch.children : [], checkBody ? this.generateBranchGuard(index) : null);
|
|
15652
|
-
}
|
|
15653
|
-
generateBranchGuard(index) {
|
|
15654
|
-
let guard = null;
|
|
15655
|
-
for (let i = 0; i <= index; i++) {
|
|
15656
|
-
const branch = this.block.branches[i];
|
|
15657
|
-
if (branch.expression === null) {
|
|
15995
|
+
addExpressionIdentifier(id, ExpressionIdentifier.DIRECTIVE);
|
|
15996
|
+
addParseSpanInfo(id, span);
|
|
15997
|
+
for (const attr of boundAttrs) {
|
|
15998
|
+
if (!this.tcb.env.config.checkTypeOfAttributes && typeof attr.value === "string") {
|
|
15658
15999
|
continue;
|
|
15659
16000
|
}
|
|
15660
|
-
|
|
15661
|
-
|
|
16001
|
+
for (const { fieldName, isTwoWayBinding } of attr.inputs) {
|
|
16002
|
+
if (genericInputs.has(fieldName)) {
|
|
16003
|
+
continue;
|
|
16004
|
+
}
|
|
16005
|
+
const expression = translateInput(attr.value, this.tcb, this.scope);
|
|
16006
|
+
genericInputs.set(fieldName, {
|
|
16007
|
+
type: "binding",
|
|
16008
|
+
field: fieldName,
|
|
16009
|
+
expression,
|
|
16010
|
+
sourceSpan: attr.sourceSpan,
|
|
16011
|
+
isTwoWayBinding
|
|
16012
|
+
});
|
|
15662
16013
|
}
|
|
15663
|
-
|
|
15664
|
-
|
|
15665
|
-
|
|
15666
|
-
|
|
15667
|
-
expression = ts62.factory.createBinaryExpression(ts62.factory.createParenthesizedExpression(expression), ts62.SyntaxKind.AmpersandAmpersandToken, expressionScope.resolve(branch.expressionAlias));
|
|
16014
|
+
}
|
|
16015
|
+
for (const { classPropertyName } of this.dir.inputs) {
|
|
16016
|
+
if (!genericInputs.has(classPropertyName)) {
|
|
16017
|
+
genericInputs.set(classPropertyName, { type: "unset", field: classPropertyName });
|
|
15668
16018
|
}
|
|
15669
|
-
markIgnoreDiagnostics(expression);
|
|
15670
|
-
const comparisonExpression = i === index ? expression : ts62.factory.createPrefixUnaryExpression(ts62.SyntaxKind.ExclamationToken, ts62.factory.createParenthesizedExpression(expression));
|
|
15671
|
-
guard = guard === null ? comparisonExpression : ts62.factory.createBinaryExpression(guard, ts62.SyntaxKind.AmpersandAmpersandToken, comparisonExpression);
|
|
15672
16019
|
}
|
|
15673
|
-
|
|
16020
|
+
const typeCtor = tcbCallTypeCtor(this.dir, this.tcb, Array.from(genericInputs.values()));
|
|
16021
|
+
markIgnoreDiagnostics(typeCtor);
|
|
16022
|
+
this.scope.addStatement(tsCreateVariable(id, typeCtor));
|
|
16023
|
+
return id;
|
|
16024
|
+
}
|
|
16025
|
+
circularFallback() {
|
|
16026
|
+
return new TcbDirectiveCtorCircularFallbackOp(this.tcb, this.scope, this.dir);
|
|
15674
16027
|
}
|
|
15675
16028
|
};
|
|
15676
|
-
var
|
|
16029
|
+
var TcbDirectiveCtorCircularFallbackOp = class extends TcbOp {
|
|
15677
16030
|
tcb;
|
|
15678
16031
|
scope;
|
|
15679
|
-
|
|
15680
|
-
constructor(tcb, scope,
|
|
16032
|
+
dir;
|
|
16033
|
+
constructor(tcb, scope, dir) {
|
|
15681
16034
|
super();
|
|
15682
16035
|
this.tcb = tcb;
|
|
15683
16036
|
this.scope = scope;
|
|
15684
|
-
this.
|
|
16037
|
+
this.dir = dir;
|
|
15685
16038
|
}
|
|
15686
16039
|
get optional() {
|
|
15687
16040
|
return false;
|
|
15688
16041
|
}
|
|
15689
16042
|
execute() {
|
|
15690
|
-
const
|
|
15691
|
-
const
|
|
15692
|
-
|
|
15693
|
-
|
|
15694
|
-
|
|
15695
|
-
|
|
15696
|
-
|
|
15697
|
-
|
|
15698
|
-
|
|
16043
|
+
const id = this.tcb.allocateId();
|
|
16044
|
+
const typeCtor = this.tcb.env.typeCtorFor(this.dir);
|
|
16045
|
+
const circularPlaceholder = ts78.factory.createCallExpression(
|
|
16046
|
+
typeCtor,
|
|
16047
|
+
/* typeArguments */
|
|
16048
|
+
void 0,
|
|
16049
|
+
[ts78.factory.createNonNullExpression(ts78.factory.createNull())]
|
|
16050
|
+
);
|
|
16051
|
+
this.scope.addStatement(tsCreateVariable(id, circularPlaceholder));
|
|
16052
|
+
return id;
|
|
15699
16053
|
}
|
|
15700
|
-
|
|
15701
|
-
|
|
15702
|
-
|
|
15703
|
-
|
|
15704
|
-
|
|
15705
|
-
|
|
15706
|
-
|
|
15707
|
-
|
|
15708
|
-
|
|
15709
|
-
continue;
|
|
15710
|
-
}
|
|
15711
|
-
const expression = tcbExpression(current.expression, this.tcb, this.scope);
|
|
15712
|
-
markIgnoreDiagnostics(expression);
|
|
15713
|
-
const comparison = ts62.factory.createBinaryExpression(switchValue, ts62.SyntaxKind.ExclamationEqualsEqualsToken, expression);
|
|
15714
|
-
if (guard === null) {
|
|
15715
|
-
guard = comparison;
|
|
15716
|
-
} else {
|
|
15717
|
-
guard = ts62.factory.createBinaryExpression(guard, ts62.SyntaxKind.AmpersandAmpersandToken, comparison);
|
|
16054
|
+
};
|
|
16055
|
+
function tcbCallTypeCtor(dir, tcb, inputs) {
|
|
16056
|
+
const typeCtor = tcb.env.typeCtorFor(dir);
|
|
16057
|
+
const members = inputs.map((input) => {
|
|
16058
|
+
const propertyName = ts78.factory.createStringLiteral(input.field);
|
|
16059
|
+
if (input.type === "binding") {
|
|
16060
|
+
let expr = widenBinding(input.expression, tcb);
|
|
16061
|
+
if (input.isTwoWayBinding && tcb.env.config.allowSignalsInTwoWayBindings) {
|
|
16062
|
+
expr = unwrapWritableSignal(expr, tcb);
|
|
15718
16063
|
}
|
|
16064
|
+
const assignment = ts78.factory.createPropertyAssignment(propertyName, wrapForDiagnostics(expr));
|
|
16065
|
+
addParseSpanInfo(assignment, input.sourceSpan);
|
|
16066
|
+
return assignment;
|
|
16067
|
+
} else {
|
|
16068
|
+
return ts78.factory.createPropertyAssignment(propertyName, getAnyExpression());
|
|
15719
16069
|
}
|
|
15720
|
-
|
|
15721
|
-
|
|
15722
|
-
|
|
15723
|
-
|
|
16070
|
+
});
|
|
16071
|
+
return ts78.factory.createCallExpression(
|
|
16072
|
+
/* expression */
|
|
16073
|
+
typeCtor,
|
|
16074
|
+
/* typeArguments */
|
|
16075
|
+
void 0,
|
|
16076
|
+
/* argumentsArray */
|
|
16077
|
+
[ts78.factory.createObjectLiteralExpression(members)]
|
|
16078
|
+
);
|
|
16079
|
+
}
|
|
16080
|
+
|
|
16081
|
+
// packages/compiler-cli/src/ngtsc/typecheck/src/ops/content_projection.js
|
|
16082
|
+
import { createCssSelectorFromNode, CssSelector as CssSelector3, SelectorMatcher as SelectorMatcher2, TmplAstElement as TmplAstElement7, TmplAstForLoopBlock, TmplAstIfBlock, TmplAstSwitchBlock, TmplAstTemplate as TmplAstTemplate4, TmplAstText } from "@angular/compiler";
|
|
16083
|
+
import ts79 from "typescript";
|
|
16084
|
+
var TcbControlFlowContentProjectionOp = class extends TcbOp {
|
|
15724
16085
|
tcb;
|
|
15725
|
-
|
|
15726
|
-
|
|
15727
|
-
|
|
16086
|
+
element;
|
|
16087
|
+
ngContentSelectors;
|
|
16088
|
+
componentName;
|
|
16089
|
+
category;
|
|
16090
|
+
constructor(tcb, element, ngContentSelectors, componentName) {
|
|
15728
16091
|
super();
|
|
15729
16092
|
this.tcb = tcb;
|
|
15730
|
-
this.
|
|
15731
|
-
this.
|
|
15732
|
-
|
|
15733
|
-
|
|
15734
|
-
return false;
|
|
16093
|
+
this.element = element;
|
|
16094
|
+
this.ngContentSelectors = ngContentSelectors;
|
|
16095
|
+
this.componentName = componentName;
|
|
16096
|
+
this.category = tcb.env.config.controlFlowPreventingContentProjection === "error" ? ts79.DiagnosticCategory.Error : ts79.DiagnosticCategory.Warning;
|
|
15735
16097
|
}
|
|
16098
|
+
optional = false;
|
|
15736
16099
|
execute() {
|
|
15737
|
-
const
|
|
15738
|
-
|
|
15739
|
-
|
|
15740
|
-
|
|
16100
|
+
const controlFlowToCheck = this.findPotentialControlFlowNodes();
|
|
16101
|
+
if (controlFlowToCheck.length > 0) {
|
|
16102
|
+
const matcher = new SelectorMatcher2();
|
|
16103
|
+
for (const selector of this.ngContentSelectors) {
|
|
16104
|
+
if (selector !== "*") {
|
|
16105
|
+
matcher.addSelectables(CssSelector3.parse(selector), selector);
|
|
16106
|
+
}
|
|
16107
|
+
}
|
|
16108
|
+
for (const root of controlFlowToCheck) {
|
|
16109
|
+
for (const child of root.children) {
|
|
16110
|
+
if (child instanceof TmplAstElement7 || child instanceof TmplAstTemplate4) {
|
|
16111
|
+
matcher.match(createCssSelectorFromNode(child), (_, originalSelector) => {
|
|
16112
|
+
this.tcb.oobRecorder.controlFlowPreventingContentProjection(this.tcb.id, this.category, child, this.componentName, originalSelector, root, this.tcb.hostPreserveWhitespaces);
|
|
16113
|
+
});
|
|
16114
|
+
}
|
|
16115
|
+
}
|
|
16116
|
+
}
|
|
16117
|
+
}
|
|
16118
|
+
return null;
|
|
16119
|
+
}
|
|
16120
|
+
findPotentialControlFlowNodes() {
|
|
16121
|
+
const result = [];
|
|
16122
|
+
for (const child of this.element.children) {
|
|
16123
|
+
if (child instanceof TmplAstForLoopBlock) {
|
|
16124
|
+
if (this.shouldCheck(child)) {
|
|
16125
|
+
result.push(child);
|
|
16126
|
+
}
|
|
16127
|
+
if (child.empty !== null && this.shouldCheck(child.empty)) {
|
|
16128
|
+
result.push(child.empty);
|
|
16129
|
+
}
|
|
16130
|
+
} else if (child instanceof TmplAstIfBlock) {
|
|
16131
|
+
for (const branch of child.branches) {
|
|
16132
|
+
if (this.shouldCheck(branch)) {
|
|
16133
|
+
result.push(branch);
|
|
16134
|
+
}
|
|
16135
|
+
}
|
|
16136
|
+
} else if (child instanceof TmplAstSwitchBlock) {
|
|
16137
|
+
for (const current of child.cases) {
|
|
16138
|
+
if (this.shouldCheck(current)) {
|
|
16139
|
+
result.push(current);
|
|
16140
|
+
}
|
|
16141
|
+
}
|
|
16142
|
+
}
|
|
16143
|
+
}
|
|
16144
|
+
return result;
|
|
16145
|
+
}
|
|
16146
|
+
shouldCheck(node) {
|
|
16147
|
+
if (node.children.length < 2) {
|
|
16148
|
+
return false;
|
|
16149
|
+
}
|
|
16150
|
+
let hasSeenRootNode = false;
|
|
16151
|
+
for (const child of node.children) {
|
|
16152
|
+
if (!(child instanceof TmplAstText) || this.tcb.hostPreserveWhitespaces || child.value.trim().length > 0) {
|
|
16153
|
+
if (hasSeenRootNode) {
|
|
16154
|
+
return true;
|
|
16155
|
+
}
|
|
16156
|
+
hasSeenRootNode = true;
|
|
16157
|
+
}
|
|
15741
16158
|
}
|
|
15742
|
-
|
|
15743
|
-
addParseSpanInfo(initializer, this.block.item.keySpan);
|
|
15744
|
-
const expression = ts62.factory.createNonNullExpression(tcbExpression(this.block.expression, this.tcb, this.scope));
|
|
15745
|
-
const trackTranslator = new TcbForLoopTrackTranslator(this.tcb, loopScope, this.block);
|
|
15746
|
-
const trackExpression = trackTranslator.translate(this.block.trackBy);
|
|
15747
|
-
const statements = [
|
|
15748
|
-
...loopScope.render(),
|
|
15749
|
-
ts62.factory.createExpressionStatement(trackExpression)
|
|
15750
|
-
];
|
|
15751
|
-
this.scope.addStatement(ts62.factory.createForOfStatement(void 0, initializer, expression, ts62.factory.createBlock(statements)));
|
|
15752
|
-
return null;
|
|
16159
|
+
return false;
|
|
15753
16160
|
}
|
|
15754
16161
|
};
|
|
16162
|
+
|
|
16163
|
+
// packages/compiler-cli/src/ngtsc/typecheck/src/ops/intersection_observer.js
|
|
16164
|
+
import ts80 from "typescript";
|
|
15755
16165
|
var TcbIntersectionObserverOp = class extends TcbOp {
|
|
15756
16166
|
tcb;
|
|
15757
16167
|
scope;
|
|
@@ -15765,50 +16175,35 @@ var TcbIntersectionObserverOp = class extends TcbOp {
|
|
|
15765
16175
|
optional = false;
|
|
15766
16176
|
execute() {
|
|
15767
16177
|
const options = tcbExpression(this.options, this.tcb, this.scope);
|
|
15768
|
-
const callback =
|
|
15769
|
-
const expression =
|
|
15770
|
-
this.scope.addStatement(
|
|
16178
|
+
const callback = ts80.factory.createNonNullExpression(ts80.factory.createNull());
|
|
16179
|
+
const expression = ts80.factory.createNewExpression(ts80.factory.createIdentifier("IntersectionObserver"), void 0, [callback, options]);
|
|
16180
|
+
this.scope.addStatement(ts80.factory.createExpressionStatement(expression));
|
|
15771
16181
|
return null;
|
|
15772
16182
|
}
|
|
15773
16183
|
};
|
|
15774
|
-
|
|
15775
|
-
|
|
15776
|
-
|
|
15777
|
-
|
|
15778
|
-
|
|
15779
|
-
|
|
15780
|
-
|
|
15781
|
-
|
|
15782
|
-
|
|
15783
|
-
|
|
15784
|
-
|
|
15785
|
-
|
|
15786
|
-
this.env = env;
|
|
15787
|
-
this.domSchemaChecker = domSchemaChecker;
|
|
15788
|
-
this.oobRecorder = oobRecorder;
|
|
15789
|
-
this.id = id;
|
|
15790
|
-
this.boundTarget = boundTarget;
|
|
15791
|
-
this.pipes = pipes;
|
|
15792
|
-
this.schemas = schemas;
|
|
15793
|
-
this.hostIsStandalone = hostIsStandalone;
|
|
15794
|
-
this.hostPreserveWhitespaces = hostPreserveWhitespaces;
|
|
15795
|
-
}
|
|
15796
|
-
/**
|
|
15797
|
-
* Allocate a new variable name for use within the `Context`.
|
|
15798
|
-
*
|
|
15799
|
-
* Currently this uses a monotonically increasing counter, but in the future the variable name
|
|
15800
|
-
* might change depending on the type of data being stored.
|
|
15801
|
-
*/
|
|
15802
|
-
allocateId() {
|
|
15803
|
-
return ts62.factory.createIdentifier(`_t${this.nextId++}`);
|
|
16184
|
+
|
|
16185
|
+
// packages/compiler-cli/src/ngtsc/typecheck/src/ops/host.js
|
|
16186
|
+
var TcbHostElementOp = class extends TcbOp {
|
|
16187
|
+
tcb;
|
|
16188
|
+
scope;
|
|
16189
|
+
element;
|
|
16190
|
+
optional = true;
|
|
16191
|
+
constructor(tcb, scope, element) {
|
|
16192
|
+
super();
|
|
16193
|
+
this.tcb = tcb;
|
|
16194
|
+
this.scope = scope;
|
|
16195
|
+
this.element = element;
|
|
15804
16196
|
}
|
|
15805
|
-
|
|
15806
|
-
|
|
15807
|
-
|
|
15808
|
-
|
|
15809
|
-
|
|
16197
|
+
execute() {
|
|
16198
|
+
const id = this.tcb.allocateId();
|
|
16199
|
+
const initializer = tsCreateElement(...this.element.tagNames);
|
|
16200
|
+
addParseSpanInfo(initializer, this.element.sourceSpan);
|
|
16201
|
+
this.scope.addStatement(tsCreateVariable(id, initializer));
|
|
16202
|
+
return id;
|
|
15810
16203
|
}
|
|
15811
16204
|
};
|
|
16205
|
+
|
|
16206
|
+
// packages/compiler-cli/src/ngtsc/typecheck/src/ops/scope.js
|
|
15812
16207
|
var Scope = class _Scope {
|
|
15813
16208
|
tcb;
|
|
15814
16209
|
parent;
|
|
@@ -15876,12 +16271,12 @@ var Scope = class _Scope {
|
|
|
15876
16271
|
*/
|
|
15877
16272
|
static getForLoopContextVariableTypes() {
|
|
15878
16273
|
return /* @__PURE__ */ new Map([
|
|
15879
|
-
["$first",
|
|
15880
|
-
["$last",
|
|
15881
|
-
["$even",
|
|
15882
|
-
["$odd",
|
|
15883
|
-
["$index",
|
|
15884
|
-
["$count",
|
|
16274
|
+
["$first", ts81.SyntaxKind.BooleanKeyword],
|
|
16275
|
+
["$last", ts81.SyntaxKind.BooleanKeyword],
|
|
16276
|
+
["$even", ts81.SyntaxKind.BooleanKeyword],
|
|
16277
|
+
["$odd", ts81.SyntaxKind.BooleanKeyword],
|
|
16278
|
+
["$index", ts81.SyntaxKind.NumberKeyword],
|
|
16279
|
+
["$count", ts81.SyntaxKind.NumberKeyword]
|
|
15885
16280
|
]);
|
|
15886
16281
|
}
|
|
15887
16282
|
constructor(tcb, parent = null, guard = null) {
|
|
@@ -15905,7 +16300,7 @@ var Scope = class _Scope {
|
|
|
15905
16300
|
if (parentScope === null && tcb.env.config.enableTemplateTypeChecker) {
|
|
15906
16301
|
scope.opQueue.push(new TcbComponentContextCompletionOp(scope));
|
|
15907
16302
|
}
|
|
15908
|
-
if (scopedNode instanceof
|
|
16303
|
+
if (scopedNode instanceof TmplAstTemplate5) {
|
|
15909
16304
|
const varMap = /* @__PURE__ */ new Map();
|
|
15910
16305
|
for (const v of scopedNode.variables) {
|
|
15911
16306
|
if (!varMap.has(v.name)) {
|
|
@@ -15921,7 +16316,7 @@ var Scope = class _Scope {
|
|
|
15921
16316
|
if (expression !== null && expressionAlias !== null) {
|
|
15922
16317
|
_Scope.registerVariable(scope, expressionAlias, new TcbBlockVariableOp(tcb, scope, tcbExpression(expression, tcb, scope), expressionAlias));
|
|
15923
16318
|
}
|
|
15924
|
-
} else if (scopedNode instanceof
|
|
16319
|
+
} else if (scopedNode instanceof TmplAstForLoopBlock2) {
|
|
15925
16320
|
const loopInitializer = tcb.allocateId();
|
|
15926
16321
|
addParseSpanInfo(loopInitializer, scopedNode.item.sourceSpan);
|
|
15927
16322
|
scope.varMap.set(scopedNode.item, loopInitializer);
|
|
@@ -15930,10 +16325,10 @@ var Scope = class _Scope {
|
|
|
15930
16325
|
if (!forLoopContextVariableTypes.has(variable.value)) {
|
|
15931
16326
|
throw new Error(`Unrecognized for loop context variable ${variable.name}`);
|
|
15932
16327
|
}
|
|
15933
|
-
const type =
|
|
16328
|
+
const type = ts81.factory.createKeywordTypeNode(forLoopContextVariableTypes.get(variable.value));
|
|
15934
16329
|
_Scope.registerVariable(scope, variable, new TcbBlockImplicitVariableOp(tcb, scope, type, variable));
|
|
15935
16330
|
}
|
|
15936
|
-
} else if (scopedNode instanceof
|
|
16331
|
+
} else if (scopedNode instanceof TmplAstHostElement5) {
|
|
15937
16332
|
scope.appendNode(scopedNode);
|
|
15938
16333
|
}
|
|
15939
16334
|
if (children !== null) {
|
|
@@ -15977,16 +16372,16 @@ var Scope = class _Scope {
|
|
|
15977
16372
|
const res = this.resolveLocal(node, directive);
|
|
15978
16373
|
if (res !== null) {
|
|
15979
16374
|
let clone;
|
|
15980
|
-
if (
|
|
15981
|
-
clone =
|
|
15982
|
-
} else if (
|
|
15983
|
-
clone =
|
|
16375
|
+
if (ts81.isIdentifier(res)) {
|
|
16376
|
+
clone = ts81.factory.createIdentifier(res.text);
|
|
16377
|
+
} else if (ts81.isNonNullExpression(res)) {
|
|
16378
|
+
clone = ts81.factory.createNonNullExpression(res.expression);
|
|
15984
16379
|
} else {
|
|
15985
16380
|
throw new Error(`Could not resolve ${node} to an Identifier or a NonNullExpression`);
|
|
15986
16381
|
}
|
|
15987
|
-
|
|
16382
|
+
ts81.setOriginalNode(clone, res);
|
|
15988
16383
|
clone.parent = clone.parent;
|
|
15989
|
-
return
|
|
16384
|
+
return ts81.setSyntheticTrailingComments(clone, []);
|
|
15990
16385
|
} else if (this.parent !== null) {
|
|
15991
16386
|
return this.parent.resolve(node, directive);
|
|
15992
16387
|
} else {
|
|
@@ -16023,37 +16418,51 @@ var Scope = class _Scope {
|
|
|
16023
16418
|
} else if (parentGuards === null) {
|
|
16024
16419
|
return this.guard;
|
|
16025
16420
|
} else {
|
|
16026
|
-
return
|
|
16421
|
+
return ts81.factory.createBinaryExpression(parentGuards, ts81.SyntaxKind.AmpersandAmpersandToken, this.guard);
|
|
16027
16422
|
}
|
|
16028
16423
|
}
|
|
16029
16424
|
/** Returns whether a template symbol is defined locally within the current scope. */
|
|
16030
16425
|
isLocal(node) {
|
|
16031
|
-
if (node instanceof
|
|
16426
|
+
if (node instanceof TmplAstVariable2) {
|
|
16032
16427
|
return this.varMap.has(node);
|
|
16033
16428
|
}
|
|
16034
|
-
if (node instanceof
|
|
16429
|
+
if (node instanceof TmplAstLetDeclaration3) {
|
|
16035
16430
|
return this.letDeclOpMap.has(node.name);
|
|
16036
16431
|
}
|
|
16037
16432
|
return this.referenceOpMap.has(node);
|
|
16038
16433
|
}
|
|
16434
|
+
/**
|
|
16435
|
+
* Constructs a `Scope` given either a `TmplAstTemplate` or a list of `TmplAstNode`s.
|
|
16436
|
+
* This is identical to `Scope.forNodes` which we can't reference in some ops due to
|
|
16437
|
+
* circular dependencies.
|
|
16438
|
+
*.
|
|
16439
|
+
* @param parentScope the `Scope` of the parent template.
|
|
16440
|
+
* @param scopedNode Node that provides the scope around the child nodes (e.g. a
|
|
16441
|
+
* `TmplAstTemplate` node exposing variables to its children).
|
|
16442
|
+
* @param children Child nodes that should be appended to the TCB.
|
|
16443
|
+
* @param guard an expression that is applied to this scope for type narrowing purposes.
|
|
16444
|
+
*/
|
|
16445
|
+
createChildScope(parentScope, scopedNode, children, guard) {
|
|
16446
|
+
return _Scope.forNodes(this.tcb, parentScope, scopedNode, children, guard);
|
|
16447
|
+
}
|
|
16039
16448
|
resolveLocal(ref, directive) {
|
|
16040
16449
|
if (ref instanceof TmplAstReference2 && this.referenceOpMap.has(ref)) {
|
|
16041
16450
|
return this.resolveOp(this.referenceOpMap.get(ref));
|
|
16042
|
-
} else if (ref instanceof
|
|
16451
|
+
} else if (ref instanceof TmplAstLetDeclaration3 && this.letDeclOpMap.has(ref.name)) {
|
|
16043
16452
|
return this.resolveOp(this.letDeclOpMap.get(ref.name).opIndex);
|
|
16044
|
-
} else if (ref instanceof
|
|
16453
|
+
} else if (ref instanceof TmplAstVariable2 && this.varMap.has(ref)) {
|
|
16045
16454
|
const opIndexOrNode = this.varMap.get(ref);
|
|
16046
16455
|
return typeof opIndexOrNode === "number" ? this.resolveOp(opIndexOrNode) : opIndexOrNode;
|
|
16047
|
-
} else if (ref instanceof
|
|
16456
|
+
} else if (ref instanceof TmplAstTemplate5 && directive === void 0 && this.templateCtxOpMap.has(ref)) {
|
|
16048
16457
|
return this.resolveOp(this.templateCtxOpMap.get(ref));
|
|
16049
|
-
} else if ((ref instanceof
|
|
16458
|
+
} else if ((ref instanceof TmplAstElement8 || ref instanceof TmplAstTemplate5 || ref instanceof TmplAstComponent3 || ref instanceof TmplAstDirective2 || ref instanceof TmplAstHostElement5) && directive !== void 0 && this.directiveOpMap.has(ref)) {
|
|
16050
16459
|
const dirMap = this.directiveOpMap.get(ref);
|
|
16051
16460
|
return dirMap.has(directive) ? this.resolveOp(dirMap.get(directive)) : null;
|
|
16052
|
-
} else if (ref instanceof
|
|
16461
|
+
} else if (ref instanceof TmplAstElement8 && this.elementOpMap.has(ref)) {
|
|
16053
16462
|
return this.resolveOp(this.elementOpMap.get(ref));
|
|
16054
|
-
} else if (ref instanceof
|
|
16463
|
+
} else if (ref instanceof TmplAstComponent3 && this.componentNodeOpMap.has(ref)) {
|
|
16055
16464
|
return this.resolveOp(this.componentNodeOpMap.get(ref));
|
|
16056
|
-
} else if (ref instanceof
|
|
16465
|
+
} else if (ref instanceof TmplAstHostElement5 && this.hostElementOpMap.has(ref)) {
|
|
16057
16466
|
return this.resolveOp(this.hostElementOpMap.get(ref));
|
|
16058
16467
|
} else {
|
|
16059
16468
|
return null;
|
|
@@ -16094,7 +16503,7 @@ var Scope = class _Scope {
|
|
|
16094
16503
|
return res;
|
|
16095
16504
|
}
|
|
16096
16505
|
appendNode(node) {
|
|
16097
|
-
if (node instanceof
|
|
16506
|
+
if (node instanceof TmplAstElement8) {
|
|
16098
16507
|
const opIndex = this.opQueue.push(new TcbElementOp(this.tcb, this, node)) - 1;
|
|
16099
16508
|
this.elementOpMap.set(node, opIndex);
|
|
16100
16509
|
if (this.tcb.env.config.controlFlowPreventingContentProjection !== "suppress") {
|
|
@@ -16105,7 +16514,7 @@ var Scope = class _Scope {
|
|
|
16105
16514
|
this.appendSelectorlessDirectives(node);
|
|
16106
16515
|
this.appendChildren(node);
|
|
16107
16516
|
this.checkAndAppendReferencesOfNode(node);
|
|
16108
|
-
} else if (node instanceof
|
|
16517
|
+
} else if (node instanceof TmplAstTemplate5) {
|
|
16109
16518
|
this.appendDirectivesAndInputsOfElementLikeNode(node);
|
|
16110
16519
|
this.appendOutputsOfElementLikeNode(node, node.inputs, node.outputs);
|
|
16111
16520
|
this.appendSelectorlessDirectives(node);
|
|
@@ -16117,15 +16526,15 @@ var Scope = class _Scope {
|
|
|
16117
16526
|
this.appendDeepSchemaChecks(node.children);
|
|
16118
16527
|
}
|
|
16119
16528
|
this.checkAndAppendReferencesOfNode(node);
|
|
16120
|
-
} else if (node instanceof
|
|
16529
|
+
} else if (node instanceof TmplAstComponent3) {
|
|
16121
16530
|
this.appendComponentNode(node);
|
|
16122
16531
|
} else if (node instanceof TmplAstDeferredBlock) {
|
|
16123
16532
|
this.appendDeferredBlock(node);
|
|
16124
|
-
} else if (node instanceof
|
|
16533
|
+
} else if (node instanceof TmplAstIfBlock2) {
|
|
16125
16534
|
this.opQueue.push(new TcbIfOp(this.tcb, this, node));
|
|
16126
|
-
} else if (node instanceof
|
|
16535
|
+
} else if (node instanceof TmplAstSwitchBlock2) {
|
|
16127
16536
|
this.opQueue.push(new TcbSwitchOp(this.tcb, this, node));
|
|
16128
|
-
} else if (node instanceof
|
|
16537
|
+
} else if (node instanceof TmplAstForLoopBlock2) {
|
|
16129
16538
|
this.opQueue.push(new TcbForOfOp(this.tcb, this, node));
|
|
16130
16539
|
node.empty && this.tcb.env.config.checkControlFlowBodies && this.appendChildren(node.empty);
|
|
16131
16540
|
} else if (node instanceof TmplAstBoundText) {
|
|
@@ -16134,14 +16543,14 @@ var Scope = class _Scope {
|
|
|
16134
16543
|
this.appendIcuExpressions(node);
|
|
16135
16544
|
} else if (node instanceof TmplAstContent) {
|
|
16136
16545
|
this.appendChildren(node);
|
|
16137
|
-
} else if (node instanceof
|
|
16546
|
+
} else if (node instanceof TmplAstLetDeclaration3) {
|
|
16138
16547
|
const opIndex = this.opQueue.push(new TcbLetDeclarationOp(this.tcb, this, node)) - 1;
|
|
16139
16548
|
if (this.isLocal(node)) {
|
|
16140
16549
|
this.tcb.oobRecorder.conflictingDeclaration(this.tcb.id, node);
|
|
16141
16550
|
} else {
|
|
16142
16551
|
this.letDeclOpMap.set(node.name, { opIndex, node });
|
|
16143
16552
|
}
|
|
16144
|
-
} else if (node instanceof
|
|
16553
|
+
} else if (node instanceof TmplAstHostElement5) {
|
|
16145
16554
|
this.appendHostElement(node);
|
|
16146
16555
|
}
|
|
16147
16556
|
}
|
|
@@ -16157,7 +16566,7 @@ var Scope = class _Scope {
|
|
|
16157
16566
|
if (target === null) {
|
|
16158
16567
|
this.tcb.oobRecorder.missingReferenceTarget(this.tcb.id, ref);
|
|
16159
16568
|
ctxIndex = this.opQueue.push(new TcbInvalidReferenceOp(this.tcb, this)) - 1;
|
|
16160
|
-
} else if (target instanceof
|
|
16569
|
+
} else if (target instanceof TmplAstTemplate5 || target instanceof TmplAstElement8) {
|
|
16161
16570
|
ctxIndex = this.opQueue.push(new TcbReferenceOp(this.tcb, this, ref, node, target)) - 1;
|
|
16162
16571
|
} else {
|
|
16163
16572
|
ctxIndex = this.opQueue.push(new TcbReferenceOp(this.tcb, this, ref, node, target.directive)) - 1;
|
|
@@ -16169,7 +16578,7 @@ var Scope = class _Scope {
|
|
|
16169
16578
|
const claimedInputs = /* @__PURE__ */ new Set();
|
|
16170
16579
|
const directives = this.tcb.boundTarget.getDirectivesOfNode(node);
|
|
16171
16580
|
if (directives === null || directives.length === 0) {
|
|
16172
|
-
if (node instanceof
|
|
16581
|
+
if (node instanceof TmplAstElement8) {
|
|
16173
16582
|
this.opQueue.push(new TcbUnclaimedInputsOp(this.tcb, this, node.inputs, node, claimedInputs), new TcbDomSchemaCheckerOp(
|
|
16174
16583
|
this.tcb,
|
|
16175
16584
|
node,
|
|
@@ -16180,7 +16589,7 @@ var Scope = class _Scope {
|
|
|
16180
16589
|
}
|
|
16181
16590
|
return;
|
|
16182
16591
|
}
|
|
16183
|
-
if (node instanceof
|
|
16592
|
+
if (node instanceof TmplAstElement8) {
|
|
16184
16593
|
const isDeferred = this.tcb.boundTarget.isDeferred(node);
|
|
16185
16594
|
if (!isDeferred && directives.some((dirMeta) => dirMeta.isExplicitlyDeferred)) {
|
|
16186
16595
|
this.tcb.oobRecorder.deferredComponentUsedEagerly(this.tcb.id, node);
|
|
@@ -16191,7 +16600,7 @@ var Scope = class _Scope {
|
|
|
16191
16600
|
this.appendDirectiveInputs(dir, node, dirMap, directives);
|
|
16192
16601
|
}
|
|
16193
16602
|
this.directiveOpMap.set(node, dirMap);
|
|
16194
|
-
if (node instanceof
|
|
16603
|
+
if (node instanceof TmplAstElement8) {
|
|
16195
16604
|
for (const dir of directives) {
|
|
16196
16605
|
for (const propertyName of dir.inputs.propertyNames) {
|
|
16197
16606
|
claimedInputs.add(propertyName);
|
|
@@ -16206,7 +16615,7 @@ var Scope = class _Scope {
|
|
|
16206
16615
|
const claimedOutputs = /* @__PURE__ */ new Set();
|
|
16207
16616
|
const directives = this.tcb.boundTarget.getDirectivesOfNode(node);
|
|
16208
16617
|
if (directives === null || directives.length === 0) {
|
|
16209
|
-
if (node instanceof
|
|
16618
|
+
if (node instanceof TmplAstElement8) {
|
|
16210
16619
|
this.opQueue.push(new TcbUnclaimedOutputsOp(this.tcb, this, node, events, bindings, claimedOutputs));
|
|
16211
16620
|
}
|
|
16212
16621
|
return;
|
|
@@ -16214,7 +16623,7 @@ var Scope = class _Scope {
|
|
|
16214
16623
|
for (const dir of directives) {
|
|
16215
16624
|
this.opQueue.push(new TcbDirectiveOutputsOp(this.tcb, this, node, bindings, events, dir));
|
|
16216
16625
|
}
|
|
16217
|
-
if (node instanceof
|
|
16626
|
+
if (node instanceof TmplAstElement8 || node instanceof TmplAstHostElement5) {
|
|
16218
16627
|
for (const dir of directives) {
|
|
16219
16628
|
for (const outputProperty of dir.outputs.propertyNames) {
|
|
16220
16629
|
claimedOutputs.add(outputProperty);
|
|
@@ -16274,27 +16683,21 @@ var Scope = class _Scope {
|
|
|
16274
16683
|
}
|
|
16275
16684
|
}
|
|
16276
16685
|
appendDirectiveInputs(dir, node, dirMap, allDirectiveMatches) {
|
|
16277
|
-
const
|
|
16686
|
+
const customFieldType = allDirectiveMatches.some(isFieldDirective) ? getCustomFieldDirectiveType(dir) : null;
|
|
16687
|
+
const directiveOp = this.getDirectiveOp(dir, node, customFieldType);
|
|
16278
16688
|
const dirIndex = this.opQueue.push(directiveOp) - 1;
|
|
16279
16689
|
dirMap.set(dir, dirIndex);
|
|
16280
|
-
|
|
16690
|
+
if (isFieldDirective(dir) && node instanceof TmplAstElement8 && (node.name === "input" || node.name === "select" || node.name === "textarea") && !allDirectiveMatches.some(getCustomFieldDirectiveType)) {
|
|
16691
|
+
this.opQueue.push(new TcbNativeFieldDirectiveTypeOp(this.tcb, this, node));
|
|
16692
|
+
}
|
|
16693
|
+
this.opQueue.push(new TcbDirectiveInputsOp(this.tcb, this, node, dir, customFieldType));
|
|
16281
16694
|
}
|
|
16282
|
-
getDirectiveOp(dir, node,
|
|
16695
|
+
getDirectiveOp(dir, node, customFieldType) {
|
|
16283
16696
|
const dirRef = dir.ref;
|
|
16284
|
-
if (dir.
|
|
16285
|
-
let customControl = null;
|
|
16286
|
-
for (const meta of allDirectiveMatches) {
|
|
16287
|
-
const type = getCustomFieldDirectiveType(meta);
|
|
16288
|
-
if (type !== null) {
|
|
16289
|
-
customControl = { type, meta };
|
|
16290
|
-
break;
|
|
16291
|
-
}
|
|
16292
|
-
}
|
|
16293
|
-
return customControl === null ? new TcbNativeFieldDirectiveTypeOp(this.tcb, this, node, dir) : new TcbCustomFieldDirectiveTypeOp(this.tcb, this, node, dir, customControl);
|
|
16294
|
-
} else if (!dir.isGeneric) {
|
|
16697
|
+
if (!dir.isGeneric) {
|
|
16295
16698
|
return new TcbNonGenericDirectiveTypeOp(this.tcb, this, node, dir);
|
|
16296
16699
|
} else if (!requiresInlineTypeCtor(dirRef.node, this.tcb.env.reflector, this.tcb.env) || this.tcb.env.config.useInlineTypeConstructors) {
|
|
16297
|
-
return new TcbDirectiveCtorOp(this.tcb, this, node, dir);
|
|
16700
|
+
return new TcbDirectiveCtorOp(this.tcb, this, node, dir, customFieldType);
|
|
16298
16701
|
}
|
|
16299
16702
|
return new TcbGenericDirectiveTypeWithAnyParamsOp(this.tcb, this, node, dir);
|
|
16300
16703
|
}
|
|
@@ -16316,10 +16719,10 @@ var Scope = class _Scope {
|
|
|
16316
16719
|
}
|
|
16317
16720
|
appendDeepSchemaChecks(nodes) {
|
|
16318
16721
|
for (const node of nodes) {
|
|
16319
|
-
if (!(node instanceof
|
|
16722
|
+
if (!(node instanceof TmplAstElement8 || node instanceof TmplAstTemplate5)) {
|
|
16320
16723
|
continue;
|
|
16321
16724
|
}
|
|
16322
|
-
if (node instanceof
|
|
16725
|
+
if (node instanceof TmplAstElement8) {
|
|
16323
16726
|
const claimedInputs = /* @__PURE__ */ new Set();
|
|
16324
16727
|
let directives = this.tcb.boundTarget.getDirectivesOfNode(node);
|
|
16325
16728
|
for (const dirNode of node.directives) {
|
|
@@ -16413,401 +16816,150 @@ var Scope = class _Scope {
|
|
|
16413
16816
|
this.validateReferenceBasedDeferredTrigger(block, triggers.hover);
|
|
16414
16817
|
}
|
|
16415
16818
|
if (triggers.interaction !== void 0) {
|
|
16416
|
-
this.validateReferenceBasedDeferredTrigger(block, triggers.interaction);
|
|
16417
|
-
}
|
|
16418
|
-
if (triggers.viewport !== void 0) {
|
|
16419
|
-
this.validateReferenceBasedDeferredTrigger(block, triggers.viewport);
|
|
16420
|
-
}
|
|
16421
|
-
}
|
|
16422
|
-
appendHostElement(node) {
|
|
16423
|
-
const opIndex = this.opQueue.push(new TcbHostElementOp(this.tcb, this, node)) - 1;
|
|
16424
|
-
const directives = this.tcb.boundTarget.getDirectivesOfNode(node);
|
|
16425
|
-
if (directives !== null && directives.length > 0) {
|
|
16426
|
-
const directiveOpMap = /* @__PURE__ */ new Map();
|
|
16427
|
-
for (const directive of directives) {
|
|
16428
|
-
const directiveOp = this.getDirectiveOp(directive, node,
|
|
16429
|
-
directiveOpMap.set(directive, this.opQueue.push(directiveOp) - 1);
|
|
16430
|
-
}
|
|
16431
|
-
this.directiveOpMap.set(node, directiveOpMap);
|
|
16432
|
-
}
|
|
16433
|
-
this.hostElementOpMap.set(node, opIndex);
|
|
16434
|
-
this.opQueue.push(new TcbUnclaimedInputsOp(this.tcb, this, node.bindings, node, null), new TcbDomSchemaCheckerOp(this.tcb, node, false, null));
|
|
16435
|
-
this.appendOutputsOfElementLikeNode(node, null, node.listeners);
|
|
16436
|
-
}
|
|
16437
|
-
validateReferenceBasedDeferredTrigger(block, trigger) {
|
|
16438
|
-
if (trigger.reference === null) {
|
|
16439
|
-
if (block.placeholder === null) {
|
|
16440
|
-
this.tcb.oobRecorder.deferImplicitTriggerMissingPlaceholder(this.tcb.id, trigger);
|
|
16441
|
-
return;
|
|
16442
|
-
}
|
|
16443
|
-
let rootNode = null;
|
|
16444
|
-
for (const child of block.placeholder.children) {
|
|
16445
|
-
if (!this.tcb.hostPreserveWhitespaces && child instanceof TmplAstText && child.value.trim().length === 0) {
|
|
16446
|
-
continue;
|
|
16447
|
-
}
|
|
16448
|
-
if (rootNode === null) {
|
|
16449
|
-
rootNode = child;
|
|
16450
|
-
} else {
|
|
16451
|
-
rootNode = null;
|
|
16452
|
-
break;
|
|
16453
|
-
}
|
|
16454
|
-
}
|
|
16455
|
-
if (rootNode === null || !(rootNode instanceof TmplAstElement2)) {
|
|
16456
|
-
this.tcb.oobRecorder.deferImplicitTriggerInvalidPlaceholder(this.tcb.id, trigger);
|
|
16457
|
-
}
|
|
16458
|
-
return;
|
|
16459
|
-
}
|
|
16460
|
-
if (this.tcb.boundTarget.getDeferredTriggerTarget(block, trigger) === null) {
|
|
16461
|
-
this.tcb.oobRecorder.inaccessibleDeferredTriggerElement(this.tcb.id, trigger);
|
|
16462
|
-
}
|
|
16463
|
-
}
|
|
16464
|
-
/** Reports a diagnostic if there are any `@let` declarations that conflict with a node. */
|
|
16465
|
-
static checkConflictingLet(scope, node) {
|
|
16466
|
-
if (scope.letDeclOpMap.has(node.name)) {
|
|
16467
|
-
scope.tcb.oobRecorder.conflictingDeclaration(scope.tcb.id, scope.letDeclOpMap.get(node.name).node);
|
|
16468
|
-
}
|
|
16469
|
-
}
|
|
16470
|
-
};
|
|
16471
|
-
function tcbThisParam(name, typeArguments) {
|
|
16472
|
-
return ts62.factory.createParameterDeclaration(
|
|
16473
|
-
/* modifiers */
|
|
16474
|
-
void 0,
|
|
16475
|
-
/* dotDotDotToken */
|
|
16476
|
-
void 0,
|
|
16477
|
-
/* name */
|
|
16478
|
-
"this",
|
|
16479
|
-
/* questionToken */
|
|
16480
|
-
void 0,
|
|
16481
|
-
/* type */
|
|
16482
|
-
ts62.factory.createTypeReferenceNode(name, typeArguments),
|
|
16483
|
-
/* initializer */
|
|
16484
|
-
void 0
|
|
16485
|
-
);
|
|
16486
|
-
}
|
|
16487
|
-
function tcbExpression(ast, tcb, scope) {
|
|
16488
|
-
const translator = new TcbExpressionTranslator(tcb, scope);
|
|
16489
|
-
return translator.translate(ast);
|
|
16490
|
-
}
|
|
16491
|
-
var TcbExpressionTranslator = class {
|
|
16492
|
-
tcb;
|
|
16493
|
-
scope;
|
|
16494
|
-
constructor(tcb, scope) {
|
|
16495
|
-
this.tcb = tcb;
|
|
16496
|
-
this.scope = scope;
|
|
16497
|
-
}
|
|
16498
|
-
translate(ast) {
|
|
16499
|
-
return astToTypescript(ast, (ast2) => this.resolve(ast2), this.tcb.env.config);
|
|
16500
|
-
}
|
|
16501
|
-
/**
|
|
16502
|
-
* Resolve an `AST` expression within the given scope.
|
|
16503
|
-
*
|
|
16504
|
-
* Some `AST` expressions refer to top-level concepts (references, variables, the component
|
|
16505
|
-
* context). This method assists in resolving those.
|
|
16506
|
-
*/
|
|
16507
|
-
resolve(ast) {
|
|
16508
|
-
if (ast instanceof PropertyRead4 && ast.receiver instanceof ImplicitReceiver3 && !(ast.receiver instanceof ThisReceiver2)) {
|
|
16509
|
-
const target = this.tcb.boundTarget.getExpressionTarget(ast);
|
|
16510
|
-
const targetExpression = target === null ? null : this.getTargetNodeExpression(target, ast);
|
|
16511
|
-
if (target instanceof TmplAstLetDeclaration2 && !this.isValidLetDeclarationAccess(target, ast)) {
|
|
16512
|
-
this.tcb.oobRecorder.letUsedBeforeDefinition(this.tcb.id, ast, target);
|
|
16513
|
-
if (targetExpression !== null) {
|
|
16514
|
-
return ts62.factory.createAsExpression(targetExpression, ts62.factory.createKeywordTypeNode(ts62.SyntaxKind.AnyKeyword));
|
|
16515
|
-
}
|
|
16516
|
-
}
|
|
16517
|
-
return targetExpression;
|
|
16518
|
-
} else if (ast instanceof Binary && Binary.isAssignmentOperation(ast.operation) && ast.left instanceof PropertyRead4 && ast.left.receiver instanceof ImplicitReceiver3) {
|
|
16519
|
-
const read = ast.left;
|
|
16520
|
-
const target = this.tcb.boundTarget.getExpressionTarget(read);
|
|
16521
|
-
if (target === null) {
|
|
16522
|
-
return null;
|
|
16523
|
-
}
|
|
16524
|
-
const targetExpression = this.getTargetNodeExpression(target, read);
|
|
16525
|
-
const expr = this.translate(ast.right);
|
|
16526
|
-
const result = ts62.factory.createParenthesizedExpression(ts62.factory.createBinaryExpression(targetExpression, ts62.SyntaxKind.EqualsToken, expr));
|
|
16527
|
-
addParseSpanInfo(result, read.sourceSpan);
|
|
16528
|
-
if (target instanceof TmplAstLetDeclaration2) {
|
|
16529
|
-
markIgnoreDiagnostics(result);
|
|
16530
|
-
this.tcb.oobRecorder.illegalWriteToLetDeclaration(this.tcb.id, read, target);
|
|
16531
|
-
}
|
|
16532
|
-
return result;
|
|
16533
|
-
} else if (ast instanceof ImplicitReceiver3) {
|
|
16534
|
-
return ts62.factory.createThis();
|
|
16535
|
-
} else if (ast instanceof BindingPipe) {
|
|
16536
|
-
const expr = this.translate(ast.exp);
|
|
16537
|
-
const pipeMeta = this.tcb.getPipeByName(ast.name);
|
|
16538
|
-
let pipe;
|
|
16539
|
-
if (pipeMeta === null) {
|
|
16540
|
-
this.tcb.oobRecorder.missingPipe(this.tcb.id, ast, this.tcb.hostIsStandalone);
|
|
16541
|
-
pipe = getAnyExpression();
|
|
16542
|
-
} else if (pipeMeta.isExplicitlyDeferred && this.tcb.boundTarget.getEagerlyUsedPipes().includes(ast.name)) {
|
|
16543
|
-
this.tcb.oobRecorder.deferredPipeUsedEagerly(this.tcb.id, ast);
|
|
16544
|
-
pipe = getAnyExpression();
|
|
16545
|
-
} else {
|
|
16546
|
-
pipe = this.tcb.env.pipeInst(pipeMeta.ref);
|
|
16547
|
-
}
|
|
16548
|
-
const args = ast.args.map((arg) => this.translate(arg));
|
|
16549
|
-
let methodAccess = ts62.factory.createPropertyAccessExpression(pipe, "transform");
|
|
16550
|
-
addParseSpanInfo(methodAccess, ast.nameSpan);
|
|
16551
|
-
if (!this.tcb.env.config.checkTypeOfPipes) {
|
|
16552
|
-
methodAccess = ts62.factory.createAsExpression(methodAccess, ts62.factory.createKeywordTypeNode(ts62.SyntaxKind.AnyKeyword));
|
|
16553
|
-
}
|
|
16554
|
-
const result = ts62.factory.createCallExpression(
|
|
16555
|
-
/* expression */
|
|
16556
|
-
methodAccess,
|
|
16557
|
-
/* typeArguments */
|
|
16558
|
-
void 0,
|
|
16559
|
-
/* argumentsArray */
|
|
16560
|
-
[expr, ...args]
|
|
16561
|
-
);
|
|
16562
|
-
addParseSpanInfo(result, ast.sourceSpan);
|
|
16563
|
-
return result;
|
|
16564
|
-
} else if ((ast instanceof Call3 || ast instanceof SafeCall2) && (ast.receiver instanceof PropertyRead4 || ast.receiver instanceof SafePropertyRead3)) {
|
|
16565
|
-
if (ast.receiver.receiver instanceof ImplicitReceiver3 && !(ast.receiver.receiver instanceof ThisReceiver2) && ast.receiver.name === "$any" && ast.args.length === 1) {
|
|
16566
|
-
const expr = this.translate(ast.args[0]);
|
|
16567
|
-
const exprAsAny = ts62.factory.createAsExpression(expr, ts62.factory.createKeywordTypeNode(ts62.SyntaxKind.AnyKeyword));
|
|
16568
|
-
const result = ts62.factory.createParenthesizedExpression(exprAsAny);
|
|
16569
|
-
addParseSpanInfo(result, ast.sourceSpan);
|
|
16570
|
-
return result;
|
|
16571
|
-
}
|
|
16572
|
-
const target = this.tcb.boundTarget.getExpressionTarget(ast);
|
|
16573
|
-
if (target === null) {
|
|
16574
|
-
return null;
|
|
16575
|
-
}
|
|
16576
|
-
const receiver = this.getTargetNodeExpression(target, ast);
|
|
16577
|
-
const method = wrapForDiagnostics(receiver);
|
|
16578
|
-
addParseSpanInfo(method, ast.receiver.nameSpan);
|
|
16579
|
-
const args = ast.args.map((arg) => this.translate(arg));
|
|
16580
|
-
const node = ts62.factory.createCallExpression(method, void 0, args);
|
|
16581
|
-
addParseSpanInfo(node, ast.sourceSpan);
|
|
16582
|
-
return node;
|
|
16583
|
-
} else {
|
|
16584
|
-
return null;
|
|
16585
|
-
}
|
|
16586
|
-
}
|
|
16587
|
-
getTargetNodeExpression(targetNode, expressionNode) {
|
|
16588
|
-
const expr = this.scope.resolve(targetNode);
|
|
16589
|
-
addParseSpanInfo(expr, expressionNode.sourceSpan);
|
|
16590
|
-
return expr;
|
|
16591
|
-
}
|
|
16592
|
-
isValidLetDeclarationAccess(target, ast) {
|
|
16593
|
-
const targetStart = target.sourceSpan.start.offset;
|
|
16594
|
-
const targetEnd = target.sourceSpan.end.offset;
|
|
16595
|
-
const astStart = ast.sourceSpan.start;
|
|
16596
|
-
return targetStart < astStart && astStart > targetEnd || !this.scope.isLocal(target);
|
|
16597
|
-
}
|
|
16598
|
-
};
|
|
16599
|
-
function tcbCallTypeCtor(dir, tcb, inputs) {
|
|
16600
|
-
const typeCtor = tcb.env.typeCtorFor(dir);
|
|
16601
|
-
const members = inputs.map((input) => {
|
|
16602
|
-
const propertyName = ts62.factory.createStringLiteral(input.field);
|
|
16603
|
-
if (input.type === "binding") {
|
|
16604
|
-
let expr = widenBinding(input.expression, tcb);
|
|
16605
|
-
if (input.isTwoWayBinding && tcb.env.config.allowSignalsInTwoWayBindings) {
|
|
16606
|
-
expr = unwrapWritableSignal(expr, tcb);
|
|
16819
|
+
this.validateReferenceBasedDeferredTrigger(block, triggers.interaction);
|
|
16820
|
+
}
|
|
16821
|
+
if (triggers.viewport !== void 0) {
|
|
16822
|
+
this.validateReferenceBasedDeferredTrigger(block, triggers.viewport);
|
|
16823
|
+
}
|
|
16824
|
+
}
|
|
16825
|
+
appendHostElement(node) {
|
|
16826
|
+
const opIndex = this.opQueue.push(new TcbHostElementOp(this.tcb, this, node)) - 1;
|
|
16827
|
+
const directives = this.tcb.boundTarget.getDirectivesOfNode(node);
|
|
16828
|
+
if (directives !== null && directives.length > 0) {
|
|
16829
|
+
const directiveOpMap = /* @__PURE__ */ new Map();
|
|
16830
|
+
for (const directive of directives) {
|
|
16831
|
+
const directiveOp = this.getDirectiveOp(directive, node, null);
|
|
16832
|
+
directiveOpMap.set(directive, this.opQueue.push(directiveOp) - 1);
|
|
16607
16833
|
}
|
|
16608
|
-
|
|
16609
|
-
addParseSpanInfo(assignment, input.sourceSpan);
|
|
16610
|
-
return assignment;
|
|
16611
|
-
} else {
|
|
16612
|
-
return ts62.factory.createPropertyAssignment(propertyName, getAnyExpression());
|
|
16834
|
+
this.directiveOpMap.set(node, directiveOpMap);
|
|
16613
16835
|
}
|
|
16614
|
-
|
|
16615
|
-
|
|
16616
|
-
|
|
16617
|
-
|
|
16618
|
-
|
|
16619
|
-
|
|
16620
|
-
|
|
16621
|
-
|
|
16622
|
-
|
|
16623
|
-
}
|
|
16624
|
-
|
|
16625
|
-
|
|
16626
|
-
|
|
16627
|
-
|
|
16836
|
+
this.hostElementOpMap.set(node, opIndex);
|
|
16837
|
+
this.opQueue.push(new TcbUnclaimedInputsOp(this.tcb, this, node.bindings, node, null), new TcbDomSchemaCheckerOp(this.tcb, node, false, null));
|
|
16838
|
+
this.appendOutputsOfElementLikeNode(node, null, node.listeners);
|
|
16839
|
+
}
|
|
16840
|
+
validateReferenceBasedDeferredTrigger(block, trigger) {
|
|
16841
|
+
if (trigger.reference === null) {
|
|
16842
|
+
if (block.placeholder === null) {
|
|
16843
|
+
this.tcb.oobRecorder.deferImplicitTriggerMissingPlaceholder(this.tcb.id, trigger);
|
|
16844
|
+
return;
|
|
16845
|
+
}
|
|
16846
|
+
let rootNode = null;
|
|
16847
|
+
for (const child of block.placeholder.children) {
|
|
16848
|
+
if (!this.tcb.hostPreserveWhitespaces && child instanceof TmplAstText2 && child.value.trim().length === 0) {
|
|
16849
|
+
continue;
|
|
16850
|
+
}
|
|
16851
|
+
if (rootNode === null) {
|
|
16852
|
+
rootNode = child;
|
|
16853
|
+
} else {
|
|
16854
|
+
rootNode = null;
|
|
16855
|
+
break;
|
|
16856
|
+
}
|
|
16857
|
+
}
|
|
16858
|
+
if (rootNode === null || !(rootNode instanceof TmplAstElement8)) {
|
|
16859
|
+
this.tcb.oobRecorder.deferImplicitTriggerInvalidPlaceholder(this.tcb.id, trigger);
|
|
16860
|
+
}
|
|
16628
16861
|
return;
|
|
16629
16862
|
}
|
|
16630
|
-
|
|
16631
|
-
|
|
16632
|
-
boundInputs.push({
|
|
16633
|
-
attribute: attr,
|
|
16634
|
-
inputs: inputs.map((input) => {
|
|
16635
|
-
return {
|
|
16636
|
-
fieldName: input.classPropertyName,
|
|
16637
|
-
required: input.required,
|
|
16638
|
-
transformType: input.transform?.type || null,
|
|
16639
|
-
isSignal: input.isSignal,
|
|
16640
|
-
isTwoWayBinding: attr instanceof TmplAstBoundAttribute3 && attr.type === BindingType3.TwoWay
|
|
16641
|
-
};
|
|
16642
|
-
})
|
|
16643
|
-
});
|
|
16863
|
+
if (this.tcb.boundTarget.getDeferredTriggerTarget(block, trigger) === null) {
|
|
16864
|
+
this.tcb.oobRecorder.inaccessibleDeferredTriggerElement(this.tcb.id, trigger);
|
|
16644
16865
|
}
|
|
16645
|
-
}
|
|
16646
|
-
if
|
|
16647
|
-
|
|
16648
|
-
|
|
16649
|
-
|
|
16866
|
+
}
|
|
16867
|
+
/** Reports a diagnostic if there are any `@let` declarations that conflict with a node. */
|
|
16868
|
+
static checkConflictingLet(scope, node) {
|
|
16869
|
+
if (scope.letDeclOpMap.has(node.name)) {
|
|
16870
|
+
scope.tcb.oobRecorder.conflictingDeclaration(scope.tcb.id, scope.letDeclOpMap.get(node.name).node);
|
|
16650
16871
|
}
|
|
16651
|
-
node.templateAttrs.forEach(processAttribute);
|
|
16652
|
-
} else {
|
|
16653
|
-
node.inputs.forEach(processAttribute);
|
|
16654
|
-
node.attributes.forEach(processAttribute);
|
|
16655
16872
|
}
|
|
16656
|
-
|
|
16657
|
-
|
|
16658
|
-
|
|
16659
|
-
|
|
16660
|
-
|
|
16661
|
-
|
|
16662
|
-
|
|
16873
|
+
};
|
|
16874
|
+
|
|
16875
|
+
// packages/compiler-cli/src/ngtsc/typecheck/src/type_check_block.js
|
|
16876
|
+
function generateTypeCheckBlock(env, ref, name, meta, domSchemaChecker, oobRecorder, genericContextBehavior) {
|
|
16877
|
+
const tcb = new Context2(env, domSchemaChecker, oobRecorder, meta.id, meta.boundTarget, meta.pipes, meta.schemas, meta.isStandalone, meta.preserveWhitespaces);
|
|
16878
|
+
const ctxRawType = env.referenceType(ref);
|
|
16879
|
+
if (!ts82.isTypeReferenceNode(ctxRawType)) {
|
|
16880
|
+
throw new Error(`Expected TypeReferenceNode when referencing the ctx param for ${ref.debugName}`);
|
|
16663
16881
|
}
|
|
16664
|
-
|
|
16665
|
-
|
|
16666
|
-
if (
|
|
16667
|
-
|
|
16668
|
-
|
|
16669
|
-
|
|
16670
|
-
|
|
16671
|
-
|
|
16672
|
-
|
|
16882
|
+
let typeParameters = void 0;
|
|
16883
|
+
let typeArguments = void 0;
|
|
16884
|
+
if (ref.node.typeParameters !== void 0) {
|
|
16885
|
+
if (!env.config.useContextGenericType) {
|
|
16886
|
+
genericContextBehavior = TcbGenericContextBehavior.FallbackToAny;
|
|
16887
|
+
}
|
|
16888
|
+
switch (genericContextBehavior) {
|
|
16889
|
+
case TcbGenericContextBehavior.UseEmitter:
|
|
16890
|
+
typeParameters = new TypeParameterEmitter(ref.node.typeParameters, env.reflector).emit((typeRef) => env.referenceType(typeRef));
|
|
16891
|
+
typeArguments = typeParameters.map((param) => ts82.factory.createTypeReferenceNode(param.name));
|
|
16892
|
+
break;
|
|
16893
|
+
case TcbGenericContextBehavior.CopyClassNodes:
|
|
16894
|
+
typeParameters = [...ref.node.typeParameters];
|
|
16895
|
+
typeArguments = typeParameters.map((param) => ts82.factory.createTypeReferenceNode(param.name));
|
|
16896
|
+
break;
|
|
16897
|
+
case TcbGenericContextBehavior.FallbackToAny:
|
|
16898
|
+
typeArguments = ref.node.typeParameters.map(() => ts82.factory.createKeywordTypeNode(ts82.SyntaxKind.AnyKeyword));
|
|
16899
|
+
break;
|
|
16673
16900
|
}
|
|
16674
|
-
} else {
|
|
16675
|
-
return expr;
|
|
16676
16901
|
}
|
|
16677
|
-
|
|
16678
|
-
function unwrapWritableSignal(expression, tcb) {
|
|
16679
|
-
const unwrapRef = tcb.env.referenceExternalSymbol(R3Identifiers4.unwrapWritableSignal.moduleName, R3Identifiers4.unwrapWritableSignal.name);
|
|
16680
|
-
return ts62.factory.createCallExpression(unwrapRef, void 0, [expression]);
|
|
16681
|
-
}
|
|
16682
|
-
var EVENT_PARAMETER = "$event";
|
|
16683
|
-
function tcbCreateEventHandler(event, tcb, scope, eventType, assertionExpression) {
|
|
16684
|
-
const handler = tcbEventHandlerExpression(event.handler, tcb, scope);
|
|
16902
|
+
const paramList = [tcbThisParam(ctxRawType.typeName, typeArguments)];
|
|
16685
16903
|
const statements = [];
|
|
16686
|
-
if (
|
|
16687
|
-
|
|
16688
|
-
|
|
16689
|
-
|
|
16690
|
-
|
|
16691
|
-
|
|
16692
|
-
|
|
16693
|
-
|
|
16694
|
-
|
|
16695
|
-
|
|
16696
|
-
let eventParamType;
|
|
16697
|
-
if (eventType === 0) {
|
|
16698
|
-
eventParamType = void 0;
|
|
16699
|
-
} else if (eventType === 1) {
|
|
16700
|
-
eventParamType = ts62.factory.createKeywordTypeNode(ts62.SyntaxKind.AnyKeyword);
|
|
16701
|
-
} else {
|
|
16702
|
-
eventParamType = eventType;
|
|
16904
|
+
if (tcb.boundTarget.target.template !== void 0) {
|
|
16905
|
+
const templateScope = Scope.forNodes(
|
|
16906
|
+
tcb,
|
|
16907
|
+
null,
|
|
16908
|
+
null,
|
|
16909
|
+
tcb.boundTarget.target.template,
|
|
16910
|
+
/* guard */
|
|
16911
|
+
null
|
|
16912
|
+
);
|
|
16913
|
+
statements.push(renderBlockStatements(env, templateScope, ts82.factory.createTrue()));
|
|
16703
16914
|
}
|
|
16704
|
-
|
|
16705
|
-
|
|
16706
|
-
|
|
16707
|
-
body = ts62.factory.createBlock([ts62.factory.createIfStatement(guards, body)]);
|
|
16915
|
+
if (tcb.boundTarget.target.host !== void 0) {
|
|
16916
|
+
const hostScope = Scope.forNodes(tcb, null, tcb.boundTarget.target.host.node, null, null);
|
|
16917
|
+
statements.push(renderBlockStatements(env, hostScope, createHostBindingsBlockGuard()));
|
|
16708
16918
|
}
|
|
16709
|
-
const
|
|
16919
|
+
const body = ts82.factory.createBlock(statements);
|
|
16920
|
+
const fnDecl = ts82.factory.createFunctionDeclaration(
|
|
16710
16921
|
/* modifiers */
|
|
16711
16922
|
void 0,
|
|
16712
|
-
/*
|
|
16923
|
+
/* asteriskToken */
|
|
16713
16924
|
void 0,
|
|
16714
16925
|
/* name */
|
|
16715
|
-
|
|
16716
|
-
/* questionToken */
|
|
16717
|
-
void 0,
|
|
16718
|
-
/* type */
|
|
16719
|
-
eventParamType
|
|
16720
|
-
);
|
|
16721
|
-
addExpressionIdentifier(eventParam, ExpressionIdentifier.EVENT_PARAMETER);
|
|
16722
|
-
return ts62.factory.createArrowFunction(
|
|
16723
|
-
/* modifiers */
|
|
16724
|
-
void 0,
|
|
16926
|
+
name,
|
|
16725
16927
|
/* typeParameters */
|
|
16726
|
-
void 0,
|
|
16928
|
+
env.config.useContextGenericType ? typeParameters : void 0,
|
|
16727
16929
|
/* parameters */
|
|
16728
|
-
|
|
16930
|
+
paramList,
|
|
16729
16931
|
/* type */
|
|
16730
|
-
ts62.factory.createKeywordTypeNode(ts62.SyntaxKind.AnyKeyword),
|
|
16731
|
-
/* equalsGreaterThanToken */
|
|
16732
16932
|
void 0,
|
|
16733
16933
|
/* body */
|
|
16734
16934
|
body
|
|
16735
16935
|
);
|
|
16936
|
+
addTypeCheckId(fnDecl, meta.id);
|
|
16937
|
+
return fnDecl;
|
|
16736
16938
|
}
|
|
16737
|
-
function
|
|
16738
|
-
const
|
|
16739
|
-
|
|
16740
|
-
|
|
16741
|
-
function checkSplitTwoWayBinding(inputName, output, inputs, tcb) {
|
|
16742
|
-
const input = inputs.find((input2) => input2.name === inputName);
|
|
16743
|
-
if (input === void 0 || input.sourceSpan !== output.sourceSpan) {
|
|
16744
|
-
return false;
|
|
16745
|
-
}
|
|
16746
|
-
const inputConsumer = tcb.boundTarget.getConsumerOfBinding(input);
|
|
16747
|
-
const outputConsumer = tcb.boundTarget.getConsumerOfBinding(output);
|
|
16748
|
-
if (outputConsumer === null || inputConsumer.ref === void 0 || outputConsumer instanceof TmplAstTemplate) {
|
|
16749
|
-
return false;
|
|
16750
|
-
}
|
|
16751
|
-
if (outputConsumer instanceof TmplAstElement2) {
|
|
16752
|
-
tcb.oobRecorder.splitTwoWayBinding(tcb.id, input, output, inputConsumer.ref.node, outputConsumer);
|
|
16753
|
-
return true;
|
|
16754
|
-
} else if (outputConsumer.ref !== inputConsumer.ref) {
|
|
16755
|
-
tcb.oobRecorder.splitTwoWayBinding(tcb.id, input, output, inputConsumer.ref.node, outputConsumer.ref.node);
|
|
16756
|
-
return true;
|
|
16757
|
-
}
|
|
16758
|
-
return false;
|
|
16759
|
-
}
|
|
16760
|
-
var TcbEventHandlerTranslator = class extends TcbExpressionTranslator {
|
|
16761
|
-
resolve(ast) {
|
|
16762
|
-
if (ast instanceof PropertyRead4 && ast.receiver instanceof ImplicitReceiver3 && !(ast.receiver instanceof ThisReceiver2) && ast.name === EVENT_PARAMETER) {
|
|
16763
|
-
const event = ts62.factory.createIdentifier(EVENT_PARAMETER);
|
|
16764
|
-
addParseSpanInfo(event, ast.nameSpan);
|
|
16765
|
-
return event;
|
|
16766
|
-
}
|
|
16767
|
-
return super.resolve(ast);
|
|
16768
|
-
}
|
|
16769
|
-
isValidLetDeclarationAccess() {
|
|
16770
|
-
return true;
|
|
16771
|
-
}
|
|
16772
|
-
};
|
|
16773
|
-
var TcbForLoopTrackTranslator = class extends TcbExpressionTranslator {
|
|
16774
|
-
block;
|
|
16775
|
-
allowedVariables;
|
|
16776
|
-
constructor(tcb, scope, block) {
|
|
16777
|
-
super(tcb, scope);
|
|
16778
|
-
this.block = block;
|
|
16779
|
-
this.allowedVariables = /* @__PURE__ */ new Set([block.item]);
|
|
16780
|
-
for (const variable of block.contextVariables) {
|
|
16781
|
-
if (variable.value === "$index") {
|
|
16782
|
-
this.allowedVariables.add(variable);
|
|
16783
|
-
}
|
|
16784
|
-
}
|
|
16785
|
-
}
|
|
16786
|
-
resolve(ast) {
|
|
16787
|
-
if (ast instanceof PropertyRead4 && ast.receiver instanceof ImplicitReceiver3) {
|
|
16788
|
-
const target = this.tcb.boundTarget.getExpressionTarget(ast);
|
|
16789
|
-
if (target !== null && (!(target instanceof TmplAstVariable) || !this.allowedVariables.has(target))) {
|
|
16790
|
-
this.tcb.oobRecorder.illegalForLoopTrackAccess(this.tcb.id, this.block, ast);
|
|
16791
|
-
}
|
|
16792
|
-
}
|
|
16793
|
-
return super.resolve(ast);
|
|
16794
|
-
}
|
|
16795
|
-
};
|
|
16796
|
-
function getComponentTagName(node) {
|
|
16797
|
-
return node.tagName || "ng-component";
|
|
16939
|
+
function renderBlockStatements(env, scope, wrapperExpression) {
|
|
16940
|
+
const scopeStatements = scope.render();
|
|
16941
|
+
const innerBody = ts82.factory.createBlock([...env.getPreludeStatements(), ...scopeStatements]);
|
|
16942
|
+
return ts82.factory.createIfStatement(wrapperExpression, innerBody);
|
|
16798
16943
|
}
|
|
16799
|
-
function
|
|
16800
|
-
|
|
16801
|
-
|
|
16802
|
-
|
|
16803
|
-
|
|
16804
|
-
|
|
16805
|
-
|
|
16806
|
-
|
|
16944
|
+
function tcbThisParam(name, typeArguments) {
|
|
16945
|
+
return ts82.factory.createParameterDeclaration(
|
|
16946
|
+
/* modifiers */
|
|
16947
|
+
void 0,
|
|
16948
|
+
/* dotDotDotToken */
|
|
16949
|
+
void 0,
|
|
16950
|
+
/* name */
|
|
16951
|
+
"this",
|
|
16952
|
+
/* questionToken */
|
|
16953
|
+
void 0,
|
|
16954
|
+
/* type */
|
|
16955
|
+
ts82.factory.createTypeReferenceNode(name, typeArguments),
|
|
16956
|
+
/* initializer */
|
|
16957
|
+
void 0
|
|
16958
|
+
);
|
|
16807
16959
|
}
|
|
16808
16960
|
|
|
16809
16961
|
// packages/compiler-cli/src/ngtsc/typecheck/src/type_check_file.js
|
|
16810
|
-
import
|
|
16962
|
+
import ts83 from "typescript";
|
|
16811
16963
|
var TypeCheckFile = class extends Environment {
|
|
16812
16964
|
fileName;
|
|
16813
16965
|
nextTcbId = 1;
|
|
@@ -16819,11 +16971,11 @@ var TypeCheckFile = class extends Environment {
|
|
|
16819
16971
|
// Type check block code affects code completion and fix suggestions.
|
|
16820
16972
|
// We want to encourage single quotes for now, like we always did.
|
|
16821
16973
|
shouldUseSingleQuotes: () => true
|
|
16822
|
-
}), refEmitter, reflector,
|
|
16974
|
+
}), refEmitter, reflector, ts83.createSourceFile(compilerHost.getCanonicalFileName(fileName), "", ts83.ScriptTarget.Latest, true));
|
|
16823
16975
|
this.fileName = fileName;
|
|
16824
16976
|
}
|
|
16825
16977
|
addTypeCheckBlock(ref, meta, domSchemaChecker, oobRecorder, genericContextBehavior) {
|
|
16826
|
-
const fnId =
|
|
16978
|
+
const fnId = ts83.factory.createIdentifier(`_tcb${this.nextTcbId++}`);
|
|
16827
16979
|
const fn = generateTypeCheckBlock(this, ref, fnId, meta, domSchemaChecker, oobRecorder, genericContextBehavior);
|
|
16828
16980
|
this.tcbStatements.push(fn);
|
|
16829
16981
|
}
|
|
@@ -16833,22 +16985,22 @@ var TypeCheckFile = class extends Environment {
|
|
|
16833
16985
|
if (importChanges.updatedImports.size > 0) {
|
|
16834
16986
|
throw new Error("AssertionError: Expected no imports to be updated for a new type check file.");
|
|
16835
16987
|
}
|
|
16836
|
-
const printer =
|
|
16988
|
+
const printer = ts83.createPrinter({ removeComments });
|
|
16837
16989
|
let source = "";
|
|
16838
16990
|
const newImports = importChanges.newImports.get(this.contextFile.fileName);
|
|
16839
16991
|
if (newImports !== void 0) {
|
|
16840
|
-
source += newImports.map((i) => printer.printNode(
|
|
16992
|
+
source += newImports.map((i) => printer.printNode(ts83.EmitHint.Unspecified, i, this.contextFile)).join("\n");
|
|
16841
16993
|
}
|
|
16842
16994
|
source += "\n";
|
|
16843
16995
|
for (const stmt of this.pipeInstStatements) {
|
|
16844
|
-
source += printer.printNode(
|
|
16996
|
+
source += printer.printNode(ts83.EmitHint.Unspecified, stmt, this.contextFile) + "\n";
|
|
16845
16997
|
}
|
|
16846
16998
|
for (const stmt of this.typeCtorStatements) {
|
|
16847
|
-
source += printer.printNode(
|
|
16999
|
+
source += printer.printNode(ts83.EmitHint.Unspecified, stmt, this.contextFile) + "\n";
|
|
16848
17000
|
}
|
|
16849
17001
|
source += "\n";
|
|
16850
17002
|
for (const stmt of this.tcbStatements) {
|
|
16851
|
-
source += printer.printNode(
|
|
17003
|
+
source += printer.printNode(ts83.EmitHint.Unspecified, stmt, this.contextFile) + "\n";
|
|
16852
17004
|
}
|
|
16853
17005
|
source += "\nexport const IS_A_MODULE = true;\n";
|
|
16854
17006
|
return source;
|
|
@@ -17014,7 +17166,7 @@ var TypeCheckContextImpl = class {
|
|
|
17014
17166
|
if (!this.opMap.has(sf)) {
|
|
17015
17167
|
return null;
|
|
17016
17168
|
}
|
|
17017
|
-
const printer =
|
|
17169
|
+
const printer = ts84.createPrinter({ omitTrailingSemicolon: true });
|
|
17018
17170
|
const importManager = new ImportManager({
|
|
17019
17171
|
// This minimizes noticeable changes with older versions of `ImportManager`.
|
|
17020
17172
|
forceGenerateNamespacesForNewImports: true,
|
|
@@ -17033,7 +17185,7 @@ var TypeCheckContextImpl = class {
|
|
|
17033
17185
|
newImports.get(sf.fileName).forEach((newImport) => {
|
|
17034
17186
|
updates.push({
|
|
17035
17187
|
pos: 0,
|
|
17036
|
-
text: printer.printNode(
|
|
17188
|
+
text: printer.printNode(ts84.EmitHint.Unspecified, newImport, sf)
|
|
17037
17189
|
});
|
|
17038
17190
|
});
|
|
17039
17191
|
}
|
|
@@ -17044,7 +17196,7 @@ var TypeCheckContextImpl = class {
|
|
|
17044
17196
|
updates.push({
|
|
17045
17197
|
pos: oldBindings.getStart(),
|
|
17046
17198
|
deletePos: oldBindings.getEnd(),
|
|
17047
|
-
text: printer.printNode(
|
|
17199
|
+
text: printer.printNode(ts84.EmitHint.Unspecified, newBindings, sf)
|
|
17048
17200
|
});
|
|
17049
17201
|
}
|
|
17050
17202
|
const result = new MagicString(sf.text, { filename: sf.fileName });
|
|
@@ -17132,7 +17284,7 @@ function getTemplateDiagnostics(parseErrors, templateId, sourceMapping) {
|
|
|
17132
17284
|
if (span.start.offset === span.end.offset) {
|
|
17133
17285
|
span.end.offset++;
|
|
17134
17286
|
}
|
|
17135
|
-
return makeTemplateDiagnostic(templateId, sourceMapping, span,
|
|
17287
|
+
return makeTemplateDiagnostic(templateId, sourceMapping, span, ts84.DiagnosticCategory.Error, ngErrorCode(ErrorCode.TEMPLATE_PARSE_ERROR), error.msg);
|
|
17136
17288
|
});
|
|
17137
17289
|
}
|
|
17138
17290
|
var InlineTcbOp = class {
|
|
@@ -17158,9 +17310,9 @@ var InlineTcbOp = class {
|
|
|
17158
17310
|
}
|
|
17159
17311
|
execute(im, sf, refEmitter, printer) {
|
|
17160
17312
|
const env = new Environment(this.config, im, refEmitter, this.reflector, sf);
|
|
17161
|
-
const fnName =
|
|
17313
|
+
const fnName = ts84.factory.createIdentifier(`_tcb_${this.ref.node.pos}`);
|
|
17162
17314
|
const fn = generateTypeCheckBlock(env, this.ref, fnName, this.meta, this.domSchemaChecker, this.oobRecorder, TcbGenericContextBehavior.CopyClassNodes);
|
|
17163
|
-
return printer.printNode(
|
|
17315
|
+
return printer.printNode(ts84.EmitHint.Unspecified, fn, sf);
|
|
17164
17316
|
}
|
|
17165
17317
|
};
|
|
17166
17318
|
var TypeCtorOp = class {
|
|
@@ -17181,7 +17333,7 @@ var TypeCtorOp = class {
|
|
|
17181
17333
|
execute(im, sf, refEmitter, printer) {
|
|
17182
17334
|
const emitEnv = new ReferenceEmitEnvironment(im, refEmitter, this.reflector, sf);
|
|
17183
17335
|
const tcb = generateInlineTypeCtor(emitEnv, this.ref.node, this.meta);
|
|
17184
|
-
return printer.printNode(
|
|
17336
|
+
return printer.printNode(ts84.EmitHint.Unspecified, tcb, sf);
|
|
17185
17337
|
}
|
|
17186
17338
|
};
|
|
17187
17339
|
|
|
@@ -17302,8 +17454,8 @@ var DirectiveSourceManager = class {
|
|
|
17302
17454
|
};
|
|
17303
17455
|
|
|
17304
17456
|
// packages/compiler-cli/src/ngtsc/typecheck/src/template_symbol_builder.js
|
|
17305
|
-
import { AST, ASTWithName as ASTWithName2, ASTWithSource as ASTWithSource2, Binary as Binary2, BindingPipe as BindingPipe2, PropertyRead as
|
|
17306
|
-
import
|
|
17457
|
+
import { AST, ASTWithName as ASTWithName2, ASTWithSource as ASTWithSource2, Binary as Binary2, BindingPipe as BindingPipe2, PropertyRead as PropertyRead8, R3Identifiers as R3Identifiers6, SafePropertyRead as SafePropertyRead4, TmplAstBoundAttribute as TmplAstBoundAttribute5, TmplAstBoundEvent as TmplAstBoundEvent3, TmplAstComponent as TmplAstComponent4, TmplAstDirective as TmplAstDirective3, TmplAstElement as TmplAstElement9, TmplAstLetDeclaration as TmplAstLetDeclaration4, TmplAstReference as TmplAstReference3, TmplAstTemplate as TmplAstTemplate6, TmplAstTextAttribute as TmplAstTextAttribute2, TmplAstVariable as TmplAstVariable3 } from "@angular/compiler";
|
|
17458
|
+
import ts85 from "typescript";
|
|
17307
17459
|
var SymbolBuilder = class {
|
|
17308
17460
|
tcbPath;
|
|
17309
17461
|
tcbIsShim;
|
|
@@ -17325,21 +17477,21 @@ var SymbolBuilder = class {
|
|
|
17325
17477
|
return this.symbolCache.get(node);
|
|
17326
17478
|
}
|
|
17327
17479
|
let symbol = null;
|
|
17328
|
-
if (node instanceof
|
|
17480
|
+
if (node instanceof TmplAstBoundAttribute5 || node instanceof TmplAstTextAttribute2) {
|
|
17329
17481
|
symbol = this.getSymbolOfInputBinding(node);
|
|
17330
17482
|
} else if (node instanceof TmplAstBoundEvent3) {
|
|
17331
17483
|
symbol = this.getSymbolOfBoundEvent(node);
|
|
17332
|
-
} else if (node instanceof
|
|
17484
|
+
} else if (node instanceof TmplAstElement9) {
|
|
17333
17485
|
symbol = this.getSymbolOfElement(node);
|
|
17334
|
-
} else if (node instanceof
|
|
17486
|
+
} else if (node instanceof TmplAstComponent4) {
|
|
17335
17487
|
symbol = this.getSymbolOfSelectorlessComponent(node);
|
|
17336
17488
|
} else if (node instanceof TmplAstDirective3) {
|
|
17337
17489
|
symbol = this.getSymbolOfSelectorlessDirective(node);
|
|
17338
|
-
} else if (node instanceof
|
|
17490
|
+
} else if (node instanceof TmplAstTemplate6) {
|
|
17339
17491
|
symbol = this.getSymbolOfAstTemplate(node);
|
|
17340
|
-
} else if (node instanceof
|
|
17492
|
+
} else if (node instanceof TmplAstVariable3) {
|
|
17341
17493
|
symbol = this.getSymbolOfVariable(node);
|
|
17342
|
-
} else if (node instanceof
|
|
17494
|
+
} else if (node instanceof TmplAstLetDeclaration4) {
|
|
17343
17495
|
symbol = this.getSymbolOfLetDeclaration(node);
|
|
17344
17496
|
} else if (node instanceof TmplAstReference3) {
|
|
17345
17497
|
symbol = this.getSymbolOfReference(node);
|
|
@@ -17360,7 +17512,7 @@ var SymbolBuilder = class {
|
|
|
17360
17512
|
const elementSourceSpan = element.startSourceSpan ?? element.sourceSpan;
|
|
17361
17513
|
const node = findFirstMatchingNode(this.typeCheckBlock, {
|
|
17362
17514
|
withSpan: elementSourceSpan,
|
|
17363
|
-
filter:
|
|
17515
|
+
filter: ts85.isVariableDeclaration
|
|
17364
17516
|
});
|
|
17365
17517
|
if (node === null) {
|
|
17366
17518
|
return null;
|
|
@@ -17417,7 +17569,7 @@ var SymbolBuilder = class {
|
|
|
17417
17569
|
const seenDirectives = /* @__PURE__ */ new Set();
|
|
17418
17570
|
for (const node of nodes) {
|
|
17419
17571
|
const symbol = this.getSymbolOfTsNode(node.parent);
|
|
17420
|
-
if (symbol === null || !isSymbolWithValueDeclaration(symbol.tsSymbol) || !
|
|
17572
|
+
if (symbol === null || !isSymbolWithValueDeclaration(symbol.tsSymbol) || !ts85.isClassDeclaration(symbol.tsSymbol.valueDeclaration)) {
|
|
17421
17573
|
continue;
|
|
17422
17574
|
}
|
|
17423
17575
|
const declaration = symbol.tsSymbol.valueDeclaration;
|
|
@@ -17452,7 +17604,7 @@ var SymbolBuilder = class {
|
|
|
17452
17604
|
throw new Error("Impossible state: typecheck code path in local compilation mode.");
|
|
17453
17605
|
}
|
|
17454
17606
|
const node = current.directive.node;
|
|
17455
|
-
if (!
|
|
17607
|
+
if (!ts85.isClassDeclaration(node) || seenDirectives.has(node)) {
|
|
17456
17608
|
continue;
|
|
17457
17609
|
}
|
|
17458
17610
|
const symbol = this.getSymbolOfTsNode(node);
|
|
@@ -17485,8 +17637,8 @@ var SymbolBuilder = class {
|
|
|
17485
17637
|
let directives = this.typeCheckData.boundTarget.getDirectivesOfNode(host);
|
|
17486
17638
|
if (!(host instanceof TmplAstDirective3)) {
|
|
17487
17639
|
const firstChild = host.children[0];
|
|
17488
|
-
if (firstChild instanceof
|
|
17489
|
-
const isMicrosyntaxTemplate = host instanceof
|
|
17640
|
+
if (firstChild instanceof TmplAstElement9) {
|
|
17641
|
+
const isMicrosyntaxTemplate = host instanceof TmplAstTemplate6 && sourceSpanEqual(firstChild.sourceSpan, host.sourceSpan);
|
|
17490
17642
|
if (isMicrosyntaxTemplate) {
|
|
17491
17643
|
const firstChildDirectives = this.typeCheckData.boundTarget.getDirectivesOfNode(firstChild);
|
|
17492
17644
|
if (firstChildDirectives !== null && directives !== null) {
|
|
@@ -17529,7 +17681,7 @@ var SymbolBuilder = class {
|
|
|
17529
17681
|
return null;
|
|
17530
17682
|
}
|
|
17531
17683
|
let expectedAccess;
|
|
17532
|
-
if (consumer instanceof
|
|
17684
|
+
if (consumer instanceof TmplAstTemplate6 || consumer instanceof TmplAstElement9) {
|
|
17533
17685
|
expectedAccess = "addEventListener";
|
|
17534
17686
|
} else {
|
|
17535
17687
|
const bindingPropertyNames = consumer.outputs.getByBindingPropertyName(eventBinding.name);
|
|
@@ -17542,10 +17694,10 @@ var SymbolBuilder = class {
|
|
|
17542
17694
|
if (!isAccessExpression(n2)) {
|
|
17543
17695
|
return false;
|
|
17544
17696
|
}
|
|
17545
|
-
if (
|
|
17697
|
+
if (ts85.isPropertyAccessExpression(n2)) {
|
|
17546
17698
|
return n2.name.getText() === expectedAccess;
|
|
17547
17699
|
} else {
|
|
17548
|
-
return
|
|
17700
|
+
return ts85.isStringLiteral(n2.argumentExpression) && n2.argumentExpression.text === expectedAccess;
|
|
17549
17701
|
}
|
|
17550
17702
|
}
|
|
17551
17703
|
const outputFieldAccesses = findAllMatchingNodes(this.typeCheckBlock, {
|
|
@@ -17554,8 +17706,8 @@ var SymbolBuilder = class {
|
|
|
17554
17706
|
});
|
|
17555
17707
|
const bindings = [];
|
|
17556
17708
|
for (const outputFieldAccess of outputFieldAccesses) {
|
|
17557
|
-
if (consumer instanceof
|
|
17558
|
-
if (!
|
|
17709
|
+
if (consumer instanceof TmplAstTemplate6 || consumer instanceof TmplAstElement9) {
|
|
17710
|
+
if (!ts85.isPropertyAccessExpression(outputFieldAccess)) {
|
|
17559
17711
|
continue;
|
|
17560
17712
|
}
|
|
17561
17713
|
const addEventListener = outputFieldAccess.name;
|
|
@@ -17578,7 +17730,7 @@ var SymbolBuilder = class {
|
|
|
17578
17730
|
}
|
|
17579
17731
|
});
|
|
17580
17732
|
} else {
|
|
17581
|
-
if (!
|
|
17733
|
+
if (!ts85.isElementAccessExpression(outputFieldAccess)) {
|
|
17582
17734
|
continue;
|
|
17583
17735
|
}
|
|
17584
17736
|
const tsSymbol = this.getTypeChecker().getSymbolAtLocation(outputFieldAccess.argumentExpression);
|
|
@@ -17614,7 +17766,7 @@ var SymbolBuilder = class {
|
|
|
17614
17766
|
if (consumer === null) {
|
|
17615
17767
|
return null;
|
|
17616
17768
|
}
|
|
17617
|
-
if (consumer instanceof
|
|
17769
|
+
if (consumer instanceof TmplAstElement9 || consumer instanceof TmplAstTemplate6) {
|
|
17618
17770
|
const host = this.getSymbol(consumer);
|
|
17619
17771
|
return host !== null ? { kind: SymbolKind.DomBinding, host } : null;
|
|
17620
17772
|
}
|
|
@@ -17631,7 +17783,7 @@ var SymbolBuilder = class {
|
|
|
17631
17783
|
let fieldAccessExpr;
|
|
17632
17784
|
let symbolInfo = null;
|
|
17633
17785
|
if (signalInputAssignment !== null) {
|
|
17634
|
-
if (
|
|
17786
|
+
if (ts85.isIdentifier(signalInputAssignment.fieldExpr)) {
|
|
17635
17787
|
continue;
|
|
17636
17788
|
}
|
|
17637
17789
|
const fieldSymbol = this.getSymbolOfTsNode(signalInputAssignment.fieldExpr);
|
|
@@ -17671,7 +17823,7 @@ var SymbolBuilder = class {
|
|
|
17671
17823
|
return null;
|
|
17672
17824
|
}
|
|
17673
17825
|
const [declaration] = tsSymbol.declarations;
|
|
17674
|
-
if (!
|
|
17826
|
+
if (!ts85.isVariableDeclaration(declaration) || !hasExpressionIdentifier(
|
|
17675
17827
|
// The expression identifier could be on the type (for regular directives) or the name
|
|
17676
17828
|
// (for generic directives and the ctor op).
|
|
17677
17829
|
declaration.getSourceFile(),
|
|
@@ -17681,7 +17833,7 @@ var SymbolBuilder = class {
|
|
|
17681
17833
|
return null;
|
|
17682
17834
|
}
|
|
17683
17835
|
const symbol = this.getSymbolOfTsNode(declaration);
|
|
17684
|
-
if (symbol === null || !isSymbolWithValueDeclaration(symbol.tsSymbol) || !
|
|
17836
|
+
if (symbol === null || !isSymbolWithValueDeclaration(symbol.tsSymbol) || !ts85.isClassDeclaration(symbol.tsSymbol.valueDeclaration)) {
|
|
17685
17837
|
return null;
|
|
17686
17838
|
}
|
|
17687
17839
|
const ref = new Reference(symbol.tsSymbol.valueDeclaration);
|
|
@@ -17705,13 +17857,13 @@ var SymbolBuilder = class {
|
|
|
17705
17857
|
getSymbolOfVariable(variable) {
|
|
17706
17858
|
const node = findFirstMatchingNode(this.typeCheckBlock, {
|
|
17707
17859
|
withSpan: variable.sourceSpan,
|
|
17708
|
-
filter:
|
|
17860
|
+
filter: ts85.isVariableDeclaration
|
|
17709
17861
|
});
|
|
17710
17862
|
if (node === null) {
|
|
17711
17863
|
return null;
|
|
17712
17864
|
}
|
|
17713
17865
|
let nodeValueSymbol = null;
|
|
17714
|
-
if (
|
|
17866
|
+
if (ts85.isForOfStatement(node.parent.parent)) {
|
|
17715
17867
|
nodeValueSymbol = this.getSymbolOfTsNode(node);
|
|
17716
17868
|
} else if (node.initializer !== void 0) {
|
|
17717
17869
|
nodeValueSymbol = this.getSymbolOfTsNode(node.initializer);
|
|
@@ -17736,12 +17888,12 @@ var SymbolBuilder = class {
|
|
|
17736
17888
|
const target = this.typeCheckData.boundTarget.getReferenceTarget(ref);
|
|
17737
17889
|
let node = findFirstMatchingNode(this.typeCheckBlock, {
|
|
17738
17890
|
withSpan: ref.sourceSpan,
|
|
17739
|
-
filter:
|
|
17891
|
+
filter: ts85.isVariableDeclaration
|
|
17740
17892
|
});
|
|
17741
17893
|
if (node === null || target === null || node.initializer === void 0) {
|
|
17742
17894
|
return null;
|
|
17743
17895
|
}
|
|
17744
|
-
const originalDeclaration =
|
|
17896
|
+
const originalDeclaration = ts85.isParenthesizedExpression(node.initializer) && ts85.isAsExpression(node.initializer.expression) ? this.getTypeChecker().getSymbolAtLocation(node.name) : this.getTypeChecker().getSymbolAtLocation(node.initializer);
|
|
17745
17897
|
if (originalDeclaration === void 0 || originalDeclaration.valueDeclaration === void 0) {
|
|
17746
17898
|
return null;
|
|
17747
17899
|
}
|
|
@@ -17754,7 +17906,7 @@ var SymbolBuilder = class {
|
|
|
17754
17906
|
isShimFile: this.tcbIsShim,
|
|
17755
17907
|
positionInFile: this.getTcbPositionForNode(node)
|
|
17756
17908
|
};
|
|
17757
|
-
if (target instanceof
|
|
17909
|
+
if (target instanceof TmplAstTemplate6 || target instanceof TmplAstElement9) {
|
|
17758
17910
|
return {
|
|
17759
17911
|
kind: SymbolKind.Reference,
|
|
17760
17912
|
tsSymbol: symbol.tsSymbol,
|
|
@@ -17765,7 +17917,7 @@ var SymbolBuilder = class {
|
|
|
17765
17917
|
referenceVarLocation: referenceVarTcbLocation
|
|
17766
17918
|
};
|
|
17767
17919
|
} else {
|
|
17768
|
-
if (!
|
|
17920
|
+
if (!ts85.isClassDeclaration(target.directive.ref.node)) {
|
|
17769
17921
|
return null;
|
|
17770
17922
|
}
|
|
17771
17923
|
return {
|
|
@@ -17782,7 +17934,7 @@ var SymbolBuilder = class {
|
|
|
17782
17934
|
getSymbolOfLetDeclaration(decl) {
|
|
17783
17935
|
const node = findFirstMatchingNode(this.typeCheckBlock, {
|
|
17784
17936
|
withSpan: decl.sourceSpan,
|
|
17785
|
-
filter:
|
|
17937
|
+
filter: ts85.isVariableDeclaration
|
|
17786
17938
|
});
|
|
17787
17939
|
if (node === null) {
|
|
17788
17940
|
return null;
|
|
@@ -17807,7 +17959,7 @@ var SymbolBuilder = class {
|
|
|
17807
17959
|
getSymbolOfPipe(expression) {
|
|
17808
17960
|
const methodAccess = findFirstMatchingNode(this.typeCheckBlock, {
|
|
17809
17961
|
withSpan: expression.nameSpan,
|
|
17810
|
-
filter:
|
|
17962
|
+
filter: ts85.isPropertyAccessExpression
|
|
17811
17963
|
});
|
|
17812
17964
|
if (methodAccess === null) {
|
|
17813
17965
|
return null;
|
|
@@ -17843,16 +17995,16 @@ var SymbolBuilder = class {
|
|
|
17843
17995
|
return this.getSymbol(expressionTarget);
|
|
17844
17996
|
}
|
|
17845
17997
|
let withSpan = expression.sourceSpan;
|
|
17846
|
-
if (expression instanceof Binary2 && Binary2.isAssignmentOperation(expression.operation) && expression.left instanceof
|
|
17998
|
+
if (expression instanceof Binary2 && Binary2.isAssignmentOperation(expression.operation) && expression.left instanceof PropertyRead8) {
|
|
17847
17999
|
withSpan = expression.left.nameSpan;
|
|
17848
18000
|
} else if (expression instanceof ASTWithName2 && !(expression instanceof SafePropertyRead4)) {
|
|
17849
18001
|
withSpan = expression.nameSpan;
|
|
17850
18002
|
}
|
|
17851
18003
|
let node = null;
|
|
17852
|
-
if (expression instanceof
|
|
18004
|
+
if (expression instanceof PropertyRead8) {
|
|
17853
18005
|
node = findFirstMatchingNode(this.typeCheckBlock, {
|
|
17854
18006
|
withSpan,
|
|
17855
|
-
filter:
|
|
18007
|
+
filter: ts85.isPropertyAccessExpression
|
|
17856
18008
|
});
|
|
17857
18009
|
}
|
|
17858
18010
|
if (node === null) {
|
|
@@ -17861,10 +18013,10 @@ var SymbolBuilder = class {
|
|
|
17861
18013
|
if (node === null) {
|
|
17862
18014
|
return null;
|
|
17863
18015
|
}
|
|
17864
|
-
while (
|
|
18016
|
+
while (ts85.isParenthesizedExpression(node)) {
|
|
17865
18017
|
node = node.expression;
|
|
17866
18018
|
}
|
|
17867
|
-
if (expression instanceof SafePropertyRead4 &&
|
|
18019
|
+
if (expression instanceof SafePropertyRead4 && ts85.isConditionalExpression(node)) {
|
|
17868
18020
|
const whenTrueSymbol = this.getSymbolOfTsNode(node.whenTrue);
|
|
17869
18021
|
if (whenTrueSymbol === null) {
|
|
17870
18022
|
return null;
|
|
@@ -17882,13 +18034,13 @@ var SymbolBuilder = class {
|
|
|
17882
18034
|
}
|
|
17883
18035
|
}
|
|
17884
18036
|
getSymbolOfTsNode(node) {
|
|
17885
|
-
while (
|
|
18037
|
+
while (ts85.isParenthesizedExpression(node)) {
|
|
17886
18038
|
node = node.expression;
|
|
17887
18039
|
}
|
|
17888
18040
|
let tsSymbol;
|
|
17889
|
-
if (
|
|
18041
|
+
if (ts85.isPropertyAccessExpression(node)) {
|
|
17890
18042
|
tsSymbol = this.getTypeChecker().getSymbolAtLocation(node.name);
|
|
17891
|
-
} else if (
|
|
18043
|
+
} else if (ts85.isCallExpression(node)) {
|
|
17892
18044
|
tsSymbol = this.getTypeChecker().getSymbolAtLocation(node.expression);
|
|
17893
18045
|
} else {
|
|
17894
18046
|
tsSymbol = this.getTypeChecker().getSymbolAtLocation(node);
|
|
@@ -17909,13 +18061,13 @@ var SymbolBuilder = class {
|
|
|
17909
18061
|
};
|
|
17910
18062
|
}
|
|
17911
18063
|
getTcbPositionForNode(node) {
|
|
17912
|
-
if (
|
|
18064
|
+
if (ts85.isTypeReferenceNode(node)) {
|
|
17913
18065
|
return this.getTcbPositionForNode(node.typeName);
|
|
17914
|
-
} else if (
|
|
18066
|
+
} else if (ts85.isQualifiedName(node)) {
|
|
17915
18067
|
return node.right.getStart();
|
|
17916
|
-
} else if (
|
|
18068
|
+
} else if (ts85.isPropertyAccessExpression(node)) {
|
|
17917
18069
|
return node.name.getStart();
|
|
17918
|
-
} else if (
|
|
18070
|
+
} else if (ts85.isElementAccessExpression(node)) {
|
|
17919
18071
|
return node.argumentExpression.getStart();
|
|
17920
18072
|
} else {
|
|
17921
18073
|
return node.getStart();
|
|
@@ -17929,13 +18081,13 @@ function sourceSpanEqual(a, b) {
|
|
|
17929
18081
|
return a.start.offset === b.start.offset && a.end.offset === b.end.offset;
|
|
17930
18082
|
}
|
|
17931
18083
|
function unwrapSignalInputWriteTAccessor(expr) {
|
|
17932
|
-
if (!
|
|
18084
|
+
if (!ts85.isElementAccessExpression(expr) || !ts85.isPropertyAccessExpression(expr.argumentExpression)) {
|
|
17933
18085
|
return null;
|
|
17934
18086
|
}
|
|
17935
|
-
if (!
|
|
18087
|
+
if (!ts85.isIdentifier(expr.argumentExpression.name) || expr.argumentExpression.name.text !== R3Identifiers6.InputSignalBrandWriteType.name) {
|
|
17936
18088
|
return null;
|
|
17937
18089
|
}
|
|
17938
|
-
if (!
|
|
18090
|
+
if (!ts85.isPropertyAccessExpression(expr.expression) && !ts85.isElementAccessExpression(expr.expression) && !ts85.isIdentifier(expr.expression)) {
|
|
17939
18091
|
throw new Error("Unexpected expression for signal input write type.");
|
|
17940
18092
|
}
|
|
17941
18093
|
return {
|
|
@@ -17952,10 +18104,10 @@ function findMatchingDirective(originalSourceFile, directiveDeclarationInTypeChe
|
|
|
17952
18104
|
function collectClassesWithName(sourceFile, className) {
|
|
17953
18105
|
const classes = [];
|
|
17954
18106
|
function visit2(node) {
|
|
17955
|
-
if (
|
|
18107
|
+
if (ts85.isClassDeclaration(node) && node.name?.text === className) {
|
|
17956
18108
|
classes.push(node);
|
|
17957
18109
|
}
|
|
17958
|
-
|
|
18110
|
+
ts85.forEachChild(node, visit2);
|
|
17959
18111
|
}
|
|
17960
18112
|
sourceFile.forEachChild(visit2);
|
|
17961
18113
|
return classes;
|
|
@@ -18984,11 +19136,11 @@ function getClassDeclFromSymbol(symbol, checker) {
|
|
|
18984
19136
|
if (decl === void 0) {
|
|
18985
19137
|
return null;
|
|
18986
19138
|
}
|
|
18987
|
-
if (
|
|
19139
|
+
if (ts86.isExportAssignment(decl)) {
|
|
18988
19140
|
const symbol2 = checker.getTypeAtLocation(decl.expression).getSymbol();
|
|
18989
19141
|
return getClassDeclFromSymbol(symbol2, checker);
|
|
18990
19142
|
}
|
|
18991
|
-
if (
|
|
19143
|
+
if (ts86.isExportSpecifier(decl)) {
|
|
18992
19144
|
const symbol2 = checker.getTypeAtLocation(decl).getSymbol();
|
|
18993
19145
|
return getClassDeclFromSymbol(symbol2, checker);
|
|
18994
19146
|
}
|
|
@@ -19021,7 +19173,7 @@ function getTheElementTagDeprecatedSuggestionDiagnostics(shimPath, program, file
|
|
|
19021
19173
|
const nodeType = typeChecker.getTypeAtLocation(diagNode);
|
|
19022
19174
|
const nodeSymbolDeclarations = nodeType.getSymbol()?.declarations;
|
|
19023
19175
|
const decl = nodeSymbolDeclarations !== void 0 && nodeSymbolDeclarations.length > 0 ? nodeSymbolDeclarations[0] : void 0;
|
|
19024
|
-
if (decl === void 0 || !
|
|
19176
|
+
if (decl === void 0 || !ts86.isClassDeclaration(decl)) {
|
|
19025
19177
|
continue;
|
|
19026
19178
|
}
|
|
19027
19179
|
const directiveForDiagnostic = templateTypeChecker.getDirectiveMetadata(decl);
|
|
@@ -19041,7 +19193,7 @@ function getTheElementTagDeprecatedSuggestionDiagnostics(shimPath, program, file
|
|
|
19041
19193
|
if (decl === void 0) {
|
|
19042
19194
|
continue;
|
|
19043
19195
|
}
|
|
19044
|
-
if (!
|
|
19196
|
+
if (!ts86.isClassDeclaration(decl)) {
|
|
19045
19197
|
continue;
|
|
19046
19198
|
}
|
|
19047
19199
|
const diagnostic = nodeToDiag.get(decl);
|
|
@@ -19320,7 +19472,7 @@ var DirectiveDecoratorHandler = class {
|
|
|
19320
19472
|
if (!this.typeCheckHostBindings) {
|
|
19321
19473
|
return;
|
|
19322
19474
|
}
|
|
19323
|
-
if (!
|
|
19475
|
+
if (!ts87.isClassDeclaration(node) || meta.isPoisoned && !this.usePoisonedData) {
|
|
19324
19476
|
return;
|
|
19325
19477
|
}
|
|
19326
19478
|
const ref = new Reference(node);
|
|
@@ -19429,17 +19581,17 @@ var DirectiveDecoratorHandler = class {
|
|
|
19429
19581
|
};
|
|
19430
19582
|
|
|
19431
19583
|
// packages/compiler-cli/src/ngtsc/annotations/ng_module/src/handler.js
|
|
19432
|
-
import { compileClassMetadata as compileClassMetadata2, compileDeclareClassMetadata as compileDeclareClassMetadata2, compileDeclareInjectorFromMetadata, compileDeclareNgModuleFromMetadata, compileInjector, compileNgModule, ExternalExpr as ExternalExpr9, FactoryTarget as FactoryTarget2, FunctionExpr, InvokeFunctionExpr, LiteralArrayExpr as LiteralArrayExpr3, R3Identifiers as
|
|
19433
|
-
import
|
|
19584
|
+
import { compileClassMetadata as compileClassMetadata2, compileDeclareClassMetadata as compileDeclareClassMetadata2, compileDeclareInjectorFromMetadata, compileDeclareNgModuleFromMetadata, compileInjector, compileNgModule, ExternalExpr as ExternalExpr9, FactoryTarget as FactoryTarget2, FunctionExpr, InvokeFunctionExpr, LiteralArrayExpr as LiteralArrayExpr3, R3Identifiers as R3Identifiers7, R3NgModuleMetadataKind, R3SelectorScopeMode, ReturnStatement, WrappedNodeExpr as WrappedNodeExpr10 } from "@angular/compiler";
|
|
19585
|
+
import ts89 from "typescript";
|
|
19434
19586
|
|
|
19435
19587
|
// packages/compiler-cli/src/ngtsc/annotations/ng_module/src/module_with_providers.js
|
|
19436
|
-
import
|
|
19588
|
+
import ts88 from "typescript";
|
|
19437
19589
|
function createModuleWithProvidersResolver(reflector, isCore) {
|
|
19438
19590
|
function _reflectModuleFromTypeParam(type, node) {
|
|
19439
|
-
if (!
|
|
19591
|
+
if (!ts88.isTypeReferenceNode(type)) {
|
|
19440
19592
|
return null;
|
|
19441
19593
|
}
|
|
19442
|
-
const typeName = type && (
|
|
19594
|
+
const typeName = type && (ts88.isIdentifier(type.typeName) && type.typeName || ts88.isQualifiedName(type.typeName) && type.typeName.right) || null;
|
|
19443
19595
|
if (typeName === null) {
|
|
19444
19596
|
return null;
|
|
19445
19597
|
}
|
|
@@ -19451,7 +19603,7 @@ function createModuleWithProvidersResolver(reflector, isCore) {
|
|
|
19451
19603
|
return null;
|
|
19452
19604
|
}
|
|
19453
19605
|
if (type.typeArguments === void 0 || type.typeArguments.length !== 1) {
|
|
19454
|
-
const parent =
|
|
19606
|
+
const parent = ts88.isMethodDeclaration(node) && ts88.isClassDeclaration(node.parent) ? node.parent : null;
|
|
19455
19607
|
const symbolName = (parent && parent.name ? parent.name.getText() + "." : "") + (node.name ? node.name.getText() : "anonymous");
|
|
19456
19608
|
throw new FatalDiagnosticError(ErrorCode.NGMODULE_MODULE_WITH_PROVIDERS_MISSING_GENERIC, type, `${symbolName} returns a ModuleWithProviders type without a generic type argument. Please add a generic type argument to the ModuleWithProviders type. If this occurrence is in library code you don't control, please contact the library authors.`);
|
|
19457
19609
|
}
|
|
@@ -19459,15 +19611,15 @@ function createModuleWithProvidersResolver(reflector, isCore) {
|
|
|
19459
19611
|
return typeNodeToValueExpr(arg);
|
|
19460
19612
|
}
|
|
19461
19613
|
function _reflectModuleFromLiteralType(type) {
|
|
19462
|
-
if (!
|
|
19614
|
+
if (!ts88.isIntersectionTypeNode(type)) {
|
|
19463
19615
|
return null;
|
|
19464
19616
|
}
|
|
19465
19617
|
for (const t of type.types) {
|
|
19466
|
-
if (
|
|
19618
|
+
if (ts88.isTypeLiteralNode(t)) {
|
|
19467
19619
|
for (const m of t.members) {
|
|
19468
|
-
const ngModuleType =
|
|
19620
|
+
const ngModuleType = ts88.isPropertySignature(m) && ts88.isIdentifier(m.name) && m.name.text === "ngModule" && m.type || null;
|
|
19469
19621
|
let ngModuleExpression = null;
|
|
19470
|
-
if (ngModuleType !== null &&
|
|
19622
|
+
if (ngModuleType !== null && ts88.isTypeQueryNode(ngModuleType)) {
|
|
19471
19623
|
ngModuleExpression = entityNameToValue(ngModuleType.exprName);
|
|
19472
19624
|
} else if (ngModuleType !== null) {
|
|
19473
19625
|
ngModuleExpression = typeNodeToValueExpr(ngModuleType);
|
|
@@ -19645,8 +19797,8 @@ var NgModuleDecoratorHandler = class {
|
|
|
19645
19797
|
if (decorator.args === null || decorator.args.length > 1) {
|
|
19646
19798
|
throw new FatalDiagnosticError(ErrorCode.DECORATOR_ARITY_WRONG, decorator.node, `Incorrect number of arguments to @NgModule decorator`);
|
|
19647
19799
|
}
|
|
19648
|
-
const meta = decorator.args.length === 1 ? unwrapExpression(decorator.args[0]) :
|
|
19649
|
-
if (!
|
|
19800
|
+
const meta = decorator.args.length === 1 ? unwrapExpression(decorator.args[0]) : ts89.factory.createObjectLiteralExpression([]);
|
|
19801
|
+
if (!ts89.isObjectLiteralExpression(meta)) {
|
|
19650
19802
|
throw new FatalDiagnosticError(ErrorCode.DECORATOR_ARG_NOT_LITERAL, meta, "@NgModule argument must be an object literal");
|
|
19651
19803
|
}
|
|
19652
19804
|
const ngModule = reflectObjectLiteral(meta);
|
|
@@ -19733,7 +19885,7 @@ var NgModuleDecoratorHandler = class {
|
|
|
19733
19885
|
id = new WrappedNodeExpr10(idExpr);
|
|
19734
19886
|
} else {
|
|
19735
19887
|
const diag = makeDiagnostic(ErrorCode.WARN_NGMODULE_ID_UNNECESSARY, idExpr, `Using 'module.id' for NgModule.id is a common anti-pattern that is ignored by the Angular compiler.`);
|
|
19736
|
-
diag.category =
|
|
19888
|
+
diag.category = ts89.DiagnosticCategory.Warning;
|
|
19737
19889
|
diagnostics.push(diag);
|
|
19738
19890
|
}
|
|
19739
19891
|
}
|
|
@@ -19793,16 +19945,16 @@ var NgModuleDecoratorHandler = class {
|
|
|
19793
19945
|
}
|
|
19794
19946
|
const rawProviders = ngModule.has("providers") ? ngModule.get("providers") : null;
|
|
19795
19947
|
let wrappedProviders = null;
|
|
19796
|
-
if (rawProviders !== null && (!
|
|
19948
|
+
if (rawProviders !== null && (!ts89.isArrayLiteralExpression(rawProviders) || rawProviders.elements.length > 0)) {
|
|
19797
19949
|
wrappedProviders = new WrappedNodeExpr10(this.annotateForClosureCompiler ? wrapFunctionExpressionsInParens(rawProviders) : rawProviders);
|
|
19798
19950
|
}
|
|
19799
19951
|
const topLevelImports = [];
|
|
19800
19952
|
if (!allowUnresolvedReferences && ngModule.has("imports")) {
|
|
19801
19953
|
const rawImports2 = unwrapExpression(ngModule.get("imports"));
|
|
19802
19954
|
let topLevelExpressions = [];
|
|
19803
|
-
if (
|
|
19955
|
+
if (ts89.isArrayLiteralExpression(rawImports2)) {
|
|
19804
19956
|
for (const element of rawImports2.elements) {
|
|
19805
|
-
if (
|
|
19957
|
+
if (ts89.isSpreadElement(element)) {
|
|
19806
19958
|
topLevelExpressions.push(element.expression);
|
|
19807
19959
|
continue;
|
|
19808
19960
|
}
|
|
@@ -19842,7 +19994,7 @@ var NgModuleDecoratorHandler = class {
|
|
|
19842
19994
|
if (exp === null) {
|
|
19843
19995
|
continue;
|
|
19844
19996
|
}
|
|
19845
|
-
if (
|
|
19997
|
+
if (ts89.isArrayLiteralExpression(exp)) {
|
|
19846
19998
|
if (exp.elements) {
|
|
19847
19999
|
injectorMetadata.imports.push(...exp.elements.map((n2) => new WrappedNodeExpr10(n2)));
|
|
19848
20000
|
}
|
|
@@ -20072,7 +20224,7 @@ var NgModuleDecoratorHandler = class {
|
|
|
20072
20224
|
const componentType = this.refEmitter.emit(decl, context);
|
|
20073
20225
|
assertSuccessfulReferenceEmit(componentType, node, "component");
|
|
20074
20226
|
const declExpr = componentType.expression;
|
|
20075
|
-
const setComponentScope = new ExternalExpr9(
|
|
20227
|
+
const setComponentScope = new ExternalExpr9(R3Identifiers7.setComponentScope);
|
|
20076
20228
|
const callExpr = new InvokeFunctionExpr(setComponentScope, [
|
|
20077
20229
|
declExpr,
|
|
20078
20230
|
directiveExpr,
|
|
@@ -20173,7 +20325,7 @@ function isNgModule(node, compilation) {
|
|
|
20173
20325
|
return !compilation.dependencies.some((dep) => dep.ref.node === node);
|
|
20174
20326
|
}
|
|
20175
20327
|
function isModuleIdExpression(expr) {
|
|
20176
|
-
return
|
|
20328
|
+
return ts89.isPropertyAccessExpression(expr) && ts89.isIdentifier(expr.expression) && expr.expression.text === "module" && expr.name.text === "id";
|
|
20177
20329
|
}
|
|
20178
20330
|
function makeStandaloneBootstrapDiagnostic(ngModuleClass, bootstrappedClassRef, rawBootstrapExpr) {
|
|
20179
20331
|
const componentClassName = bootstrappedClassRef.node.name.text;
|
|
@@ -20246,7 +20398,7 @@ var ComponentSymbol = class _ComponentSymbol extends DirectiveSymbol {
|
|
|
20246
20398
|
};
|
|
20247
20399
|
|
|
20248
20400
|
// packages/compiler-cli/src/ngtsc/annotations/component/src/util.js
|
|
20249
|
-
import
|
|
20401
|
+
import ts90 from "typescript";
|
|
20250
20402
|
function collectLegacyAnimationNames(value, legacyAnimationTriggerNames) {
|
|
20251
20403
|
if (value instanceof Map) {
|
|
20252
20404
|
const name = value.get("name");
|
|
@@ -20314,7 +20466,7 @@ function validateAndFlattenComponentImports(imports, expr, isDeferred) {
|
|
|
20314
20466
|
if (ref instanceof DynamicValue) {
|
|
20315
20467
|
diagnosticNode = ref.node;
|
|
20316
20468
|
diagnosticValue = ref;
|
|
20317
|
-
} else if (
|
|
20469
|
+
} else if (ts90.isArrayLiteralExpression(expr) && expr.elements.length === imports.length && !expr.elements.some(ts90.isSpreadAssignment) && !imports.some(Array.isArray)) {
|
|
20318
20470
|
diagnosticNode = expr.elements[i];
|
|
20319
20471
|
diagnosticValue = ref;
|
|
20320
20472
|
} else {
|
|
@@ -20341,11 +20493,11 @@ import { outputAst as o4 } from "@angular/compiler";
|
|
|
20341
20493
|
|
|
20342
20494
|
// packages/compiler-cli/src/ngtsc/hmr/src/extract_dependencies.js
|
|
20343
20495
|
import { outputAst as o3 } from "@angular/compiler";
|
|
20344
|
-
import
|
|
20496
|
+
import ts91 from "typescript";
|
|
20345
20497
|
function extractHmrDependencies(node, definition, factory, deferBlockMetadata, classMetadata, debugInfo, reflection, evaluator) {
|
|
20346
|
-
const name =
|
|
20498
|
+
const name = ts91.isClassDeclaration(node) && node.name ? node.name.text : null;
|
|
20347
20499
|
const visitor = new PotentialTopLevelReadsVisitor();
|
|
20348
|
-
const sourceFile =
|
|
20500
|
+
const sourceFile = ts91.getOriginalNode(node).getSourceFile();
|
|
20349
20501
|
definition.expression.visitExpression(visitor, null);
|
|
20350
20502
|
definition.statements.forEach((statement) => statement.visitStatement(visitor, null));
|
|
20351
20503
|
factory.initializer?.visitExpression(visitor, null);
|
|
@@ -20406,19 +20558,19 @@ function getRuntimeRepresentation(node, reflection, evaluator) {
|
|
|
20406
20558
|
function getTopLevelDeclarationNames(sourceFile) {
|
|
20407
20559
|
const results = /* @__PURE__ */ new Set();
|
|
20408
20560
|
for (const node of sourceFile.statements) {
|
|
20409
|
-
if (
|
|
20561
|
+
if (ts91.isClassDeclaration(node) || ts91.isFunctionDeclaration(node) || ts91.isEnumDeclaration(node)) {
|
|
20410
20562
|
if (node.name) {
|
|
20411
20563
|
results.add(node.name.text);
|
|
20412
20564
|
}
|
|
20413
20565
|
continue;
|
|
20414
20566
|
}
|
|
20415
|
-
if (
|
|
20567
|
+
if (ts91.isVariableStatement(node)) {
|
|
20416
20568
|
for (const decl of node.declarationList.declarations) {
|
|
20417
20569
|
trackBindingName(decl.name, results);
|
|
20418
20570
|
}
|
|
20419
20571
|
continue;
|
|
20420
20572
|
}
|
|
20421
|
-
if (
|
|
20573
|
+
if (ts91.isImportDeclaration(node) && node.importClause) {
|
|
20422
20574
|
const importClause = node.importClause;
|
|
20423
20575
|
if (importClause.isTypeOnly) {
|
|
20424
20576
|
continue;
|
|
@@ -20428,7 +20580,7 @@ function getTopLevelDeclarationNames(sourceFile) {
|
|
|
20428
20580
|
}
|
|
20429
20581
|
if (importClause.namedBindings) {
|
|
20430
20582
|
const namedBindings = importClause.namedBindings;
|
|
20431
|
-
if (
|
|
20583
|
+
if (ts91.isNamespaceImport(namedBindings)) {
|
|
20432
20584
|
results.add(namedBindings.name.text);
|
|
20433
20585
|
} else {
|
|
20434
20586
|
namedBindings.elements.forEach((el) => {
|
|
@@ -20444,11 +20596,11 @@ function getTopLevelDeclarationNames(sourceFile) {
|
|
|
20444
20596
|
return results;
|
|
20445
20597
|
}
|
|
20446
20598
|
function trackBindingName(node, results) {
|
|
20447
|
-
if (
|
|
20599
|
+
if (ts91.isIdentifier(node)) {
|
|
20448
20600
|
results.add(node.text);
|
|
20449
20601
|
} else {
|
|
20450
20602
|
for (const el of node.elements) {
|
|
20451
|
-
if (!
|
|
20603
|
+
if (!ts91.isOmittedExpression(el)) {
|
|
20452
20604
|
trackBindingName(el.name, results);
|
|
20453
20605
|
}
|
|
20454
20606
|
}
|
|
@@ -20478,10 +20630,10 @@ var PotentialTopLevelReadsVisitor = class extends o3.RecursiveAstVisitor {
|
|
|
20478
20630
|
* @param node Node from which to start the traversal.
|
|
20479
20631
|
*/
|
|
20480
20632
|
addAllTopLevelIdentifiers = (node) => {
|
|
20481
|
-
if (
|
|
20633
|
+
if (ts91.isIdentifier(node) && this.isTopLevelIdentifierReference(node)) {
|
|
20482
20634
|
this.allReads.add(node);
|
|
20483
20635
|
} else {
|
|
20484
|
-
|
|
20636
|
+
ts91.forEachChild(node, this.addAllTopLevelIdentifiers);
|
|
20485
20637
|
}
|
|
20486
20638
|
};
|
|
20487
20639
|
/**
|
|
@@ -20496,52 +20648,52 @@ var PotentialTopLevelReadsVisitor = class extends o3.RecursiveAstVisitor {
|
|
|
20496
20648
|
if (!parent) {
|
|
20497
20649
|
return false;
|
|
20498
20650
|
}
|
|
20499
|
-
if (
|
|
20500
|
-
while (parent &&
|
|
20651
|
+
if (ts91.isParenthesizedExpression(parent) && parent.expression === node) {
|
|
20652
|
+
while (parent && ts91.isParenthesizedExpression(parent)) {
|
|
20501
20653
|
node = parent;
|
|
20502
20654
|
parent = parent.parent;
|
|
20503
20655
|
}
|
|
20504
20656
|
}
|
|
20505
|
-
if (
|
|
20657
|
+
if (ts91.isSourceFile(parent)) {
|
|
20506
20658
|
return true;
|
|
20507
20659
|
}
|
|
20508
|
-
if (
|
|
20660
|
+
if (ts91.isCallExpression(parent)) {
|
|
20509
20661
|
return parent.expression === node || parent.arguments.includes(node);
|
|
20510
20662
|
}
|
|
20511
|
-
if (
|
|
20663
|
+
if (ts91.isExpressionStatement(parent) || ts91.isPropertyAccessExpression(parent) || ts91.isComputedPropertyName(parent) || ts91.isTemplateSpan(parent) || ts91.isSpreadAssignment(parent) || ts91.isSpreadElement(parent) || ts91.isAwaitExpression(parent) || ts91.isNonNullExpression(parent) || ts91.isIfStatement(parent) || ts91.isDoStatement(parent) || ts91.isWhileStatement(parent) || ts91.isSwitchStatement(parent) || ts91.isCaseClause(parent) || ts91.isThrowStatement(parent) || ts91.isNewExpression(parent) || ts91.isExpressionWithTypeArguments(parent)) {
|
|
20512
20664
|
return parent.expression === node;
|
|
20513
20665
|
}
|
|
20514
|
-
if (
|
|
20666
|
+
if (ts91.isArrayLiteralExpression(parent)) {
|
|
20515
20667
|
return parent.elements.includes(node);
|
|
20516
20668
|
}
|
|
20517
|
-
if (
|
|
20669
|
+
if (ts91.isPropertyAssignment(parent) || ts91.isParameter(parent) || ts91.isBindingElement(parent) || ts91.isPropertyDeclaration(parent) || ts91.isEnumMember(parent)) {
|
|
20518
20670
|
return parent.initializer === node;
|
|
20519
20671
|
}
|
|
20520
|
-
if (
|
|
20672
|
+
if (ts91.isVariableDeclaration(parent)) {
|
|
20521
20673
|
return parent.name === node || parent.initializer === node;
|
|
20522
20674
|
}
|
|
20523
|
-
if (
|
|
20675
|
+
if (ts91.isClassDeclaration(parent) || ts91.isFunctionDeclaration(parent) || ts91.isShorthandPropertyAssignment(parent)) {
|
|
20524
20676
|
return parent.name === node;
|
|
20525
20677
|
}
|
|
20526
|
-
if (
|
|
20678
|
+
if (ts91.isElementAccessExpression(parent)) {
|
|
20527
20679
|
return parent.expression === node || parent.argumentExpression === node;
|
|
20528
20680
|
}
|
|
20529
|
-
if (
|
|
20681
|
+
if (ts91.isBinaryExpression(parent)) {
|
|
20530
20682
|
return parent.left === node || parent.right === node;
|
|
20531
20683
|
}
|
|
20532
|
-
if (
|
|
20684
|
+
if (ts91.isForInStatement(parent) || ts91.isForOfStatement(parent)) {
|
|
20533
20685
|
return parent.expression === node || parent.initializer === node;
|
|
20534
20686
|
}
|
|
20535
|
-
if (
|
|
20687
|
+
if (ts91.isForStatement(parent)) {
|
|
20536
20688
|
return parent.condition === node || parent.initializer === node || parent.incrementor === node;
|
|
20537
20689
|
}
|
|
20538
|
-
if (
|
|
20690
|
+
if (ts91.isArrowFunction(parent)) {
|
|
20539
20691
|
return parent.body === node;
|
|
20540
20692
|
}
|
|
20541
|
-
if (
|
|
20693
|
+
if (ts91.isImportSpecifier(parent) || ts91.isExportSpecifier(parent)) {
|
|
20542
20694
|
return (parent.propertyName || parent.name) === node;
|
|
20543
20695
|
}
|
|
20544
|
-
if (
|
|
20696
|
+
if (ts91.isConditionalExpression(parent)) {
|
|
20545
20697
|
return parent.condition === node || parent.whenFalse === node || parent.whenTrue === node;
|
|
20546
20698
|
}
|
|
20547
20699
|
return false;
|
|
@@ -20553,20 +20705,20 @@ var PotentialTopLevelReadsVisitor = class extends o3.RecursiveAstVisitor {
|
|
|
20553
20705
|
};
|
|
20554
20706
|
function isConstEnumReference(node, reflection) {
|
|
20555
20707
|
const parent = node.parent;
|
|
20556
|
-
if (!parent || !
|
|
20708
|
+
if (!parent || !ts91.isPropertyAccessExpression(parent) || parent.expression !== node || !ts91.isIdentifier(parent.name)) {
|
|
20557
20709
|
return false;
|
|
20558
20710
|
}
|
|
20559
20711
|
const declaration = reflection.getDeclarationOfIdentifier(node);
|
|
20560
|
-
return declaration !== null &&
|
|
20712
|
+
return declaration !== null && ts91.isEnumDeclaration(declaration.node) && !!declaration.node.modifiers?.some((m) => m.kind === ts91.SyntaxKind.ConstKeyword);
|
|
20561
20713
|
}
|
|
20562
20714
|
|
|
20563
20715
|
// packages/compiler-cli/src/ngtsc/hmr/src/metadata.js
|
|
20564
|
-
import
|
|
20716
|
+
import ts92 from "typescript";
|
|
20565
20717
|
function extractHmrMetatadata(clazz, reflection, evaluator, compilerHost, rootDirs, definition, factory, deferBlockMetadata, classMetadata, debugInfo) {
|
|
20566
20718
|
if (!reflection.isClass(clazz)) {
|
|
20567
20719
|
return null;
|
|
20568
20720
|
}
|
|
20569
|
-
const sourceFile =
|
|
20721
|
+
const sourceFile = ts92.getOriginalNode(clazz).getSourceFile();
|
|
20570
20722
|
const filePath = getProjectRelativePath(sourceFile.fileName, rootDirs, compilerHost) || compilerHost.getCanonicalFileName(sourceFile.fileName);
|
|
20571
20723
|
const dependencies = extractHmrDependencies(clazz, definition, factory, deferBlockMetadata, classMetadata, debugInfo, reflection, evaluator);
|
|
20572
20724
|
if (dependencies === null) {
|
|
@@ -20584,7 +20736,7 @@ function extractHmrMetatadata(clazz, reflection, evaluator, compilerHost, rootDi
|
|
|
20584
20736
|
|
|
20585
20737
|
// packages/compiler-cli/src/ngtsc/hmr/src/update_declaration.js
|
|
20586
20738
|
import { compileHmrUpdateCallback } from "@angular/compiler";
|
|
20587
|
-
import
|
|
20739
|
+
import ts93 from "typescript";
|
|
20588
20740
|
function getHmrUpdateDeclaration(compilationResults, constantStatements, meta, declaration) {
|
|
20589
20741
|
const namespaceSpecifiers = meta.namespaceDependencies.reduce((result, current) => {
|
|
20590
20742
|
result.set(current.moduleName, current.assignedName);
|
|
@@ -20596,11 +20748,11 @@ function getHmrUpdateDeclaration(compilationResults, constantStatements, meta, d
|
|
|
20596
20748
|
rewriter: importRewriter
|
|
20597
20749
|
});
|
|
20598
20750
|
const callback = compileHmrUpdateCallback(compilationResults, constantStatements, meta);
|
|
20599
|
-
const sourceFile =
|
|
20751
|
+
const sourceFile = ts93.getOriginalNode(declaration).getSourceFile();
|
|
20600
20752
|
const node = translateStatement(sourceFile, callback, importManager);
|
|
20601
|
-
return
|
|
20602
|
-
|
|
20603
|
-
|
|
20753
|
+
return ts93.factory.updateFunctionDeclaration(node, [
|
|
20754
|
+
ts93.factory.createToken(ts93.SyntaxKind.ExportKeyword),
|
|
20755
|
+
ts93.factory.createToken(ts93.SyntaxKind.DefaultKeyword)
|
|
20604
20756
|
], node.asteriskToken, node.name, node.typeParameters, node.parameters, node.type, node.body);
|
|
20605
20757
|
}
|
|
20606
20758
|
var HmrModuleImportRewriter = class {
|
|
@@ -21047,7 +21199,7 @@ var ComponentDecoratorHandler = class {
|
|
|
21047
21199
|
path: absoluteFrom(template.declaration.resolvedTemplateUrl),
|
|
21048
21200
|
node: template.sourceMapping.node
|
|
21049
21201
|
};
|
|
21050
|
-
const relativeTemplatePath = getProjectRelativePath(templateResource.path ??
|
|
21202
|
+
const relativeTemplatePath = getProjectRelativePath(templateResource.path ?? ts94.getOriginalNode(node).getSourceFile().fileName, this.rootDirs, this.compilerHost);
|
|
21051
21203
|
let selectorlessEnabled = false;
|
|
21052
21204
|
let localReferencedSymbols = null;
|
|
21053
21205
|
if (this.enableSelectorless) {
|
|
@@ -21081,7 +21233,7 @@ var ComponentDecoratorHandler = class {
|
|
|
21081
21233
|
externalStyles.push(resourceUrl);
|
|
21082
21234
|
continue;
|
|
21083
21235
|
}
|
|
21084
|
-
if (styleUrl.source === 2 &&
|
|
21236
|
+
if (styleUrl.source === 2 && ts94.isStringLiteralLike(styleUrl.expression)) {
|
|
21085
21237
|
styleResources.add({
|
|
21086
21238
|
path: absoluteFrom(resourceUrl),
|
|
21087
21239
|
node: styleUrl.expression
|
|
@@ -21103,7 +21255,7 @@ var ComponentDecoratorHandler = class {
|
|
|
21103
21255
|
diagnostics.push(makeResourceNotFoundError(styleUrl.url, styleUrl.expression, resourceType).toDiagnostic());
|
|
21104
21256
|
}
|
|
21105
21257
|
}
|
|
21106
|
-
if ((encapsulation === ViewEncapsulation2.ShadowDom || encapsulation === ViewEncapsulation2.
|
|
21258
|
+
if ((encapsulation === ViewEncapsulation2.ShadowDom || encapsulation === ViewEncapsulation2.ExperimentalIsolatedShadowDom) && metadata.selector !== null) {
|
|
21107
21259
|
const selectorError = checkCustomElementSelectorForErrors(metadata.selector);
|
|
21108
21260
|
if (selectorError !== null) {
|
|
21109
21261
|
if (diagnostics === void 0) {
|
|
@@ -21289,7 +21441,7 @@ var ComponentDecoratorHandler = class {
|
|
|
21289
21441
|
return null;
|
|
21290
21442
|
}
|
|
21291
21443
|
typeCheck(ctx, node, meta) {
|
|
21292
|
-
if (!
|
|
21444
|
+
if (!ts94.isClassDeclaration(node) || meta.isPoisoned && !this.usePoisonedData) {
|
|
21293
21445
|
return;
|
|
21294
21446
|
}
|
|
21295
21447
|
const ref = new Reference(node);
|
|
@@ -21820,12 +21972,12 @@ var ComponentDecoratorHandler = class {
|
|
|
21820
21972
|
*/
|
|
21821
21973
|
collectExplicitlyDeferredSymbols(rawDeferredImports) {
|
|
21822
21974
|
const deferredTypes = /* @__PURE__ */ new Map();
|
|
21823
|
-
if (!
|
|
21975
|
+
if (!ts94.isArrayLiteralExpression(rawDeferredImports)) {
|
|
21824
21976
|
return deferredTypes;
|
|
21825
21977
|
}
|
|
21826
21978
|
for (const element of rawDeferredImports.elements) {
|
|
21827
21979
|
const node = tryUnwrapForwardRef(element, this.reflector) || element;
|
|
21828
|
-
if (!
|
|
21980
|
+
if (!ts94.isIdentifier(node)) {
|
|
21829
21981
|
continue;
|
|
21830
21982
|
}
|
|
21831
21983
|
const imp = this.reflector.getImportOfIdentifier(node);
|
|
@@ -21893,12 +22045,12 @@ var ComponentDecoratorHandler = class {
|
|
|
21893
22045
|
}
|
|
21894
22046
|
}
|
|
21895
22047
|
if (analysisData.meta.isStandalone) {
|
|
21896
|
-
if (analysisData.rawImports !== null &&
|
|
22048
|
+
if (analysisData.rawImports !== null && ts94.isArrayLiteralExpression(analysisData.rawImports)) {
|
|
21897
22049
|
for (const element of analysisData.rawImports.elements) {
|
|
21898
22050
|
this.registerDeferrableCandidate(componentClassDecl, element, false, allDeferredDecls, eagerlyUsedDecls, resolutionData);
|
|
21899
22051
|
}
|
|
21900
22052
|
}
|
|
21901
|
-
if (analysisData.rawDeferredImports !== null &&
|
|
22053
|
+
if (analysisData.rawDeferredImports !== null && ts94.isArrayLiteralExpression(analysisData.rawDeferredImports)) {
|
|
21902
22054
|
for (const element of analysisData.rawDeferredImports.elements) {
|
|
21903
22055
|
this.registerDeferrableCandidate(componentClassDecl, element, false, allDeferredDecls, eagerlyUsedDecls, resolutionData);
|
|
21904
22056
|
}
|
|
@@ -21917,7 +22069,7 @@ var ComponentDecoratorHandler = class {
|
|
|
21917
22069
|
*/
|
|
21918
22070
|
registerDeferrableCandidate(componentClassDecl, element, isDeferredImport, allDeferredDecls, eagerlyUsedDecls, resolutionData) {
|
|
21919
22071
|
const node = tryUnwrapForwardRef(element, this.reflector) || element;
|
|
21920
|
-
if (!
|
|
22072
|
+
if (!ts94.isIdentifier(node)) {
|
|
21921
22073
|
return;
|
|
21922
22074
|
}
|
|
21923
22075
|
const imp = this.reflector.getImportOfIdentifier(node);
|
|
@@ -22052,7 +22204,7 @@ function isDefaultImport(node) {
|
|
|
22052
22204
|
|
|
22053
22205
|
// packages/compiler-cli/src/ngtsc/annotations/src/injectable.js
|
|
22054
22206
|
import { compileClassMetadata as compileClassMetadata3, compileDeclareClassMetadata as compileDeclareClassMetadata3, compileDeclareInjectableFromMetadata, compileInjectable, createMayBeForwardRefExpression as createMayBeForwardRefExpression3, FactoryTarget as FactoryTarget4, LiteralExpr as LiteralExpr3, WrappedNodeExpr as WrappedNodeExpr11 } from "@angular/compiler";
|
|
22055
|
-
import
|
|
22207
|
+
import ts95 from "typescript";
|
|
22056
22208
|
var InjectableDecoratorHandler = class {
|
|
22057
22209
|
reflector;
|
|
22058
22210
|
evaluator;
|
|
@@ -22187,7 +22339,7 @@ function extractInjectableMetadata(clazz, decorator, reflector) {
|
|
|
22187
22339
|
};
|
|
22188
22340
|
} else if (decorator.args.length === 1) {
|
|
22189
22341
|
const metaNode = decorator.args[0];
|
|
22190
|
-
if (!
|
|
22342
|
+
if (!ts95.isObjectLiteralExpression(metaNode)) {
|
|
22191
22343
|
throw new FatalDiagnosticError(ErrorCode.DECORATOR_ARG_NOT_LITERAL, metaNode, `@Injectable argument must be an object literal`);
|
|
22192
22344
|
}
|
|
22193
22345
|
const meta = reflectObjectLiteral(metaNode);
|
|
@@ -22199,7 +22351,7 @@ function extractInjectableMetadata(clazz, decorator, reflector) {
|
|
|
22199
22351
|
let deps = void 0;
|
|
22200
22352
|
if ((meta.has("useClass") || meta.has("useFactory")) && meta.has("deps")) {
|
|
22201
22353
|
const depsExpr = meta.get("deps");
|
|
22202
|
-
if (!
|
|
22354
|
+
if (!ts95.isArrayLiteralExpression(depsExpr)) {
|
|
22203
22355
|
throw new FatalDiagnosticError(ErrorCode.VALUE_NOT_LITERAL, depsExpr, `@Injectable deps metadata must be an inline array`);
|
|
22204
22356
|
}
|
|
22205
22357
|
deps = depsExpr.elements.map((dep) => getDep(dep, reflector));
|
|
@@ -22288,12 +22440,12 @@ function getDep(dep, reflector) {
|
|
|
22288
22440
|
}
|
|
22289
22441
|
return true;
|
|
22290
22442
|
}
|
|
22291
|
-
if (
|
|
22443
|
+
if (ts95.isArrayLiteralExpression(dep)) {
|
|
22292
22444
|
dep.elements.forEach((el) => {
|
|
22293
22445
|
let isDecorator = false;
|
|
22294
|
-
if (
|
|
22446
|
+
if (ts95.isIdentifier(el)) {
|
|
22295
22447
|
isDecorator = maybeUpdateDecorator(el, reflector);
|
|
22296
|
-
} else if (
|
|
22448
|
+
} else if (ts95.isNewExpression(el) && ts95.isIdentifier(el.expression)) {
|
|
22297
22449
|
const token = el.arguments && el.arguments.length > 0 && el.arguments[0] || void 0;
|
|
22298
22450
|
isDecorator = maybeUpdateDecorator(el.expression, reflector, token);
|
|
22299
22451
|
}
|
|
@@ -22307,7 +22459,7 @@ function getDep(dep, reflector) {
|
|
|
22307
22459
|
|
|
22308
22460
|
// packages/compiler-cli/src/ngtsc/annotations/src/pipe.js
|
|
22309
22461
|
import { compileClassMetadata as compileClassMetadata4, compileDeclareClassMetadata as compileDeclareClassMetadata4, compileDeclarePipeFromMetadata, compilePipeFromMetadata, FactoryTarget as FactoryTarget5 } from "@angular/compiler";
|
|
22310
|
-
import
|
|
22462
|
+
import ts96 from "typescript";
|
|
22311
22463
|
var PipeSymbol = class _PipeSymbol extends SemanticSymbol {
|
|
22312
22464
|
name;
|
|
22313
22465
|
constructor(decl, name) {
|
|
@@ -22377,13 +22529,13 @@ var PipeDecoratorHandler = class {
|
|
|
22377
22529
|
}
|
|
22378
22530
|
const meta = decorator.args.length === 0 || // TODO(crisbeto): temporary for testing until we've changed
|
|
22379
22531
|
// the pipe public API not to require a name.
|
|
22380
|
-
|
|
22532
|
+
ts96.isNonNullExpression(decorator.args[0]) && decorator.args[0].expression.kind === ts96.SyntaxKind.NullKeyword ? null : unwrapExpression(decorator.args[0]);
|
|
22381
22533
|
let pipeName = null;
|
|
22382
22534
|
let pipeNameExpr = null;
|
|
22383
22535
|
let pure = true;
|
|
22384
22536
|
let isStandalone = this.implicitStandaloneValue;
|
|
22385
22537
|
if (meta !== null) {
|
|
22386
|
-
if (!
|
|
22538
|
+
if (!ts96.isObjectLiteralExpression(meta)) {
|
|
22387
22539
|
throw new FatalDiagnosticError(ErrorCode.DECORATOR_ARG_NOT_LITERAL, meta, "@Pipe must have a literal argument");
|
|
22388
22540
|
}
|
|
22389
22541
|
const pipe = reflectObjectLiteral(meta);
|
|
@@ -22509,12 +22661,12 @@ var PipeDecoratorHandler = class {
|
|
|
22509
22661
|
};
|
|
22510
22662
|
|
|
22511
22663
|
// packages/compiler-cli/src/ngtsc/transform/jit/src/initializer_api_transforms/transform.js
|
|
22512
|
-
import
|
|
22664
|
+
import ts99 from "typescript";
|
|
22513
22665
|
|
|
22514
22666
|
// packages/compiler-cli/src/ngtsc/transform/jit/src/initializer_api_transforms/transform_api.js
|
|
22515
|
-
import
|
|
22667
|
+
import ts97 from "typescript";
|
|
22516
22668
|
function createSyntheticAngularCoreDecoratorAccess(factory, importManager, ngClassDecorator, sourceFile, decoratorName) {
|
|
22517
|
-
const classDecoratorIdentifier =
|
|
22669
|
+
const classDecoratorIdentifier = ts97.isIdentifier(ngClassDecorator.identifier) ? ngClassDecorator.identifier : ngClassDecorator.identifier.expression;
|
|
22518
22670
|
return factory.createPropertyAccessExpression(
|
|
22519
22671
|
importManager.addImport({
|
|
22520
22672
|
exportModuleSpecifier: "@angular/core",
|
|
@@ -22524,11 +22676,11 @@ function createSyntheticAngularCoreDecoratorAccess(factory, importManager, ngCla
|
|
|
22524
22676
|
// The synthetic identifier may be checked later by the downlevel decorators
|
|
22525
22677
|
// transform to resolve to an Angular import using `getSymbolAtLocation`. We trick
|
|
22526
22678
|
// the transform to think it's not synthetic and comes from Angular core.
|
|
22527
|
-
|
|
22679
|
+
ts97.setOriginalNode(factory.createIdentifier(decoratorName), classDecoratorIdentifier)
|
|
22528
22680
|
);
|
|
22529
22681
|
}
|
|
22530
22682
|
function castAsAny(factory, expr) {
|
|
22531
|
-
return factory.createAsExpression(expr, factory.createKeywordTypeNode(
|
|
22683
|
+
return factory.createAsExpression(expr, factory.createKeywordTypeNode(ts97.SyntaxKind.AnyKeyword));
|
|
22532
22684
|
}
|
|
22533
22685
|
|
|
22534
22686
|
// packages/compiler-cli/src/ngtsc/transform/jit/src/initializer_api_transforms/input_function.js
|
|
@@ -22559,7 +22711,7 @@ var signalInputsTransform = (member, sourceFile, host, factory, importTracker, i
|
|
|
22559
22711
|
};
|
|
22560
22712
|
|
|
22561
22713
|
// packages/compiler-cli/src/ngtsc/transform/jit/src/initializer_api_transforms/model_function.js
|
|
22562
|
-
import
|
|
22714
|
+
import ts98 from "typescript";
|
|
22563
22715
|
var signalModelTransform = (member, sourceFile, host, factory, importTracker, importManager, classDecorator, isCore) => {
|
|
22564
22716
|
if (host.getDecoratorsOfDeclaration(member.node)?.some((d) => {
|
|
22565
22717
|
return isAngularDecorator2(d, "Input", isCore) || isAngularDecorator2(d, "Output", isCore);
|
|
@@ -22580,7 +22732,7 @@ var signalModelTransform = (member, sourceFile, host, factory, importTracker, im
|
|
|
22580
22732
|
// Config is cast to `any` because `isSignal` will be private, and in case this
|
|
22581
22733
|
// transform is used directly as a pre-compilation step, the decorator should
|
|
22582
22734
|
// not fail. It is already validated now due to us parsing the input metadata.
|
|
22583
|
-
factory.createAsExpression(inputConfig, factory.createKeywordTypeNode(
|
|
22735
|
+
factory.createAsExpression(inputConfig, factory.createKeywordTypeNode(ts98.SyntaxKind.AnyKeyword)),
|
|
22584
22736
|
classDecorator,
|
|
22585
22737
|
factory,
|
|
22586
22738
|
sourceFile,
|
|
@@ -22655,21 +22807,21 @@ function getInitializerApiJitTransform(host, importTracker, isCore, shouldTransf
|
|
|
22655
22807
|
return (ctx) => {
|
|
22656
22808
|
return (sourceFile) => {
|
|
22657
22809
|
const importManager = new ImportManager();
|
|
22658
|
-
sourceFile =
|
|
22810
|
+
sourceFile = ts99.visitNode(sourceFile, createTransformVisitor(ctx, host, importManager, importTracker, isCore, shouldTransformClass), ts99.isSourceFile);
|
|
22659
22811
|
return importManager.transformTsFile(ctx, sourceFile);
|
|
22660
22812
|
};
|
|
22661
22813
|
};
|
|
22662
22814
|
}
|
|
22663
22815
|
function createTransformVisitor(ctx, host, importManager, importTracker, isCore, shouldTransformClass) {
|
|
22664
22816
|
const visitor = (node) => {
|
|
22665
|
-
if (
|
|
22666
|
-
const originalNode =
|
|
22817
|
+
if (ts99.isClassDeclaration(node) && node.name !== void 0) {
|
|
22818
|
+
const originalNode = ts99.getOriginalNode(node, ts99.isClassDeclaration);
|
|
22667
22819
|
const angularDecorator = host.getDecoratorsOfDeclaration(originalNode)?.find((d) => decoratorsWithInputs.some((name) => isAngularDecorator2(d, name, isCore)));
|
|
22668
22820
|
if (angularDecorator !== void 0 && (shouldTransformClass === void 0 || shouldTransformClass(node))) {
|
|
22669
22821
|
let hasChanged = false;
|
|
22670
22822
|
const sourceFile = originalNode.getSourceFile();
|
|
22671
22823
|
const members = node.members.map((memberNode) => {
|
|
22672
|
-
if (!
|
|
22824
|
+
if (!ts99.isPropertyDeclaration(memberNode)) {
|
|
22673
22825
|
return memberNode;
|
|
22674
22826
|
}
|
|
22675
22827
|
const member = reflectClassMember(memberNode);
|
|
@@ -22690,7 +22842,7 @@ function createTransformVisitor(ctx, host, importManager, importTracker, isCore,
|
|
|
22690
22842
|
}
|
|
22691
22843
|
}
|
|
22692
22844
|
}
|
|
22693
|
-
return
|
|
22845
|
+
return ts99.visitEachChild(node, visitor, ctx);
|
|
22694
22846
|
};
|
|
22695
22847
|
return visitor;
|
|
22696
22848
|
}
|