@angular/compiler-cli 21.2.0 → 21.2.2
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-IO4PSCVA.js → chunk-32EO3D75.js} +1 -1
- package/bundles/chunk-FLWAEX6T.js +1 -1
- package/bundles/{chunk-IG22BDVK.js → chunk-OECV6WLT.js} +862 -1172
- package/bundles/{chunk-G6DAEDUS.js → chunk-RJ3Y43GR.js} +2 -2
- package/bundles/{chunk-J2UUYQZ3.js → chunk-SPPRVX7S.js} +2 -2
- package/bundles/index.js +4 -4
- package/bundles/private/migrations.js +2 -2
- package/bundles/private/testing.js +1 -1
- package/bundles/private/tooling.js +1 -1
- package/bundles/src/bin/ng_xi18n.js +4 -4
- package/bundles/src/bin/ngc.js +4 -4
- package/linker/src/file_linker/partial_linkers/util.d.ts +1 -1
- package/package.json +2 -2
- package/src/ngtsc/core/src/compiler.d.ts +1 -1
- package/src/ngtsc/diagnostics/src/docs.d.ts +1 -1
- package/src/ngtsc/typecheck/src/comments.d.ts +0 -7
- package/src/ngtsc/typecheck/src/environment.d.ts +7 -6
- package/src/ngtsc/typecheck/src/expression.d.ts +3 -15
- package/src/ngtsc/typecheck/src/host_bindings.d.ts +1 -1
- package/src/ngtsc/typecheck/src/ops/base.d.ts +3 -3
- package/src/ngtsc/typecheck/src/ops/bindings.d.ts +8 -3
- package/src/ngtsc/typecheck/src/ops/codegen.d.ts +74 -0
- package/src/ngtsc/typecheck/src/ops/context.d.ts +1 -2
- package/src/ngtsc/typecheck/src/ops/directive_constructor.d.ts +3 -3
- package/src/ngtsc/typecheck/src/ops/directive_type.d.ts +4 -4
- package/src/ngtsc/typecheck/src/ops/element.d.ts +2 -2
- package/src/ngtsc/typecheck/src/ops/events.d.ts +2 -2
- package/src/ngtsc/typecheck/src/ops/expression.d.ts +5 -5
- package/src/ngtsc/typecheck/src/ops/for_block.d.ts +2 -2
- package/src/ngtsc/typecheck/src/ops/host.d.ts +2 -2
- package/src/ngtsc/typecheck/src/ops/inputs.d.ts +2 -2
- package/src/ngtsc/typecheck/src/ops/let.d.ts +2 -2
- package/src/ngtsc/typecheck/src/ops/references.d.ts +3 -3
- package/src/ngtsc/typecheck/src/ops/schema.d.ts +2 -2
- package/src/ngtsc/typecheck/src/ops/scope.d.ts +9 -9
- package/src/ngtsc/typecheck/src/ops/selectorless.d.ts +2 -2
- package/src/ngtsc/typecheck/src/ops/template.d.ts +2 -2
- package/src/ngtsc/typecheck/src/ops/variables.d.ts +6 -6
- package/src/ngtsc/typecheck/src/reference_emit_environment.d.ts +2 -5
- package/src/ngtsc/typecheck/src/ts_util.d.ts +0 -37
- package/src/ngtsc/typecheck/src/type_check_block.d.ts +1 -1
- package/src/ngtsc/typecheck/src/type_check_file.d.ts +3 -2
- package/src/ngtsc/typecheck/src/type_constructor.d.ts +3 -2
|
@@ -229,7 +229,7 @@ var COMPILER_ERRORS_WITH_GUIDES = /* @__PURE__ */ new Set([
|
|
|
229
229
|
import { VERSION } from "@angular/compiler";
|
|
230
230
|
var DOC_PAGE_BASE_URL = (() => {
|
|
231
231
|
const full = VERSION.full;
|
|
232
|
-
const isPreRelease = full.includes("-next") || full.includes("-rc") || full === "21.2.
|
|
232
|
+
const isPreRelease = full.includes("-next") || full.includes("-rc") || full === "21.2.2";
|
|
233
233
|
const prefix = isPreRelease ? "next" : `v${VERSION.major}`;
|
|
234
234
|
return `https://${prefix}.angular.dev`;
|
|
235
235
|
})();
|
|
@@ -7013,6 +7013,7 @@ function insertDebugNameIntoCallExpression(node, debugName) {
|
|
|
7013
7013
|
return ts32.factory.updateCallExpression(node, node.expression, node.typeArguments, newArgs);
|
|
7014
7014
|
}
|
|
7015
7015
|
function createNgDevModeConditional(devModeExpression, prodModeExpression) {
|
|
7016
|
+
ts32.addSyntheticLeadingComment(prodModeExpression, ts32.SyntaxKind.MultiLineCommentTrivia, " istanbul ignore next ", false);
|
|
7016
7017
|
return ts32.factory.createParenthesizedExpression(ts32.factory.createConditionalExpression(ts32.factory.createIdentifier("ngDevMode"), void 0, devModeExpression, void 0, prodModeExpression));
|
|
7017
7018
|
}
|
|
7018
7019
|
function isVariableDeclarationCase(node) {
|
|
@@ -9836,7 +9837,7 @@ function _extractTemplateStyleUrls(template) {
|
|
|
9836
9837
|
|
|
9837
9838
|
// packages/compiler-cli/src/ngtsc/annotations/component/src/handler.js
|
|
9838
9839
|
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";
|
|
9839
|
-
import
|
|
9840
|
+
import ts79 from "typescript";
|
|
9840
9841
|
|
|
9841
9842
|
// packages/compiler-cli/src/ngtsc/incremental/semantic_graph/src/api.js
|
|
9842
9843
|
import ts43 from "typescript";
|
|
@@ -10954,8 +10955,8 @@ var TypeCheckScopeRegistry = class {
|
|
|
10954
10955
|
};
|
|
10955
10956
|
|
|
10956
10957
|
// packages/compiler-cli/src/ngtsc/annotations/directive/src/handler.js
|
|
10957
|
-
import { compileClassMetadata, compileDeclareClassMetadata, compileDeclareDirectiveFromMetadata, compileDirectiveFromMetadata, FactoryTarget, makeBindingParser as makeBindingParser2, R3TargetBinder, WrappedNodeExpr as
|
|
10958
|
-
import
|
|
10958
|
+
import { compileClassMetadata, compileDeclareClassMetadata, compileDeclareDirectiveFromMetadata, compileDirectiveFromMetadata, FactoryTarget, makeBindingParser as makeBindingParser2, R3TargetBinder, WrappedNodeExpr as WrappedNodeExpr8 } from "@angular/compiler";
|
|
10959
|
+
import ts72 from "typescript";
|
|
10959
10960
|
|
|
10960
10961
|
// packages/compiler-cli/src/ngtsc/annotations/directive/src/symbol.js
|
|
10961
10962
|
var DirectiveSymbol = class _DirectiveSymbol extends SemanticSymbol {
|
|
@@ -11044,7 +11045,7 @@ function isBaseClassEqual(current, previous) {
|
|
|
11044
11045
|
}
|
|
11045
11046
|
|
|
11046
11047
|
// packages/compiler-cli/src/ngtsc/typecheck/src/checker.js
|
|
11047
|
-
import { CssSelector as CssSelector4, DomElementSchemaRegistry as DomElementSchemaRegistry2, ExternalExpr as ExternalExpr8, WrappedNodeExpr as
|
|
11048
|
+
import { CssSelector as CssSelector4, DomElementSchemaRegistry as DomElementSchemaRegistry2, ExternalExpr as ExternalExpr8, WrappedNodeExpr as WrappedNodeExpr7 } from "@angular/compiler";
|
|
11048
11049
|
|
|
11049
11050
|
// packages/compiler-cli/src/ngtsc/typecheck/src/ts_util.js
|
|
11050
11051
|
import ts48 from "typescript";
|
|
@@ -11078,25 +11079,7 @@ var ExpressionIdentifier;
|
|
|
11078
11079
|
ExpressionIdentifier2["EVENT_PARAMETER"] = "EP";
|
|
11079
11080
|
ExpressionIdentifier2["VARIABLE_AS_EXPRESSION"] = "VAE";
|
|
11080
11081
|
})(ExpressionIdentifier || (ExpressionIdentifier = {}));
|
|
11081
|
-
function addExpressionIdentifier(node, identifier) {
|
|
11082
|
-
ts47.addSyntheticTrailingComment(
|
|
11083
|
-
node,
|
|
11084
|
-
ts47.SyntaxKind.MultiLineCommentTrivia,
|
|
11085
|
-
`${CommentTriviaType.EXPRESSION_TYPE_IDENTIFIER}:${identifier}`,
|
|
11086
|
-
/* hasTrailingNewLine */
|
|
11087
|
-
false
|
|
11088
|
-
);
|
|
11089
|
-
}
|
|
11090
11082
|
var IGNORE_FOR_DIAGNOSTICS_MARKER = `${CommentTriviaType.DIAGNOSTIC}:ignore`;
|
|
11091
|
-
function markIgnoreDiagnostics(node) {
|
|
11092
|
-
ts47.addSyntheticTrailingComment(
|
|
11093
|
-
node,
|
|
11094
|
-
ts47.SyntaxKind.MultiLineCommentTrivia,
|
|
11095
|
-
IGNORE_FOR_DIAGNOSTICS_MARKER,
|
|
11096
|
-
/* hasTrailingNewLine */
|
|
11097
|
-
false
|
|
11098
|
-
);
|
|
11099
|
-
}
|
|
11100
11083
|
function hasIgnoreForDiagnosticsMarker(node, sourceFile) {
|
|
11101
11084
|
return ts47.forEachTrailingCommentRange(sourceFile.text, node.getEnd(), (pos, end, kind) => {
|
|
11102
11085
|
if (kind !== ts47.SyntaxKind.MultiLineCommentTrivia) {
|
|
@@ -11182,119 +11165,9 @@ function hasExpressionIdentifier(sourceFile, node, identifier) {
|
|
|
11182
11165
|
}
|
|
11183
11166
|
|
|
11184
11167
|
// packages/compiler-cli/src/ngtsc/typecheck/src/ts_util.js
|
|
11185
|
-
var SAFE_TO_CAST_WITHOUT_PARENS = null;
|
|
11186
|
-
function tsCastToAny(expr) {
|
|
11187
|
-
if (SAFE_TO_CAST_WITHOUT_PARENS === null) {
|
|
11188
|
-
SAFE_TO_CAST_WITHOUT_PARENS = /* @__PURE__ */ new Set([
|
|
11189
|
-
// Expressions which are already parenthesized can be cast without further wrapping.
|
|
11190
|
-
ts48.SyntaxKind.ParenthesizedExpression,
|
|
11191
|
-
// Expressions which form a single lexical unit leave no room for precedence issues with the cast.
|
|
11192
|
-
ts48.SyntaxKind.Identifier,
|
|
11193
|
-
ts48.SyntaxKind.CallExpression,
|
|
11194
|
-
ts48.SyntaxKind.NonNullExpression,
|
|
11195
|
-
ts48.SyntaxKind.ElementAccessExpression,
|
|
11196
|
-
ts48.SyntaxKind.PropertyAccessExpression,
|
|
11197
|
-
ts48.SyntaxKind.ArrayLiteralExpression,
|
|
11198
|
-
ts48.SyntaxKind.ObjectLiteralExpression,
|
|
11199
|
-
// The same goes for various literals.
|
|
11200
|
-
ts48.SyntaxKind.StringLiteral,
|
|
11201
|
-
ts48.SyntaxKind.NumericLiteral,
|
|
11202
|
-
ts48.SyntaxKind.TrueKeyword,
|
|
11203
|
-
ts48.SyntaxKind.FalseKeyword,
|
|
11204
|
-
ts48.SyntaxKind.NullKeyword,
|
|
11205
|
-
ts48.SyntaxKind.UndefinedKeyword
|
|
11206
|
-
]);
|
|
11207
|
-
}
|
|
11208
|
-
if (!SAFE_TO_CAST_WITHOUT_PARENS.has(expr.kind)) {
|
|
11209
|
-
expr = ts48.factory.createParenthesizedExpression(expr);
|
|
11210
|
-
}
|
|
11211
|
-
return ts48.factory.createParenthesizedExpression(ts48.factory.createAsExpression(expr, ts48.factory.createKeywordTypeNode(ts48.SyntaxKind.AnyKeyword)));
|
|
11212
|
-
}
|
|
11213
|
-
function tsCreateElement(...tagNames) {
|
|
11214
|
-
const createElement = ts48.factory.createPropertyAccessExpression(
|
|
11215
|
-
/* expression */
|
|
11216
|
-
ts48.factory.createIdentifier("document"),
|
|
11217
|
-
"createElement"
|
|
11218
|
-
);
|
|
11219
|
-
let arg;
|
|
11220
|
-
if (tagNames.length === 1) {
|
|
11221
|
-
arg = ts48.factory.createStringLiteral(tagNames[0]);
|
|
11222
|
-
} else {
|
|
11223
|
-
const assertedNullExpression = ts48.factory.createNonNullExpression(ts48.factory.createNull());
|
|
11224
|
-
const type = ts48.factory.createUnionTypeNode(tagNames.map((tag) => ts48.factory.createLiteralTypeNode(ts48.factory.createStringLiteral(tag))));
|
|
11225
|
-
arg = ts48.factory.createAsExpression(assertedNullExpression, type);
|
|
11226
|
-
}
|
|
11227
|
-
return ts48.factory.createCallExpression(
|
|
11228
|
-
/* expression */
|
|
11229
|
-
createElement,
|
|
11230
|
-
/* typeArguments */
|
|
11231
|
-
void 0,
|
|
11232
|
-
/* argumentsArray */
|
|
11233
|
-
[arg]
|
|
11234
|
-
);
|
|
11235
|
-
}
|
|
11236
|
-
function tsDeclareVariable(id, type) {
|
|
11237
|
-
addExpressionIdentifier(type, ExpressionIdentifier.VARIABLE_AS_EXPRESSION);
|
|
11238
|
-
const initializer = ts48.factory.createAsExpression(ts48.factory.createNonNullExpression(ts48.factory.createNull()), type);
|
|
11239
|
-
const decl = ts48.factory.createVariableDeclaration(
|
|
11240
|
-
/* name */
|
|
11241
|
-
id,
|
|
11242
|
-
/* exclamationToken */
|
|
11243
|
-
void 0,
|
|
11244
|
-
/* type */
|
|
11245
|
-
void 0,
|
|
11246
|
-
/* initializer */
|
|
11247
|
-
initializer
|
|
11248
|
-
);
|
|
11249
|
-
return ts48.factory.createVariableStatement(
|
|
11250
|
-
/* modifiers */
|
|
11251
|
-
void 0,
|
|
11252
|
-
/* declarationList */
|
|
11253
|
-
[decl]
|
|
11254
|
-
);
|
|
11255
|
-
}
|
|
11256
|
-
function tsCreateTypeQueryForCoercedInput(typeName, coercedInputName) {
|
|
11257
|
-
return ts48.factory.createTypeQueryNode(ts48.factory.createQualifiedName(typeName, `ngAcceptInputType_${coercedInputName}`));
|
|
11258
|
-
}
|
|
11259
|
-
function tsCreateVariable(id, initializer, flags = null) {
|
|
11260
|
-
const decl = ts48.factory.createVariableDeclaration(
|
|
11261
|
-
/* name */
|
|
11262
|
-
id,
|
|
11263
|
-
/* exclamationToken */
|
|
11264
|
-
void 0,
|
|
11265
|
-
/* type */
|
|
11266
|
-
void 0,
|
|
11267
|
-
/* initializer */
|
|
11268
|
-
initializer
|
|
11269
|
-
);
|
|
11270
|
-
return ts48.factory.createVariableStatement(
|
|
11271
|
-
/* modifiers */
|
|
11272
|
-
void 0,
|
|
11273
|
-
/* declarationList */
|
|
11274
|
-
flags === null ? [decl] : ts48.factory.createVariableDeclarationList([decl], flags)
|
|
11275
|
-
);
|
|
11276
|
-
}
|
|
11277
|
-
function tsCallMethod(receiver, methodName, args = []) {
|
|
11278
|
-
const methodAccess = ts48.factory.createPropertyAccessExpression(receiver, methodName);
|
|
11279
|
-
return ts48.factory.createCallExpression(
|
|
11280
|
-
/* expression */
|
|
11281
|
-
methodAccess,
|
|
11282
|
-
/* typeArguments */
|
|
11283
|
-
void 0,
|
|
11284
|
-
/* argumentsArray */
|
|
11285
|
-
args
|
|
11286
|
-
);
|
|
11287
|
-
}
|
|
11288
11168
|
function isAccessExpression(node) {
|
|
11289
11169
|
return ts48.isPropertyAccessExpression(node) || ts48.isElementAccessExpression(node);
|
|
11290
11170
|
}
|
|
11291
|
-
function tsNumericExpression2(value) {
|
|
11292
|
-
if (value < 0) {
|
|
11293
|
-
const operand = ts48.factory.createNumericLiteral(Math.abs(value));
|
|
11294
|
-
return ts48.factory.createPrefixUnaryExpression(ts48.SyntaxKind.MinusToken, operand);
|
|
11295
|
-
}
|
|
11296
|
-
return ts48.factory.createNumericLiteral(value);
|
|
11297
|
-
}
|
|
11298
11171
|
function isDirectiveDeclaration(node) {
|
|
11299
11172
|
const sourceFile = node.getSourceFile();
|
|
11300
11173
|
return (ts48.isTypeNode(node) || ts48.isIdentifier(node)) && ts48.isVariableDeclaration(node.parent) && hasExpressionIdentifier(sourceFile, node, ExpressionIdentifier.DIRECTIVE);
|
|
@@ -11316,7 +11189,7 @@ function isSymbolAliasOf(firstSymbol, lastSymbol, typeChecker) {
|
|
|
11316
11189
|
}
|
|
11317
11190
|
|
|
11318
11191
|
// packages/compiler-cli/src/ngtsc/typecheck/src/checker.js
|
|
11319
|
-
import
|
|
11192
|
+
import ts71 from "typescript";
|
|
11320
11193
|
|
|
11321
11194
|
// packages/compiler-cli/src/ngtsc/program_driver/src/api.js
|
|
11322
11195
|
var NgOriginalFile = Symbol("NgOriginalFile");
|
|
@@ -12908,7 +12781,7 @@ var MagicString = class _MagicString {
|
|
|
12908
12781
|
};
|
|
12909
12782
|
|
|
12910
12783
|
// packages/compiler-cli/src/ngtsc/typecheck/src/context.js
|
|
12911
|
-
import
|
|
12784
|
+
import ts68 from "typescript";
|
|
12912
12785
|
|
|
12913
12786
|
// packages/compiler-cli/src/ngtsc/typecheck/src/dom.js
|
|
12914
12787
|
import { DomElementSchemaRegistry } from "@angular/compiler";
|
|
@@ -12977,10 +12850,112 @@ var RegistryDomSchemaChecker = class {
|
|
|
12977
12850
|
};
|
|
12978
12851
|
|
|
12979
12852
|
// packages/compiler-cli/src/ngtsc/typecheck/src/environment.js
|
|
12980
|
-
import
|
|
12853
|
+
import ts59 from "typescript";
|
|
12981
12854
|
|
|
12982
12855
|
// packages/compiler-cli/src/ngtsc/typecheck/src/reference_emit_environment.js
|
|
12983
12856
|
import { ExpressionType, ExternalExpr as ExternalExpr7, TypeModifier } from "@angular/compiler";
|
|
12857
|
+
import ts54 from "typescript";
|
|
12858
|
+
|
|
12859
|
+
// packages/compiler-cli/src/ngtsc/typecheck/src/ops/codegen.js
|
|
12860
|
+
import { AbsoluteSourceSpan as AbsoluteSourceSpan2 } from "@angular/compiler";
|
|
12861
|
+
import ts53 from "typescript";
|
|
12862
|
+
var TcbExpr = class {
|
|
12863
|
+
source;
|
|
12864
|
+
/** Text for the content containing the expression's location information. */
|
|
12865
|
+
spanComment = null;
|
|
12866
|
+
/** Text for the content containing the expression's identifier. */
|
|
12867
|
+
identifierComment = null;
|
|
12868
|
+
/**
|
|
12869
|
+
* Text of the comment instructing the type checker to
|
|
12870
|
+
* ignore diagnostics coming from this expression.
|
|
12871
|
+
*/
|
|
12872
|
+
ignoreComment = null;
|
|
12873
|
+
constructor(source) {
|
|
12874
|
+
this.source = source;
|
|
12875
|
+
}
|
|
12876
|
+
/**
|
|
12877
|
+
* Converts the node's current state to a string.
|
|
12878
|
+
* @param ignoreComments Whether the comments associated with the expression should be skipped.
|
|
12879
|
+
*/
|
|
12880
|
+
print(ignoreComments = false) {
|
|
12881
|
+
if (ignoreComments) {
|
|
12882
|
+
return this.source;
|
|
12883
|
+
}
|
|
12884
|
+
return this.source + this.formatComment(this.identifierComment) + this.formatComment(this.ignoreComment) + this.formatComment(this.spanComment);
|
|
12885
|
+
}
|
|
12886
|
+
/**
|
|
12887
|
+
* Adds a synthetic comment to the expression that represents the parse span of the provided node.
|
|
12888
|
+
* This comment can later be retrieved as trivia of a node to recover original source locations.
|
|
12889
|
+
* @param span Span from the parser containing the location information.
|
|
12890
|
+
*/
|
|
12891
|
+
addParseSpanInfo(span) {
|
|
12892
|
+
let start;
|
|
12893
|
+
let end;
|
|
12894
|
+
if (span instanceof AbsoluteSourceSpan2) {
|
|
12895
|
+
start = span.start;
|
|
12896
|
+
end = span.end;
|
|
12897
|
+
} else {
|
|
12898
|
+
start = span.start.offset;
|
|
12899
|
+
end = span.end.offset;
|
|
12900
|
+
}
|
|
12901
|
+
this.spanComment = `${start},${end}`;
|
|
12902
|
+
return this;
|
|
12903
|
+
}
|
|
12904
|
+
/** Marks the expression to be ignored for diagnostics. */
|
|
12905
|
+
markIgnoreDiagnostics() {
|
|
12906
|
+
this.ignoreComment = `${CommentTriviaType.DIAGNOSTIC}:ignore`;
|
|
12907
|
+
return this;
|
|
12908
|
+
}
|
|
12909
|
+
/**
|
|
12910
|
+
* Wraps the expression in parenthesis such that inserted
|
|
12911
|
+
* span comments become attached to the proper node.
|
|
12912
|
+
*/
|
|
12913
|
+
wrapForTypeChecker() {
|
|
12914
|
+
this.source = `(${this.print()})`;
|
|
12915
|
+
this.spanComment = this.identifierComment = this.ignoreComment = null;
|
|
12916
|
+
return this;
|
|
12917
|
+
}
|
|
12918
|
+
/**
|
|
12919
|
+
* Tags the expression with an identifier.
|
|
12920
|
+
* @param identifier Identifier to apply to the expression.
|
|
12921
|
+
*/
|
|
12922
|
+
addExpressionIdentifier(identifier) {
|
|
12923
|
+
this.identifierComment = `${CommentTriviaType.EXPRESSION_TYPE_IDENTIFIER}:${identifier}`;
|
|
12924
|
+
return this;
|
|
12925
|
+
}
|
|
12926
|
+
/**
|
|
12927
|
+
* `toString` implementation meant to catch errors like accidentally
|
|
12928
|
+
* writing `foo ${expr} bar` instead of `foo ${expr.print()} bar`.
|
|
12929
|
+
*/
|
|
12930
|
+
toString() {
|
|
12931
|
+
throw new Error("Assertion error: TcbExpr should not be converted to a string through concatenation. Use the `print` method instead.");
|
|
12932
|
+
}
|
|
12933
|
+
/** Format a comment string as a TypeScript comment. */
|
|
12934
|
+
formatComment(content) {
|
|
12935
|
+
return content === null || content.length === 0 ? "" : ` /*${content}*/`;
|
|
12936
|
+
}
|
|
12937
|
+
};
|
|
12938
|
+
function declareVariable(identifier, type) {
|
|
12939
|
+
type.addExpressionIdentifier(ExpressionIdentifier.VARIABLE_AS_EXPRESSION);
|
|
12940
|
+
return new TcbExpr(`var ${identifier.print()} = null! as ${type.print()}`);
|
|
12941
|
+
}
|
|
12942
|
+
function getStatementsBlock(expressions, singleLine = false) {
|
|
12943
|
+
let result = "";
|
|
12944
|
+
for (const expr of expressions) {
|
|
12945
|
+
result += `${expr.print()};${singleLine ? " " : "\n"}`;
|
|
12946
|
+
}
|
|
12947
|
+
return result;
|
|
12948
|
+
}
|
|
12949
|
+
function quoteAndEscape(value) {
|
|
12950
|
+
return JSON.stringify(value);
|
|
12951
|
+
}
|
|
12952
|
+
var tempPrinter = null;
|
|
12953
|
+
function tempPrint(node, sourceFile) {
|
|
12954
|
+
tempPrinter ??= ts53.createPrinter();
|
|
12955
|
+
return tempPrinter.printNode(ts53.EmitHint.Unspecified, node, sourceFile);
|
|
12956
|
+
}
|
|
12957
|
+
|
|
12958
|
+
// packages/compiler-cli/src/ngtsc/typecheck/src/reference_emit_environment.js
|
|
12984
12959
|
var ReferenceEmitEnvironment = class {
|
|
12985
12960
|
importManager;
|
|
12986
12961
|
refEmitter;
|
|
@@ -13006,13 +12981,18 @@ var ReferenceEmitEnvironment = class {
|
|
|
13006
12981
|
assertSuccessfulReferenceEmit(ngExpr, this.contextFile, "symbol");
|
|
13007
12982
|
return translateType(new ExpressionType(ngExpr.expression), this.contextFile, this.reflector, this.refEmitter, this.importManager);
|
|
13008
12983
|
}
|
|
13009
|
-
/**
|
|
13010
|
-
* Generate a `ts.Expression` that refers to the external symbol. This
|
|
13011
|
-
* may result in new imports being generated.
|
|
13012
|
-
*/
|
|
13013
12984
|
referenceExternalSymbol(moduleName, name) {
|
|
13014
|
-
const
|
|
13015
|
-
|
|
12985
|
+
const importResult = this.importManager.addImport({
|
|
12986
|
+
exportModuleSpecifier: moduleName,
|
|
12987
|
+
exportSymbolName: name,
|
|
12988
|
+
requestedFile: this.contextFile
|
|
12989
|
+
});
|
|
12990
|
+
if (ts54.isIdentifier(importResult)) {
|
|
12991
|
+
return new TcbExpr(importResult.text);
|
|
12992
|
+
} else if (ts54.isIdentifier(importResult.expression)) {
|
|
12993
|
+
return new TcbExpr(`${importResult.expression.text}.${importResult.name.text}`);
|
|
12994
|
+
}
|
|
12995
|
+
throw new Error("Unexpected value returned by import manager");
|
|
13016
12996
|
}
|
|
13017
12997
|
/**
|
|
13018
12998
|
* Generate a `ts.TypeNode` that references a given type from the provided module.
|
|
@@ -13035,15 +13015,15 @@ var ReferenceEmitEnvironment = class {
|
|
|
13035
13015
|
};
|
|
13036
13016
|
|
|
13037
13017
|
// packages/compiler-cli/src/ngtsc/typecheck/src/type_constructor.js
|
|
13038
|
-
import {
|
|
13039
|
-
import
|
|
13018
|
+
import { R3Identifiers as R3Identifiers3 } from "@angular/compiler";
|
|
13019
|
+
import ts58 from "typescript";
|
|
13040
13020
|
|
|
13041
13021
|
// packages/compiler-cli/src/ngtsc/typecheck/src/tcb_util.js
|
|
13042
13022
|
import { R3Identifiers as R3Identifiers2 } from "@angular/compiler";
|
|
13043
|
-
import
|
|
13023
|
+
import ts57 from "typescript";
|
|
13044
13024
|
|
|
13045
13025
|
// packages/compiler-cli/src/ngtsc/typecheck/src/type_parameter_emitter.js
|
|
13046
|
-
import
|
|
13026
|
+
import ts55 from "typescript";
|
|
13047
13027
|
var TypeParameterEmitter = class {
|
|
13048
13028
|
typeParameters;
|
|
13049
13029
|
reflector;
|
|
@@ -13090,11 +13070,11 @@ var TypeParameterEmitter = class {
|
|
|
13090
13070
|
return this.typeParameters.map((typeParam) => {
|
|
13091
13071
|
const constraint = typeParam.constraint !== void 0 ? emitter.emitType(typeParam.constraint) : void 0;
|
|
13092
13072
|
const defaultType = typeParam.default !== void 0 ? emitter.emitType(typeParam.default) : void 0;
|
|
13093
|
-
return
|
|
13073
|
+
return ts55.factory.updateTypeParameterDeclaration(typeParam, typeParam.modifiers, typeParam.name, constraint, defaultType);
|
|
13094
13074
|
});
|
|
13095
13075
|
}
|
|
13096
13076
|
resolveTypeReference(type) {
|
|
13097
|
-
const target =
|
|
13077
|
+
const target = ts55.isIdentifier(type.typeName) ? type.typeName : type.typeName.right;
|
|
13098
13078
|
const declaration = this.reflector.getDeclarationOfIdentifier(target);
|
|
13099
13079
|
if (declaration === null || declaration.node === null) {
|
|
13100
13080
|
return null;
|
|
@@ -13120,8 +13100,8 @@ var TypeParameterEmitter = class {
|
|
|
13120
13100
|
if (typeNode === null) {
|
|
13121
13101
|
return null;
|
|
13122
13102
|
}
|
|
13123
|
-
if (!
|
|
13124
|
-
throw new Error(`Expected TypeReferenceNode for emitted reference, got ${
|
|
13103
|
+
if (!ts55.isTypeReferenceNode(typeNode)) {
|
|
13104
|
+
throw new Error(`Expected TypeReferenceNode for emitted reference, got ${ts55.SyntaxKind[typeNode.kind]}.`);
|
|
13125
13105
|
}
|
|
13126
13106
|
return typeNode;
|
|
13127
13107
|
}
|
|
@@ -13131,8 +13111,8 @@ var TypeParameterEmitter = class {
|
|
|
13131
13111
|
};
|
|
13132
13112
|
|
|
13133
13113
|
// packages/compiler-cli/src/ngtsc/typecheck/src/host_bindings.js
|
|
13134
|
-
import { BindingType, CssSelector as CssSelector2, makeBindingParser, TmplAstBoundAttribute, TmplAstBoundEvent, TmplAstHostElement, AbsoluteSourceSpan as
|
|
13135
|
-
import
|
|
13114
|
+
import { BindingType, CssSelector as CssSelector2, makeBindingParser, TmplAstBoundAttribute, TmplAstBoundEvent, TmplAstHostElement, AbsoluteSourceSpan as AbsoluteSourceSpan3, ParseSpan, PropertyRead as PropertyRead2, ParsedEventType, Call, ThisReceiver as ThisReceiver2, KeyedRead, LiteralPrimitive, RecursiveAstVisitor, ASTWithName, SafeCall, ImplicitReceiver as ImplicitReceiver2 } from "@angular/compiler";
|
|
13115
|
+
import ts56 from "typescript";
|
|
13136
13116
|
var GUARD_COMMENT_TEXT = "hostBindingsBlockGuard";
|
|
13137
13117
|
function createHostElement(type, selector, sourceNode, literal4, bindingDecorators, listenerDecorators) {
|
|
13138
13118
|
const bindings = [];
|
|
@@ -13140,7 +13120,7 @@ function createHostElement(type, selector, sourceNode, literal4, bindingDecorato
|
|
|
13140
13120
|
let parser = null;
|
|
13141
13121
|
if (literal4 !== null) {
|
|
13142
13122
|
for (const prop of literal4.properties) {
|
|
13143
|
-
if (
|
|
13123
|
+
if (ts56.isPropertyAssignment(prop) && ts56.isStringLiteralLike(prop.initializer) && isStaticName(prop.name)) {
|
|
13144
13124
|
parser ??= makeBindingParser();
|
|
13145
13125
|
createNodeFromHostLiteralProperty(prop, parser, bindings, listeners);
|
|
13146
13126
|
}
|
|
@@ -13171,19 +13151,18 @@ function createHostElement(type, selector, sourceNode, literal4, bindingDecorato
|
|
|
13171
13151
|
return new TmplAstHostElement(tagNames, bindings, listeners, createSourceSpan(sourceNode.name));
|
|
13172
13152
|
}
|
|
13173
13153
|
function createHostBindingsBlockGuard() {
|
|
13174
|
-
|
|
13175
|
-
return ts54.factory.createParenthesizedExpression(trueExpr);
|
|
13154
|
+
return `(true /*${GUARD_COMMENT_TEXT}*/)`;
|
|
13176
13155
|
}
|
|
13177
13156
|
function isHostBindingsBlockGuard(node) {
|
|
13178
|
-
if (!
|
|
13157
|
+
if (!ts56.isIfStatement(node)) {
|
|
13179
13158
|
return false;
|
|
13180
13159
|
}
|
|
13181
13160
|
const expr = node.expression;
|
|
13182
|
-
if (!
|
|
13161
|
+
if (!ts56.isParenthesizedExpression(expr) || expr.expression.kind !== ts56.SyntaxKind.TrueKeyword) {
|
|
13183
13162
|
return false;
|
|
13184
13163
|
}
|
|
13185
13164
|
const text = expr.getSourceFile().text;
|
|
13186
|
-
return
|
|
13165
|
+
return ts56.forEachTrailingCommentRange(text, expr.expression.getEnd(), (pos, end, kind) => kind === ts56.SyntaxKind.MultiLineCommentTrivia && text.substring(pos + 2, end - 2) === GUARD_COMMENT_TEXT) || false;
|
|
13187
13166
|
}
|
|
13188
13167
|
function createNodeFromHostLiteralProperty(property, parser, bindings, listeners) {
|
|
13189
13168
|
const { name, initializer } = property;
|
|
@@ -13207,19 +13186,19 @@ function createNodeFromHostLiteralProperty(property, parser, bindings, listeners
|
|
|
13207
13186
|
}
|
|
13208
13187
|
}
|
|
13209
13188
|
function createNodeFromBindingDecorator(decorator, bindings) {
|
|
13210
|
-
if (!
|
|
13189
|
+
if (!ts56.isCallExpression(decorator.expression)) {
|
|
13211
13190
|
return;
|
|
13212
13191
|
}
|
|
13213
13192
|
const args = decorator.expression.arguments;
|
|
13214
13193
|
const property = decorator.parent;
|
|
13215
13194
|
let nameNode = null;
|
|
13216
13195
|
let propertyName = null;
|
|
13217
|
-
if (property &&
|
|
13196
|
+
if (property && ts56.isPropertyDeclaration(property) && isStaticName(property.name)) {
|
|
13218
13197
|
propertyName = property.name;
|
|
13219
13198
|
}
|
|
13220
13199
|
if (args.length === 0) {
|
|
13221
13200
|
nameNode = propertyName;
|
|
13222
|
-
} else if (
|
|
13201
|
+
} else if (ts56.isStringLiteralLike(args[0])) {
|
|
13223
13202
|
nameNode = args[0];
|
|
13224
13203
|
} else {
|
|
13225
13204
|
return;
|
|
@@ -13229,36 +13208,36 @@ function createNodeFromBindingDecorator(decorator, bindings) {
|
|
|
13229
13208
|
}
|
|
13230
13209
|
const span = new ParseSpan(-1, -1);
|
|
13231
13210
|
const propertyStart = property.getStart();
|
|
13232
|
-
const receiver = new ThisReceiver2(span, new
|
|
13233
|
-
const nameSpan = new
|
|
13234
|
-
const read =
|
|
13211
|
+
const receiver = new ThisReceiver2(span, new AbsoluteSourceSpan3(propertyStart, propertyStart));
|
|
13212
|
+
const nameSpan = new AbsoluteSourceSpan3(propertyName.getStart(), propertyName.getEnd());
|
|
13213
|
+
const read = ts56.isIdentifier(propertyName) ? new PropertyRead2(span, nameSpan, nameSpan, receiver, propertyName.text) : new KeyedRead(span, nameSpan, receiver, new LiteralPrimitive(span, nameSpan, propertyName.text));
|
|
13235
13214
|
const { attrName, type } = inferBoundAttribute(nameNode.text);
|
|
13236
13215
|
bindings.push(new TmplAstBoundAttribute(attrName, type, 0, read, null, createSourceSpan(decorator), createStaticExpressionSpan(nameNode), createSourceSpan(decorator), void 0));
|
|
13237
13216
|
}
|
|
13238
13217
|
function createNodeFromListenerDecorator(decorator, parser, listeners) {
|
|
13239
|
-
if (!
|
|
13218
|
+
if (!ts56.isCallExpression(decorator.expression) || decorator.expression.arguments.length === 0) {
|
|
13240
13219
|
return;
|
|
13241
13220
|
}
|
|
13242
13221
|
const args = decorator.expression.arguments;
|
|
13243
13222
|
const method = decorator.parent;
|
|
13244
|
-
if (!method || !
|
|
13223
|
+
if (!method || !ts56.isMethodDeclaration(method) || !isStaticName(method.name) || !ts56.isStringLiteralLike(args[0])) {
|
|
13245
13224
|
return;
|
|
13246
13225
|
}
|
|
13247
13226
|
const span = new ParseSpan(-1, -1);
|
|
13248
13227
|
const argNodes = [];
|
|
13249
13228
|
const methodStart = method.getStart();
|
|
13250
|
-
const methodReceiver = new ThisReceiver2(span, new
|
|
13251
|
-
const nameSpan = new
|
|
13252
|
-
const receiver =
|
|
13253
|
-
if (args.length > 1 &&
|
|
13229
|
+
const methodReceiver = new ThisReceiver2(span, new AbsoluteSourceSpan3(methodStart, methodStart));
|
|
13230
|
+
const nameSpan = new AbsoluteSourceSpan3(method.name.getStart(), method.name.getEnd());
|
|
13231
|
+
const receiver = ts56.isIdentifier(method.name) ? new PropertyRead2(span, nameSpan, nameSpan, methodReceiver, method.name.text) : new KeyedRead(span, nameSpan, methodReceiver, new LiteralPrimitive(span, nameSpan, method.name.text));
|
|
13232
|
+
if (args.length > 1 && ts56.isArrayLiteralExpression(args[1])) {
|
|
13254
13233
|
for (const expr of args[1].elements) {
|
|
13255
|
-
if (
|
|
13234
|
+
if (ts56.isStringLiteralLike(expr)) {
|
|
13256
13235
|
const span2 = createStaticExpressionSpan(expr);
|
|
13257
13236
|
const ast = parser.parseBinding(expr.text, true, span2, span2.start.offset);
|
|
13258
13237
|
fixupSpans(ast, expr);
|
|
13259
13238
|
argNodes.push(ast);
|
|
13260
13239
|
} else {
|
|
13261
|
-
const expressionSpan = new
|
|
13240
|
+
const expressionSpan = new AbsoluteSourceSpan3(expr.getStart(), expr.getEnd());
|
|
13262
13241
|
const anyRead = new PropertyRead2(span, expressionSpan, expressionSpan, new ImplicitReceiver2(span, expressionSpan), "$any");
|
|
13263
13242
|
const anyCall = new Call(span, expressionSpan, anyRead, [new LiteralPrimitive(span, expressionSpan, 0)], expressionSpan);
|
|
13264
13243
|
argNodes.push(anyCall);
|
|
@@ -13316,11 +13295,11 @@ function inferBoundAttribute(name) {
|
|
|
13316
13295
|
return { attrName, type };
|
|
13317
13296
|
}
|
|
13318
13297
|
function isStaticName(node) {
|
|
13319
|
-
return
|
|
13298
|
+
return ts56.isIdentifier(node) || ts56.isStringLiteralLike(node);
|
|
13320
13299
|
}
|
|
13321
13300
|
function createStaticExpressionSpan(node) {
|
|
13322
13301
|
const span = createSourceSpan(node);
|
|
13323
|
-
if (
|
|
13302
|
+
if (ts56.isStringLiteralLike(node)) {
|
|
13324
13303
|
span.fullStart = span.fullStart.moveBy(1);
|
|
13325
13304
|
span.start = span.start.moveBy(1);
|
|
13326
13305
|
span.end = span.end.moveBy(-1);
|
|
@@ -13331,7 +13310,7 @@ function fixupSpans(ast, initializer) {
|
|
|
13331
13310
|
const escapeIndex = initializer.getText().indexOf("\\", 1);
|
|
13332
13311
|
if (escapeIndex > -1) {
|
|
13333
13312
|
const newSpan = new ParseSpan(0, initializer.getWidth());
|
|
13334
|
-
const newSourceSpan = new
|
|
13313
|
+
const newSourceSpan = new AbsoluteSourceSpan3(initializer.getStart(), initializer.getEnd());
|
|
13335
13314
|
ast.visit(new ReplaceSpanVisitor(escapeIndex, newSpan, newSourceSpan));
|
|
13336
13315
|
}
|
|
13337
13316
|
}
|
|
@@ -13410,7 +13389,7 @@ function getSourceMapping(shimSf, position, resolver, isDiagnosticRequest) {
|
|
|
13410
13389
|
}
|
|
13411
13390
|
function isInHostBindingTcb(node) {
|
|
13412
13391
|
let current = node;
|
|
13413
|
-
while (current && !
|
|
13392
|
+
while (current && !ts57.isFunctionDeclaration(current)) {
|
|
13414
13393
|
if (isHostBindingsBlockGuard(current)) {
|
|
13415
13394
|
return true;
|
|
13416
13395
|
}
|
|
@@ -13420,14 +13399,14 @@ function isInHostBindingTcb(node) {
|
|
|
13420
13399
|
}
|
|
13421
13400
|
function findTypeCheckBlock(file, id, isDiagnosticRequest) {
|
|
13422
13401
|
for (const stmt of file.statements) {
|
|
13423
|
-
if (
|
|
13402
|
+
if (ts57.isFunctionDeclaration(stmt) && getTypeCheckId2(stmt, file, isDiagnosticRequest) === id) {
|
|
13424
13403
|
return stmt;
|
|
13425
13404
|
}
|
|
13426
13405
|
}
|
|
13427
|
-
return findNodeInFile(file, (node) =>
|
|
13406
|
+
return findNodeInFile(file, (node) => ts57.isFunctionDeclaration(node) && getTypeCheckId2(node, file, isDiagnosticRequest) === id);
|
|
13428
13407
|
}
|
|
13429
13408
|
function findSourceLocation(node, sourceFile, isDiagnosticsRequest) {
|
|
13430
|
-
while (node !== void 0 && !
|
|
13409
|
+
while (node !== void 0 && !ts57.isFunctionDeclaration(node)) {
|
|
13431
13410
|
if (hasIgnoreForDiagnosticsMarker(node, sourceFile) && isDiagnosticsRequest) {
|
|
13432
13411
|
return null;
|
|
13433
13412
|
}
|
|
@@ -13444,7 +13423,7 @@ function findSourceLocation(node, sourceFile, isDiagnosticsRequest) {
|
|
|
13444
13423
|
return null;
|
|
13445
13424
|
}
|
|
13446
13425
|
function getTypeCheckId2(node, sourceFile, isDiagnosticRequest) {
|
|
13447
|
-
while (!
|
|
13426
|
+
while (!ts57.isFunctionDeclaration(node)) {
|
|
13448
13427
|
if (hasIgnoreForDiagnosticsMarker(node, sourceFile) && isDiagnosticRequest) {
|
|
13449
13428
|
return null;
|
|
13450
13429
|
}
|
|
@@ -13454,8 +13433,8 @@ function getTypeCheckId2(node, sourceFile, isDiagnosticRequest) {
|
|
|
13454
13433
|
}
|
|
13455
13434
|
}
|
|
13456
13435
|
const start = node.getFullStart();
|
|
13457
|
-
return
|
|
13458
|
-
if (kind !==
|
|
13436
|
+
return ts57.forEachLeadingCommentRange(sourceFile.text, start, (pos, end, kind) => {
|
|
13437
|
+
if (kind !== ts57.SyntaxKind.MultiLineCommentTrivia) {
|
|
13459
13438
|
return null;
|
|
13460
13439
|
}
|
|
13461
13440
|
const commentText = sourceFile.text.substring(pos + 2, end - 2);
|
|
@@ -13480,167 +13459,92 @@ function findNodeInFile(file, predicate) {
|
|
|
13480
13459
|
if (predicate(node)) {
|
|
13481
13460
|
return node;
|
|
13482
13461
|
}
|
|
13483
|
-
return
|
|
13462
|
+
return ts57.forEachChild(node, visit2) ?? null;
|
|
13484
13463
|
};
|
|
13485
|
-
return
|
|
13464
|
+
return ts57.forEachChild(file, visit2) ?? null;
|
|
13486
13465
|
}
|
|
13487
13466
|
|
|
13488
13467
|
// packages/compiler-cli/src/ngtsc/typecheck/src/type_constructor.js
|
|
13489
13468
|
function generateTypeCtorDeclarationFn(env, meta, nodeTypeRef, typeParams) {
|
|
13490
|
-
const
|
|
13491
|
-
const
|
|
13492
|
-
const
|
|
13469
|
+
const typeArgs = generateGenericArgs(typeParams);
|
|
13470
|
+
const typeRef = ts58.isIdentifier(nodeTypeRef) ? nodeTypeRef.text : tempPrint(nodeTypeRef, nodeTypeRef.getSourceFile());
|
|
13471
|
+
const typeRefWithGenerics = `${typeRef}${typeArgs}`;
|
|
13472
|
+
const initParam = constructTypeCtorParameter(env, meta, nodeTypeRef.getSourceFile(), typeRef, typeRefWithGenerics);
|
|
13493
13473
|
const typeParameters = typeParametersWithDefaultTypes(typeParams);
|
|
13474
|
+
let source;
|
|
13494
13475
|
if (meta.body) {
|
|
13495
|
-
const fnType =
|
|
13496
|
-
|
|
13497
|
-
typeParameters,
|
|
13498
|
-
/* parameters */
|
|
13499
|
-
[initParam],
|
|
13500
|
-
/* type */
|
|
13501
|
-
rawType
|
|
13502
|
-
);
|
|
13503
|
-
const decl = ts56.factory.createVariableDeclaration(
|
|
13504
|
-
/* name */
|
|
13505
|
-
meta.fnName,
|
|
13506
|
-
/* exclamationToken */
|
|
13507
|
-
void 0,
|
|
13508
|
-
/* type */
|
|
13509
|
-
fnType,
|
|
13510
|
-
/* body */
|
|
13511
|
-
ts56.factory.createNonNullExpression(ts56.factory.createNull())
|
|
13512
|
-
);
|
|
13513
|
-
const declList = ts56.factory.createVariableDeclarationList([decl], ts56.NodeFlags.Const);
|
|
13514
|
-
return ts56.factory.createVariableStatement(
|
|
13515
|
-
/* modifiers */
|
|
13516
|
-
void 0,
|
|
13517
|
-
/* declarationList */
|
|
13518
|
-
declList
|
|
13519
|
-
);
|
|
13476
|
+
const fnType = `${typeParameters}(${initParam}) => ${typeRefWithGenerics}`;
|
|
13477
|
+
source = `const ${meta.fnName}: ${fnType} = null!`;
|
|
13520
13478
|
} else {
|
|
13521
|
-
|
|
13522
|
-
/* modifiers */
|
|
13523
|
-
[ts56.factory.createModifier(ts56.SyntaxKind.DeclareKeyword)],
|
|
13524
|
-
/* asteriskToken */
|
|
13525
|
-
void 0,
|
|
13526
|
-
/* name */
|
|
13527
|
-
meta.fnName,
|
|
13528
|
-
/* typeParameters */
|
|
13529
|
-
typeParameters,
|
|
13530
|
-
/* parameters */
|
|
13531
|
-
[initParam],
|
|
13532
|
-
/* type */
|
|
13533
|
-
rawType,
|
|
13534
|
-
/* body */
|
|
13535
|
-
void 0
|
|
13536
|
-
);
|
|
13479
|
+
source = `declare function ${meta.fnName}${typeParameters}(${initParam}): ${typeRefWithGenerics}`;
|
|
13537
13480
|
}
|
|
13481
|
+
return new TcbExpr(source);
|
|
13538
13482
|
}
|
|
13539
13483
|
function generateInlineTypeCtor(env, node, meta) {
|
|
13540
|
-
const
|
|
13541
|
-
const
|
|
13542
|
-
const initParam = constructTypeCtorParameter(env, meta,
|
|
13543
|
-
|
|
13544
|
-
|
|
13545
|
-
|
|
13546
|
-
|
|
13547
|
-
|
|
13548
|
-
}
|
|
13549
|
-
return ts56.factory.createMethodDeclaration(
|
|
13550
|
-
/* modifiers */
|
|
13551
|
-
[ts56.factory.createModifier(ts56.SyntaxKind.StaticKeyword)],
|
|
13552
|
-
/* asteriskToken */
|
|
13553
|
-
void 0,
|
|
13554
|
-
/* name */
|
|
13555
|
-
meta.fnName,
|
|
13556
|
-
/* questionToken */
|
|
13557
|
-
void 0,
|
|
13558
|
-
/* typeParameters */
|
|
13559
|
-
typeParametersWithDefaultTypes(node.typeParameters),
|
|
13560
|
-
/* parameters */
|
|
13561
|
-
[initParam],
|
|
13562
|
-
/* type */
|
|
13563
|
-
rawType,
|
|
13564
|
-
/* body */
|
|
13565
|
-
body
|
|
13566
|
-
);
|
|
13567
|
-
}
|
|
13568
|
-
function constructTypeCtorParameter(env, meta, rawType) {
|
|
13484
|
+
const typeRef = node.name.text;
|
|
13485
|
+
const typeRefWithGenerics = `${typeRef}${generateGenericArgs(node.typeParameters)}`;
|
|
13486
|
+
const initParam = constructTypeCtorParameter(env, meta, node.getSourceFile(), typeRef, typeRefWithGenerics);
|
|
13487
|
+
const body = `{ return null!; }`;
|
|
13488
|
+
const typeParams = typeParametersWithDefaultTypes(node.typeParameters);
|
|
13489
|
+
return `static ${meta.fnName}${typeParams}(${initParam}): ${typeRefWithGenerics} ${body}`;
|
|
13490
|
+
}
|
|
13491
|
+
function constructTypeCtorParameter(env, meta, sourceFile, typeRef, typeRefWithGenerics) {
|
|
13569
13492
|
let initType = null;
|
|
13570
13493
|
const plainKeys = [];
|
|
13571
13494
|
const coercedKeys = [];
|
|
13572
13495
|
const signalInputKeys = [];
|
|
13573
13496
|
for (const { classPropertyName, transform, isSignal } of meta.fields.inputs) {
|
|
13574
13497
|
if (isSignal) {
|
|
13575
|
-
signalInputKeys.push(
|
|
13498
|
+
signalInputKeys.push(quoteAndEscape(classPropertyName));
|
|
13576
13499
|
} else if (!meta.coercedInputFields.has(classPropertyName)) {
|
|
13577
|
-
plainKeys.push(
|
|
13500
|
+
plainKeys.push(quoteAndEscape(classPropertyName));
|
|
13578
13501
|
} else {
|
|
13579
|
-
const coercionType = transform != null ? transform.type.node :
|
|
13580
|
-
coercedKeys.push(
|
|
13581
|
-
/* modifiers */
|
|
13582
|
-
void 0,
|
|
13583
|
-
/* name */
|
|
13584
|
-
classPropertyName,
|
|
13585
|
-
/* questionToken */
|
|
13586
|
-
void 0,
|
|
13587
|
-
/* type */
|
|
13588
|
-
coercionType
|
|
13589
|
-
));
|
|
13502
|
+
const coercionType = transform != null ? tempPrint(transform.type.node, sourceFile) : `typeof ${typeRef}.ngAcceptInputType_${classPropertyName}`;
|
|
13503
|
+
coercedKeys.push(`${classPropertyName}: ${coercionType}`);
|
|
13590
13504
|
}
|
|
13591
13505
|
}
|
|
13592
13506
|
if (plainKeys.length > 0) {
|
|
13593
|
-
|
|
13594
|
-
initType = ts56.factory.createTypeReferenceNode("Pick", [rawType, keyTypeUnion]);
|
|
13507
|
+
initType = `Pick<${typeRefWithGenerics}, ${plainKeys.join(" | ")}>`;
|
|
13595
13508
|
}
|
|
13596
13509
|
if (coercedKeys.length > 0) {
|
|
13597
|
-
|
|
13598
|
-
|
|
13510
|
+
let coercedLiteral = "{\n";
|
|
13511
|
+
for (const key of coercedKeys) {
|
|
13512
|
+
coercedLiteral += `${key};
|
|
13513
|
+
`;
|
|
13514
|
+
}
|
|
13515
|
+
coercedLiteral += "}";
|
|
13516
|
+
initType = initType !== null ? `${initType} & ${coercedLiteral}` : coercedLiteral;
|
|
13599
13517
|
}
|
|
13600
13518
|
if (signalInputKeys.length > 0) {
|
|
13601
|
-
const keyTypeUnion =
|
|
13602
|
-
const
|
|
13603
|
-
|
|
13604
|
-
|
|
13605
|
-
new ExpressionType2(new WrappedNodeExpr7(keyTypeUnion))
|
|
13606
|
-
]);
|
|
13607
|
-
initType = initType !== null ? ts56.factory.createIntersectionTypeNode([initType, unwrapDirectiveSignalInputsExpr]) : unwrapDirectiveSignalInputsExpr;
|
|
13519
|
+
const keyTypeUnion = signalInputKeys.join(" | ");
|
|
13520
|
+
const unwrapRef = env.referenceExternalSymbol(R3Identifiers3.UnwrapDirectiveSignalInputs.moduleName, R3Identifiers3.UnwrapDirectiveSignalInputs.name);
|
|
13521
|
+
const unwrapExpr = `${unwrapRef.print()}<${typeRefWithGenerics}, ${keyTypeUnion}>`;
|
|
13522
|
+
initType = initType !== null ? `${initType} & ${unwrapExpr}` : unwrapExpr;
|
|
13608
13523
|
}
|
|
13609
13524
|
if (initType === null) {
|
|
13610
|
-
initType =
|
|
13525
|
+
initType = "{}";
|
|
13611
13526
|
}
|
|
13612
|
-
return
|
|
13613
|
-
/* modifiers */
|
|
13614
|
-
void 0,
|
|
13615
|
-
/* dotDotDotToken */
|
|
13616
|
-
void 0,
|
|
13617
|
-
/* name */
|
|
13618
|
-
"init",
|
|
13619
|
-
/* questionToken */
|
|
13620
|
-
void 0,
|
|
13621
|
-
/* type */
|
|
13622
|
-
initType,
|
|
13623
|
-
/* initializer */
|
|
13624
|
-
void 0
|
|
13625
|
-
);
|
|
13527
|
+
return `init: ${initType}`;
|
|
13626
13528
|
}
|
|
13627
|
-
function generateGenericArgs(
|
|
13628
|
-
|
|
13529
|
+
function generateGenericArgs(typeParameters) {
|
|
13530
|
+
if (typeParameters === void 0 || typeParameters.length === 0) {
|
|
13531
|
+
return "";
|
|
13532
|
+
}
|
|
13533
|
+
return `<${typeParameters.map((param) => param.name.text).join(", ")}>`;
|
|
13629
13534
|
}
|
|
13630
13535
|
function requiresInlineTypeCtor(node, host, env) {
|
|
13631
13536
|
return !checkIfGenericTypeBoundsCanBeEmitted(node, host, env);
|
|
13632
13537
|
}
|
|
13633
13538
|
function typeParametersWithDefaultTypes(params) {
|
|
13634
|
-
if (params === void 0) {
|
|
13635
|
-
return
|
|
13539
|
+
if (params === void 0 || params.length === 0) {
|
|
13540
|
+
return "";
|
|
13636
13541
|
}
|
|
13637
|
-
|
|
13638
|
-
|
|
13639
|
-
|
|
13640
|
-
|
|
13641
|
-
return param;
|
|
13642
|
-
}
|
|
13542
|
+
const paramStrings = params.map((param) => {
|
|
13543
|
+
const constraint = param.constraint ? ` extends ${tempPrint(param.constraint, param.getSourceFile())}` : "";
|
|
13544
|
+
const defaultValue = ` = ${param.default ? tempPrint(param.default, param.getSourceFile()) : "any"}`;
|
|
13545
|
+
return `${param.name.text}${constraint}${defaultValue}`;
|
|
13643
13546
|
});
|
|
13547
|
+
return `<${paramStrings.join(", ")}>`;
|
|
13644
13548
|
}
|
|
13645
13549
|
|
|
13646
13550
|
// packages/compiler-cli/src/ngtsc/typecheck/src/environment.js
|
|
@@ -13668,17 +13572,17 @@ var Environment = class extends ReferenceEmitEnvironment {
|
|
|
13668
13572
|
const dirRef = dir.ref;
|
|
13669
13573
|
const node = dirRef.node;
|
|
13670
13574
|
if (this.typeCtors.has(node)) {
|
|
13671
|
-
return this.typeCtors.get(node);
|
|
13575
|
+
return new TcbExpr(this.typeCtors.get(node));
|
|
13672
13576
|
}
|
|
13673
13577
|
if (requiresInlineTypeCtor(node, this.reflector, this)) {
|
|
13674
13578
|
const ref = this.reference(dirRef);
|
|
13675
|
-
const typeCtorExpr =
|
|
13579
|
+
const typeCtorExpr = `${ref.print()}.ngTypeCtor`;
|
|
13676
13580
|
this.typeCtors.set(node, typeCtorExpr);
|
|
13677
|
-
return typeCtorExpr;
|
|
13581
|
+
return new TcbExpr(typeCtorExpr);
|
|
13678
13582
|
} else {
|
|
13679
13583
|
const fnName = `_ctor${this.nextIds.typeCtor++}`;
|
|
13680
13584
|
const nodeTypeRef = this.referenceType(dirRef);
|
|
13681
|
-
if (!
|
|
13585
|
+
if (!ts59.isTypeReferenceNode(nodeTypeRef)) {
|
|
13682
13586
|
throw new Error(`Expected TypeReferenceNode from reference to ${dirRef.debugName}`);
|
|
13683
13587
|
}
|
|
13684
13588
|
const meta = {
|
|
@@ -13694,9 +13598,8 @@ var Environment = class extends ReferenceEmitEnvironment {
|
|
|
13694
13598
|
const typeParams = this.emitTypeParameters(node);
|
|
13695
13599
|
const typeCtor = generateTypeCtorDeclarationFn(this, meta, nodeTypeRef.typeName, typeParams);
|
|
13696
13600
|
this.typeCtorStatements.push(typeCtor);
|
|
13697
|
-
|
|
13698
|
-
|
|
13699
|
-
return fnId;
|
|
13601
|
+
this.typeCtors.set(node, fnName);
|
|
13602
|
+
return new TcbExpr(fnName);
|
|
13700
13603
|
}
|
|
13701
13604
|
}
|
|
13702
13605
|
/*
|
|
@@ -13704,13 +13607,13 @@ var Environment = class extends ReferenceEmitEnvironment {
|
|
|
13704
13607
|
*/
|
|
13705
13608
|
pipeInst(ref) {
|
|
13706
13609
|
if (this.pipeInsts.has(ref.node)) {
|
|
13707
|
-
return this.pipeInsts.get(ref.node);
|
|
13610
|
+
return new TcbExpr(this.pipeInsts.get(ref.node));
|
|
13708
13611
|
}
|
|
13709
13612
|
const pipeType = this.referenceType(ref);
|
|
13710
|
-
const pipeInstId =
|
|
13711
|
-
this.pipeInstStatements.push(tsDeclareVariable(pipeInstId, pipeType));
|
|
13613
|
+
const pipeInstId = `_pipe${this.nextIds.pipeInst++}`;
|
|
13712
13614
|
this.pipeInsts.set(ref.node, pipeInstId);
|
|
13713
|
-
|
|
13615
|
+
this.pipeInstStatements.push(declareVariable(new TcbExpr(pipeInstId), new TcbExpr(tempPrint(pipeType, this.contextFile))));
|
|
13616
|
+
return new TcbExpr(pipeInstId);
|
|
13714
13617
|
}
|
|
13715
13618
|
/**
|
|
13716
13619
|
* Generate a `ts.Expression` that references the given node.
|
|
@@ -13720,7 +13623,8 @@ var Environment = class extends ReferenceEmitEnvironment {
|
|
|
13720
13623
|
reference(ref) {
|
|
13721
13624
|
const ngExpr = this.refEmitter.emit(ref, this.contextFile, ImportFlags.NoAliasing);
|
|
13722
13625
|
assertSuccessfulReferenceEmit(ngExpr, this.contextFile, "class");
|
|
13723
|
-
|
|
13626
|
+
const tsExpression = translateExpression(this.contextFile, ngExpr.expression, this.importManager);
|
|
13627
|
+
return new TcbExpr(tempPrint(tsExpression, this.contextFile));
|
|
13724
13628
|
}
|
|
13725
13629
|
emitTypeParameters(declaration) {
|
|
13726
13630
|
const emitter = new TypeParameterEmitter(declaration.typeParameters, this.reflector);
|
|
@@ -13732,8 +13636,8 @@ var Environment = class extends ReferenceEmitEnvironment {
|
|
|
13732
13636
|
};
|
|
13733
13637
|
|
|
13734
13638
|
// packages/compiler-cli/src/ngtsc/typecheck/src/oob.js
|
|
13735
|
-
import { AbsoluteSourceSpan as
|
|
13736
|
-
import
|
|
13639
|
+
import { AbsoluteSourceSpan as AbsoluteSourceSpan4, BindingType as BindingType2, ParseSourceSpan as ParseSourceSpan2, TmplAstBoundAttribute as TmplAstBoundAttribute2, TmplAstBoundEvent as TmplAstBoundEvent2, TmplAstComponent, TmplAstDirective, TmplAstElement } from "@angular/compiler";
|
|
13640
|
+
import ts60 from "typescript";
|
|
13737
13641
|
var OutOfBandDiagnosticRecorderImpl = class {
|
|
13738
13642
|
resolver;
|
|
13739
13643
|
_diagnostics = [];
|
|
@@ -13768,7 +13672,7 @@ var OutOfBandDiagnosticRecorderImpl = class {
|
|
|
13768
13672
|
const mapping = this.resolver.getTemplateSourceMapping(id);
|
|
13769
13673
|
const value = ref.value.trim();
|
|
13770
13674
|
const errorMsg = `No directive found with exportAs '${value}'.`;
|
|
13771
|
-
this._diagnostics.push(makeTemplateDiagnostic(id, mapping, ref.valueSpan || ref.sourceSpan,
|
|
13675
|
+
this._diagnostics.push(makeTemplateDiagnostic(id, mapping, ref.valueSpan || ref.sourceSpan, ts60.DiagnosticCategory.Error, ngErrorCode(ErrorCode.MISSING_REFERENCE_TARGET), errorMsg));
|
|
13772
13676
|
}
|
|
13773
13677
|
missingPipe(id, ast, isStandalone) {
|
|
13774
13678
|
if (this.recordedPipes.has(ast)) {
|
|
@@ -13791,7 +13695,7 @@ To fix this, import the "${suggestedClassName}" class from "${suggestedImport}"
|
|
|
13791
13695
|
To fix this, import the "${suggestedClassName}" class from "${suggestedImport}" and add it to the "imports" array of the module declaring the component.`;
|
|
13792
13696
|
}
|
|
13793
13697
|
}
|
|
13794
|
-
this._diagnostics.push(makeTemplateDiagnostic(id, mapping, sourceSpan,
|
|
13698
|
+
this._diagnostics.push(makeTemplateDiagnostic(id, mapping, sourceSpan, ts60.DiagnosticCategory.Error, ngErrorCode(ErrorCode.MISSING_PIPE), errorMsg));
|
|
13795
13699
|
this.recordedPipes.add(ast);
|
|
13796
13700
|
}
|
|
13797
13701
|
deferredPipeUsedEagerly(id, ast) {
|
|
@@ -13804,24 +13708,24 @@ To fix this, import the "${suggestedClassName}" class from "${suggestedImport}"
|
|
|
13804
13708
|
if (sourceSpan === null) {
|
|
13805
13709
|
throw new Error(`Assertion failure: no SourceLocation found for usage of pipe '${ast.name}'.`);
|
|
13806
13710
|
}
|
|
13807
|
-
this._diagnostics.push(makeTemplateDiagnostic(id, mapping, sourceSpan,
|
|
13711
|
+
this._diagnostics.push(makeTemplateDiagnostic(id, mapping, sourceSpan, ts60.DiagnosticCategory.Error, ngErrorCode(ErrorCode.DEFERRED_PIPE_USED_EAGERLY), errorMsg));
|
|
13808
13712
|
this.recordedPipes.add(ast);
|
|
13809
13713
|
}
|
|
13810
13714
|
deferredComponentUsedEagerly(id, element) {
|
|
13811
13715
|
const mapping = this.resolver.getTemplateSourceMapping(id);
|
|
13812
13716
|
const errorMsg = `Element '${element.name}' contains a component or a directive that was imported via \`@Component.deferredImports\`, but the element itself is located outside of a \`@defer\` block in a template. To fix this, either use the '${element.name}' element inside of a \`@defer\` block or import referenced component/directive dependency using the \`@Component.imports\` field.`;
|
|
13813
13717
|
const { start, end } = element.startSourceSpan;
|
|
13814
|
-
const absoluteSourceSpan = new
|
|
13718
|
+
const absoluteSourceSpan = new AbsoluteSourceSpan4(start.offset, end.offset);
|
|
13815
13719
|
const sourceSpan = this.resolver.toTemplateParseSourceSpan(id, absoluteSourceSpan);
|
|
13816
13720
|
if (sourceSpan === null) {
|
|
13817
13721
|
throw new Error(`Assertion failure: no SourceLocation found for usage of pipe '${element.name}'.`);
|
|
13818
13722
|
}
|
|
13819
|
-
this._diagnostics.push(makeTemplateDiagnostic(id, mapping, sourceSpan,
|
|
13723
|
+
this._diagnostics.push(makeTemplateDiagnostic(id, mapping, sourceSpan, ts60.DiagnosticCategory.Error, ngErrorCode(ErrorCode.DEFERRED_DIRECTIVE_USED_EAGERLY), errorMsg));
|
|
13820
13724
|
}
|
|
13821
13725
|
duplicateTemplateVar(id, variable, firstDecl) {
|
|
13822
13726
|
const mapping = this.resolver.getTemplateSourceMapping(id);
|
|
13823
13727
|
const errorMsg = `Cannot redeclare variable '${variable.name}' as it was previously declared elsewhere for the same template.`;
|
|
13824
|
-
this._diagnostics.push(makeTemplateDiagnostic(id, mapping, variable.sourceSpan,
|
|
13728
|
+
this._diagnostics.push(makeTemplateDiagnostic(id, mapping, variable.sourceSpan, ts60.DiagnosticCategory.Error, ngErrorCode(ErrorCode.DUPLICATE_VARIABLE_DECLARATION), errorMsg, [
|
|
13825
13729
|
{
|
|
13826
13730
|
text: `The variable '${firstDecl.name}' was first declared here.`,
|
|
13827
13731
|
start: firstDecl.sourceSpan.start.offset,
|
|
@@ -13862,7 +13766,7 @@ To fix this, import the "${suggestedClassName}" class from "${suggestedImport}"
|
|
|
13862
13766
|
const message = `This structural directive supports advanced type inference, but the current compiler configuration prevents its usage. The variable ${varIdentification} will have type 'any' as a result.
|
|
13863
13767
|
|
|
13864
13768
|
Consider enabling the 'strictTemplates' option in your tsconfig.json for better type inference within this template.`;
|
|
13865
|
-
this._diagnostics.push(makeTemplateDiagnostic(id, mapping, diagnosticVar.keySpan,
|
|
13769
|
+
this._diagnostics.push(makeTemplateDiagnostic(id, mapping, diagnosticVar.keySpan, ts60.DiagnosticCategory.Suggestion, ngErrorCode(ErrorCode.SUGGEST_SUBOPTIMAL_TYPE_INFERENCE), message));
|
|
13866
13770
|
}
|
|
13867
13771
|
splitTwoWayBinding(id, input, output, inputConsumer, outputConsumer) {
|
|
13868
13772
|
const mapping = this.resolver.getTemplateSourceMapping(id);
|
|
@@ -13896,7 +13800,7 @@ Consider enabling the 'strictTemplates' option in your tsconfig.json for better
|
|
|
13896
13800
|
sourceFile: outputConsumer.name.getSourceFile()
|
|
13897
13801
|
});
|
|
13898
13802
|
}
|
|
13899
|
-
this._diagnostics.push(makeTemplateDiagnostic(id, mapping, input.keySpan,
|
|
13803
|
+
this._diagnostics.push(makeTemplateDiagnostic(id, mapping, input.keySpan, ts60.DiagnosticCategory.Error, ngErrorCode(ErrorCode.SPLIT_TWO_WAY_BINDING), errorMsg, relatedMessages));
|
|
13900
13804
|
}
|
|
13901
13805
|
missingRequiredInputs(id, element, directiveName, isComponent, inputAliases) {
|
|
13902
13806
|
const message = `Required input${inputAliases.length === 1 ? "" : "s"} ${inputAliases.map((n2) => `'${n2}'`).join(", ")} from ${isComponent ? "component" : "directive"} ${directiveName} must be specified.`;
|
|
@@ -13916,7 +13820,7 @@ Consider enabling the 'strictTemplates' option in your tsconfig.json for better
|
|
|
13916
13820
|
const end = element.startSourceSpan.end.moveBy(start.offset + name.length - element.startSourceSpan.end.offset);
|
|
13917
13821
|
span = new ParseSourceSpan2(start, end);
|
|
13918
13822
|
}
|
|
13919
|
-
this._diagnostics.push(makeTemplateDiagnostic(id, this.resolver.getTemplateSourceMapping(id), span,
|
|
13823
|
+
this._diagnostics.push(makeTemplateDiagnostic(id, this.resolver.getTemplateSourceMapping(id), span, ts60.DiagnosticCategory.Error, ngErrorCode(ErrorCode.MISSING_REQUIRED_INPUTS), message));
|
|
13920
13824
|
}
|
|
13921
13825
|
illegalForLoopTrackAccess(id, block, access) {
|
|
13922
13826
|
const sourceSpan = this.resolver.toTemplateParseSourceSpan(id, access.sourceSpan);
|
|
@@ -13925,7 +13829,7 @@ Consider enabling the 'strictTemplates' option in your tsconfig.json for better
|
|
|
13925
13829
|
}
|
|
13926
13830
|
const messageVars = [block.item, ...block.contextVariables.filter((v) => v.value === "$index")].map((v) => `'${v.name}'`).join(", ");
|
|
13927
13831
|
const message = `Cannot access '${access.name}' inside of a track expression. Only ${messageVars} and properties on the containing component are available to this expression.`;
|
|
13928
|
-
this._diagnostics.push(makeTemplateDiagnostic(id, this.resolver.getTemplateSourceMapping(id), sourceSpan,
|
|
13832
|
+
this._diagnostics.push(makeTemplateDiagnostic(id, this.resolver.getTemplateSourceMapping(id), sourceSpan, ts60.DiagnosticCategory.Error, ngErrorCode(ErrorCode.ILLEGAL_FOR_LOOP_TRACK_ACCESS), message));
|
|
13929
13833
|
}
|
|
13930
13834
|
inaccessibleDeferredTriggerElement(id, trigger) {
|
|
13931
13835
|
let message;
|
|
@@ -13936,7 +13840,7 @@ Consider enabling the 'strictTemplates' option in your tsconfig.json for better
|
|
|
13936
13840
|
Check that an element with #${trigger.reference} exists in the same template and it's accessible from the @defer block.
|
|
13937
13841
|
Deferred blocks can only access triggers in same view, a parent embedded view or the root view of the @placeholder block.`;
|
|
13938
13842
|
}
|
|
13939
|
-
this._diagnostics.push(makeTemplateDiagnostic(id, this.resolver.getTemplateSourceMapping(id), trigger.sourceSpan,
|
|
13843
|
+
this._diagnostics.push(makeTemplateDiagnostic(id, this.resolver.getTemplateSourceMapping(id), trigger.sourceSpan, ts60.DiagnosticCategory.Error, ngErrorCode(ErrorCode.INACCESSIBLE_DEFERRED_TRIGGER_ELEMENT), message));
|
|
13940
13844
|
}
|
|
13941
13845
|
controlFlowPreventingContentProjection(id, category, projectionNode, componentName, slotSelector, controlFlowNode, preservesWhitespaces) {
|
|
13942
13846
|
const blockName = controlFlowNode.nameSpan.toString().trim();
|
|
@@ -13958,43 +13862,43 @@ Deferred blocks can only access triggers in same view, a parent embedded view or
|
|
|
13958
13862
|
if (sourceSpan === null) {
|
|
13959
13863
|
throw new Error(`Assertion failure: no SourceLocation found for property write.`);
|
|
13960
13864
|
}
|
|
13961
|
-
this._diagnostics.push(makeTemplateDiagnostic(id, this.resolver.getTemplateSourceMapping(id), sourceSpan,
|
|
13865
|
+
this._diagnostics.push(makeTemplateDiagnostic(id, this.resolver.getTemplateSourceMapping(id), sourceSpan, ts60.DiagnosticCategory.Error, ngErrorCode(ErrorCode.ILLEGAL_LET_WRITE), `Cannot assign to @let declaration '${target.name}'.`));
|
|
13962
13866
|
}
|
|
13963
13867
|
letUsedBeforeDefinition(id, node, target) {
|
|
13964
13868
|
const sourceSpan = this.resolver.toTemplateParseSourceSpan(id, node.sourceSpan);
|
|
13965
13869
|
if (sourceSpan === null) {
|
|
13966
13870
|
throw new Error(`Assertion failure: no SourceLocation found for property read.`);
|
|
13967
13871
|
}
|
|
13968
|
-
this._diagnostics.push(makeTemplateDiagnostic(id, this.resolver.getTemplateSourceMapping(id), sourceSpan,
|
|
13872
|
+
this._diagnostics.push(makeTemplateDiagnostic(id, this.resolver.getTemplateSourceMapping(id), sourceSpan, ts60.DiagnosticCategory.Error, ngErrorCode(ErrorCode.LET_USED_BEFORE_DEFINITION), `Cannot read @let declaration '${target.name}' before it has been defined.`));
|
|
13969
13873
|
}
|
|
13970
13874
|
conflictingDeclaration(id, decl) {
|
|
13971
13875
|
const mapping = this.resolver.getTemplateSourceMapping(id);
|
|
13972
13876
|
const errorMsg = `Cannot declare @let called '${decl.name}' as there is another symbol in the template with the same name.`;
|
|
13973
|
-
this._diagnostics.push(makeTemplateDiagnostic(id, mapping, decl.sourceSpan,
|
|
13877
|
+
this._diagnostics.push(makeTemplateDiagnostic(id, mapping, decl.sourceSpan, ts60.DiagnosticCategory.Error, ngErrorCode(ErrorCode.CONFLICTING_LET_DECLARATION), errorMsg));
|
|
13974
13878
|
}
|
|
13975
13879
|
missingNamedTemplateDependency(id, node) {
|
|
13976
13880
|
this._diagnostics.push(makeTemplateDiagnostic(
|
|
13977
13881
|
id,
|
|
13978
13882
|
this.resolver.getTemplateSourceMapping(id),
|
|
13979
13883
|
node.startSourceSpan,
|
|
13980
|
-
|
|
13884
|
+
ts60.DiagnosticCategory.Error,
|
|
13981
13885
|
ngErrorCode(ErrorCode.MISSING_NAMED_TEMPLATE_DEPENDENCY),
|
|
13982
13886
|
// Wording is meant to mimic the wording TS uses in their diagnostic for missing symbols.
|
|
13983
13887
|
`Cannot find name "${node instanceof TmplAstDirective ? node.name : node.componentName}". Selectorless references are only supported to classes or non-type import statements.`
|
|
13984
13888
|
));
|
|
13985
13889
|
}
|
|
13986
13890
|
incorrectTemplateDependencyType(id, node) {
|
|
13987
|
-
this._diagnostics.push(makeTemplateDiagnostic(id, this.resolver.getTemplateSourceMapping(id), node.startSourceSpan,
|
|
13891
|
+
this._diagnostics.push(makeTemplateDiagnostic(id, this.resolver.getTemplateSourceMapping(id), node.startSourceSpan, ts60.DiagnosticCategory.Error, ngErrorCode(ErrorCode.INCORRECT_NAMED_TEMPLATE_DEPENDENCY_TYPE), `Incorrect reference type. Type must be a standalone ${node instanceof TmplAstComponent ? "@Component" : "@Directive"}.`));
|
|
13988
13892
|
}
|
|
13989
13893
|
unclaimedDirectiveBinding(id, directive, node) {
|
|
13990
13894
|
const errorMsg = `Directive ${directive.name} does not have an ${node instanceof TmplAstBoundEvent2 ? "output" : "input"} named "${node.name}". Bindings to directives must target existing inputs or outputs.`;
|
|
13991
|
-
this._diagnostics.push(makeTemplateDiagnostic(id, this.resolver.getTemplateSourceMapping(id), node.keySpan || node.sourceSpan,
|
|
13895
|
+
this._diagnostics.push(makeTemplateDiagnostic(id, this.resolver.getTemplateSourceMapping(id), node.keySpan || node.sourceSpan, ts60.DiagnosticCategory.Error, ngErrorCode(ErrorCode.UNCLAIMED_DIRECTIVE_BINDING), errorMsg));
|
|
13992
13896
|
}
|
|
13993
13897
|
deferImplicitTriggerMissingPlaceholder(id, trigger) {
|
|
13994
|
-
this._diagnostics.push(makeTemplateDiagnostic(id, this.resolver.getTemplateSourceMapping(id), trigger.sourceSpan,
|
|
13898
|
+
this._diagnostics.push(makeTemplateDiagnostic(id, this.resolver.getTemplateSourceMapping(id), trigger.sourceSpan, ts60.DiagnosticCategory.Error, ngErrorCode(ErrorCode.DEFER_IMPLICIT_TRIGGER_MISSING_PLACEHOLDER), "Trigger with no target can only be placed on an @defer that has a @placeholder block"));
|
|
13995
13899
|
}
|
|
13996
13900
|
deferImplicitTriggerInvalidPlaceholder(id, trigger) {
|
|
13997
|
-
this._diagnostics.push(makeTemplateDiagnostic(id, this.resolver.getTemplateSourceMapping(id), trigger.sourceSpan,
|
|
13901
|
+
this._diagnostics.push(makeTemplateDiagnostic(id, this.resolver.getTemplateSourceMapping(id), trigger.sourceSpan, ts60.DiagnosticCategory.Error, ngErrorCode(ErrorCode.DEFER_IMPLICIT_TRIGGER_INVALID_PLACEHOLDER), "Trigger with no target can only be placed on an @defer that has a @placeholder block with exactly one root element node"));
|
|
13998
13902
|
}
|
|
13999
13903
|
formFieldUnsupportedBinding(id, node) {
|
|
14000
13904
|
let message;
|
|
@@ -14011,7 +13915,7 @@ Deferred blocks can only access triggers in same view, a parent embedded view or
|
|
|
14011
13915
|
} else {
|
|
14012
13916
|
message = `Setting the '${node.name}' attribute is not allowed on nodes using the '[formField]' directive`;
|
|
14013
13917
|
}
|
|
14014
|
-
this._diagnostics.push(makeTemplateDiagnostic(id, this.resolver.getTemplateSourceMapping(id), node.sourceSpan,
|
|
13918
|
+
this._diagnostics.push(makeTemplateDiagnostic(id, this.resolver.getTemplateSourceMapping(id), node.sourceSpan, ts60.DiagnosticCategory.Error, ngErrorCode(ErrorCode.FORM_FIELD_UNSUPPORTED_BINDING), message));
|
|
14015
13919
|
}
|
|
14016
13920
|
};
|
|
14017
13921
|
function makeInlineDiagnostic(id, code, node, messageText, relatedInformation) {
|
|
@@ -14023,7 +13927,7 @@ function makeInlineDiagnostic(id, code, node, messageText, relatedInformation) {
|
|
|
14023
13927
|
}
|
|
14024
13928
|
|
|
14025
13929
|
// packages/compiler-cli/src/ngtsc/typecheck/src/shim.js
|
|
14026
|
-
import
|
|
13930
|
+
import ts61 from "typescript";
|
|
14027
13931
|
var TypeCheckShimGenerator = class {
|
|
14028
13932
|
extensionPrefix = "ngtypecheck";
|
|
14029
13933
|
shouldEmit = false;
|
|
@@ -14031,7 +13935,7 @@ var TypeCheckShimGenerator = class {
|
|
|
14031
13935
|
if (priorShimSf !== null) {
|
|
14032
13936
|
return priorShimSf;
|
|
14033
13937
|
}
|
|
14034
|
-
return
|
|
13938
|
+
return ts61.createSourceFile(genFilePath, "export const USED_FOR_NG_TYPE_CHECKING = true;", ts61.ScriptTarget.Latest, true, ts61.ScriptKind.TS);
|
|
14035
13939
|
}
|
|
14036
13940
|
static shimFor(fileName) {
|
|
14037
13941
|
return absoluteFrom(fileName.replace(/\.tsx?$/, ".ngtypecheck.ts"));
|
|
@@ -14039,71 +13943,9 @@ var TypeCheckShimGenerator = class {
|
|
|
14039
13943
|
};
|
|
14040
13944
|
|
|
14041
13945
|
// packages/compiler-cli/src/ngtsc/typecheck/src/type_check_block.js
|
|
14042
|
-
import
|
|
14043
|
-
|
|
14044
|
-
// packages/compiler-cli/src/ngtsc/typecheck/src/diagnostics.js
|
|
14045
|
-
import { AbsoluteSourceSpan as AbsoluteSourceSpan4 } from "@angular/compiler";
|
|
14046
|
-
import ts60 from "typescript";
|
|
14047
|
-
function wrapForDiagnostics(expr) {
|
|
14048
|
-
return ts60.factory.createParenthesizedExpression(expr);
|
|
14049
|
-
}
|
|
14050
|
-
function wrapForTypeChecker(expr) {
|
|
14051
|
-
return ts60.factory.createParenthesizedExpression(expr);
|
|
14052
|
-
}
|
|
14053
|
-
function addParseSpanInfo(node, span) {
|
|
14054
|
-
let commentText;
|
|
14055
|
-
if (span instanceof AbsoluteSourceSpan4) {
|
|
14056
|
-
commentText = `${span.start},${span.end}`;
|
|
14057
|
-
} else {
|
|
14058
|
-
commentText = `${span.start.offset},${span.end.offset}`;
|
|
14059
|
-
}
|
|
14060
|
-
ts60.addSyntheticTrailingComment(
|
|
14061
|
-
node,
|
|
14062
|
-
ts60.SyntaxKind.MultiLineCommentTrivia,
|
|
14063
|
-
commentText,
|
|
14064
|
-
/* hasTrailingNewLine */
|
|
14065
|
-
false
|
|
14066
|
-
);
|
|
14067
|
-
}
|
|
14068
|
-
function addTypeCheckId(tcb, id) {
|
|
14069
|
-
ts60.addSyntheticLeadingComment(tcb, ts60.SyntaxKind.MultiLineCommentTrivia, id, true);
|
|
14070
|
-
}
|
|
14071
|
-
function shouldReportDiagnostic(diagnostic) {
|
|
14072
|
-
const { code } = diagnostic;
|
|
14073
|
-
if (code === 6133) {
|
|
14074
|
-
return false;
|
|
14075
|
-
} else if (code === 6199) {
|
|
14076
|
-
return false;
|
|
14077
|
-
} else if (code === 2695) {
|
|
14078
|
-
return false;
|
|
14079
|
-
} else if (code === 7006) {
|
|
14080
|
-
return false;
|
|
14081
|
-
}
|
|
14082
|
-
return true;
|
|
14083
|
-
}
|
|
14084
|
-
function translateDiagnostic(diagnostic, resolver) {
|
|
14085
|
-
if (diagnostic.file === void 0 || diagnostic.start === void 0) {
|
|
14086
|
-
return null;
|
|
14087
|
-
}
|
|
14088
|
-
const fullMapping = getSourceMapping(
|
|
14089
|
-
diagnostic.file,
|
|
14090
|
-
diagnostic.start,
|
|
14091
|
-
resolver,
|
|
14092
|
-
/*isDiagnosticsRequest*/
|
|
14093
|
-
true
|
|
14094
|
-
);
|
|
14095
|
-
if (fullMapping === null) {
|
|
14096
|
-
return null;
|
|
14097
|
-
}
|
|
14098
|
-
const { sourceLocation, sourceMapping: templateSourceMapping, span } = fullMapping;
|
|
14099
|
-
return makeTemplateDiagnostic(sourceLocation.id, templateSourceMapping, span, diagnostic.category, diagnostic.code, diagnostic.messageText, void 0, diagnostic.reportsDeprecated !== void 0 ? {
|
|
14100
|
-
reportsDeprecated: diagnostic.reportsDeprecated,
|
|
14101
|
-
relatedMessages: diagnostic.relatedInformation
|
|
14102
|
-
} : void 0);
|
|
14103
|
-
}
|
|
13946
|
+
import ts66 from "typescript";
|
|
14104
13947
|
|
|
14105
13948
|
// packages/compiler-cli/src/ngtsc/typecheck/src/ops/context.js
|
|
14106
|
-
import ts61 from "typescript";
|
|
14107
13949
|
var TcbGenericContextBehavior;
|
|
14108
13950
|
(function(TcbGenericContextBehavior2) {
|
|
14109
13951
|
TcbGenericContextBehavior2[TcbGenericContextBehavior2["UseEmitter"] = 0] = "UseEmitter";
|
|
@@ -14139,7 +13981,7 @@ var Context2 = class {
|
|
|
14139
13981
|
* might change depending on the type of data being stored.
|
|
14140
13982
|
*/
|
|
14141
13983
|
allocateId() {
|
|
14142
|
-
return
|
|
13984
|
+
return `_t${this.nextId++}`;
|
|
14143
13985
|
}
|
|
14144
13986
|
getPipeByName(name) {
|
|
14145
13987
|
if (this.pipes === null || !this.pipes.has(name)) {
|
|
@@ -14151,10 +13993,8 @@ var Context2 = class {
|
|
|
14151
13993
|
|
|
14152
13994
|
// packages/compiler-cli/src/ngtsc/typecheck/src/ops/scope.js
|
|
14153
13995
|
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";
|
|
14154
|
-
import ts81 from "typescript";
|
|
14155
13996
|
|
|
14156
13997
|
// packages/compiler-cli/src/ngtsc/typecheck/src/ops/base.js
|
|
14157
|
-
import ts62 from "typescript";
|
|
14158
13998
|
var TcbOp = class {
|
|
14159
13999
|
/**
|
|
14160
14000
|
* Replacement value or operation used while this `TcbOp` is executing (i.e. to resolve circular
|
|
@@ -14165,70 +14005,25 @@ var TcbOp = class {
|
|
|
14165
14005
|
* circular references.
|
|
14166
14006
|
*/
|
|
14167
14007
|
circularFallback() {
|
|
14168
|
-
return
|
|
14008
|
+
return new TcbExpr("null!");
|
|
14169
14009
|
}
|
|
14170
14010
|
};
|
|
14171
14011
|
|
|
14172
14012
|
// packages/compiler-cli/src/ngtsc/typecheck/src/ops/template.js
|
|
14173
14013
|
import { TmplAstBoundAttribute as TmplAstBoundAttribute3, TmplAstTemplate } from "@angular/compiler";
|
|
14174
|
-
import ts65 from "typescript";
|
|
14175
14014
|
|
|
14176
14015
|
// packages/compiler-cli/src/ngtsc/typecheck/src/ops/expression.js
|
|
14177
14016
|
import { Binary, BindingPipe, Call as Call3, ImplicitReceiver as ImplicitReceiver4, PropertyRead as PropertyRead4, R3Identifiers as R3Identifiers4, SafeCall as SafeCall2, SafePropertyRead as SafePropertyRead3, ThisReceiver as ThisReceiver4, TmplAstLetDeclaration as TmplAstLetDeclaration2 } from "@angular/compiler";
|
|
14178
|
-
import ts64 from "typescript";
|
|
14179
14017
|
|
|
14180
14018
|
// packages/compiler-cli/src/ngtsc/typecheck/src/expression.js
|
|
14181
14019
|
import { ASTWithSource, Call as Call2, ImplicitReceiver as ImplicitReceiver3, PropertyRead as PropertyRead3, SafeKeyedRead, SafePropertyRead as SafePropertyRead2, ThisReceiver as ThisReceiver3 } from "@angular/compiler";
|
|
14182
|
-
|
|
14183
|
-
|
|
14184
|
-
return ts63.factory.createAsExpression(ts63.factory.createNumericLiteral("0"), ts63.factory.createKeywordTypeNode(ts63.SyntaxKind.AnyKeyword));
|
|
14185
|
-
}
|
|
14186
|
-
function astToTypescript(ast, maybeResolve, config) {
|
|
14187
|
-
const translator = new AstTranslator(maybeResolve, config);
|
|
14020
|
+
function astToTcbExpr(ast, maybeResolve, config) {
|
|
14021
|
+
const translator = new TcbExprTranslator(maybeResolve, config);
|
|
14188
14022
|
return translator.translate(ast);
|
|
14189
14023
|
}
|
|
14190
|
-
var
|
|
14024
|
+
var TcbExprTranslator = class {
|
|
14191
14025
|
maybeResolve;
|
|
14192
14026
|
config;
|
|
14193
|
-
UNDEFINED = ts63.factory.createIdentifier("undefined");
|
|
14194
|
-
UNARY_OPS = /* @__PURE__ */ new Map([
|
|
14195
|
-
["+", ts63.SyntaxKind.PlusToken],
|
|
14196
|
-
["-", ts63.SyntaxKind.MinusToken]
|
|
14197
|
-
]);
|
|
14198
|
-
BINARY_OPS = /* @__PURE__ */ new Map([
|
|
14199
|
-
["+", ts63.SyntaxKind.PlusToken],
|
|
14200
|
-
["-", ts63.SyntaxKind.MinusToken],
|
|
14201
|
-
["<", ts63.SyntaxKind.LessThanToken],
|
|
14202
|
-
[">", ts63.SyntaxKind.GreaterThanToken],
|
|
14203
|
-
["<=", ts63.SyntaxKind.LessThanEqualsToken],
|
|
14204
|
-
[">=", ts63.SyntaxKind.GreaterThanEqualsToken],
|
|
14205
|
-
["=", ts63.SyntaxKind.EqualsToken],
|
|
14206
|
-
["==", ts63.SyntaxKind.EqualsEqualsToken],
|
|
14207
|
-
["===", ts63.SyntaxKind.EqualsEqualsEqualsToken],
|
|
14208
|
-
["*", ts63.SyntaxKind.AsteriskToken],
|
|
14209
|
-
["**", ts63.SyntaxKind.AsteriskAsteriskToken],
|
|
14210
|
-
["/", ts63.SyntaxKind.SlashToken],
|
|
14211
|
-
["%", ts63.SyntaxKind.PercentToken],
|
|
14212
|
-
["!=", ts63.SyntaxKind.ExclamationEqualsToken],
|
|
14213
|
-
["!==", ts63.SyntaxKind.ExclamationEqualsEqualsToken],
|
|
14214
|
-
["||", ts63.SyntaxKind.BarBarToken],
|
|
14215
|
-
["&&", ts63.SyntaxKind.AmpersandAmpersandToken],
|
|
14216
|
-
["&", ts63.SyntaxKind.AmpersandToken],
|
|
14217
|
-
["|", ts63.SyntaxKind.BarToken],
|
|
14218
|
-
["??", ts63.SyntaxKind.QuestionQuestionToken],
|
|
14219
|
-
["=", ts63.SyntaxKind.EqualsToken],
|
|
14220
|
-
["+=", ts63.SyntaxKind.PlusEqualsToken],
|
|
14221
|
-
["-=", ts63.SyntaxKind.MinusEqualsToken],
|
|
14222
|
-
["*=", ts63.SyntaxKind.AsteriskEqualsToken],
|
|
14223
|
-
["/=", ts63.SyntaxKind.SlashEqualsToken],
|
|
14224
|
-
["%=", ts63.SyntaxKind.PercentEqualsToken],
|
|
14225
|
-
["**=", ts63.SyntaxKind.AsteriskAsteriskEqualsToken],
|
|
14226
|
-
["&&=", ts63.SyntaxKind.AmpersandAmpersandEqualsToken],
|
|
14227
|
-
["||=", ts63.SyntaxKind.BarBarEqualsToken],
|
|
14228
|
-
["??=", ts63.SyntaxKind.QuestionQuestionEqualsToken],
|
|
14229
|
-
["in", ts63.SyntaxKind.InKeyword],
|
|
14230
|
-
["instanceof", ts63.SyntaxKind.InstanceOfKeyword]
|
|
14231
|
-
]);
|
|
14232
14027
|
constructor(maybeResolve, config) {
|
|
14233
14028
|
this.maybeResolve = maybeResolve;
|
|
14234
14029
|
this.config = config;
|
|
@@ -14245,37 +14040,31 @@ var AstTranslator = class {
|
|
|
14245
14040
|
}
|
|
14246
14041
|
visitUnary(ast) {
|
|
14247
14042
|
const expr = this.translate(ast.expr);
|
|
14248
|
-
const
|
|
14249
|
-
|
|
14250
|
-
throw new Error(`Unsupported Unary.operator: ${ast.operator}`);
|
|
14251
|
-
}
|
|
14252
|
-
const node = wrapForDiagnostics(ts63.factory.createPrefixUnaryExpression(op, expr));
|
|
14253
|
-
addParseSpanInfo(node, ast.sourceSpan);
|
|
14254
|
-
return node;
|
|
14043
|
+
const node = new TcbExpr(`${ast.operator}${expr.print()}`);
|
|
14044
|
+
return node.wrapForTypeChecker().addParseSpanInfo(ast.sourceSpan);
|
|
14255
14045
|
}
|
|
14256
14046
|
visitBinary(ast) {
|
|
14257
|
-
const lhs =
|
|
14258
|
-
const rhs =
|
|
14259
|
-
|
|
14260
|
-
|
|
14261
|
-
|
|
14262
|
-
}
|
|
14263
|
-
|
|
14264
|
-
addParseSpanInfo(node, ast.sourceSpan);
|
|
14047
|
+
const lhs = this.translate(ast.left);
|
|
14048
|
+
const rhs = this.translate(ast.right);
|
|
14049
|
+
lhs.wrapForTypeChecker();
|
|
14050
|
+
rhs.wrapForTypeChecker();
|
|
14051
|
+
const expression = `${lhs.print()} ${ast.operation} ${rhs.print()}`;
|
|
14052
|
+
const node = new TcbExpr(ast.operation === "??" || ast.operation === "**" ? `(${expression})` : expression);
|
|
14053
|
+
node.addParseSpanInfo(ast.sourceSpan);
|
|
14265
14054
|
return node;
|
|
14266
14055
|
}
|
|
14267
14056
|
visitChain(ast) {
|
|
14268
|
-
const elements = ast.expressions.map((expr) => this.translate(expr));
|
|
14269
|
-
const node =
|
|
14270
|
-
|
|
14057
|
+
const elements = ast.expressions.map((expr) => this.translate(expr).print());
|
|
14058
|
+
const node = new TcbExpr(elements.join(", "));
|
|
14059
|
+
node.wrapForTypeChecker();
|
|
14060
|
+
node.addParseSpanInfo(ast.sourceSpan);
|
|
14271
14061
|
return node;
|
|
14272
14062
|
}
|
|
14273
14063
|
visitConditional(ast) {
|
|
14274
14064
|
const condExpr = this.translate(ast.condition);
|
|
14275
14065
|
const trueExpr = this.translate(ast.trueExp);
|
|
14276
|
-
const falseExpr =
|
|
14277
|
-
const node =
|
|
14278
|
-
addParseSpanInfo(node, ast.sourceSpan);
|
|
14066
|
+
const falseExpr = this.translate(ast.falseExp).wrapForTypeChecker();
|
|
14067
|
+
const node = new TcbExpr(`(${condExpr.print()} ? ${trueExpr.print()} : ${falseExpr.print()})`).addParseSpanInfo(ast.sourceSpan);
|
|
14279
14068
|
return node;
|
|
14280
14069
|
}
|
|
14281
14070
|
visitImplicitReceiver(ast) {
|
|
@@ -14285,141 +14074,136 @@ var AstTranslator = class {
|
|
|
14285
14074
|
throw new Error("Method not implemented.");
|
|
14286
14075
|
}
|
|
14287
14076
|
visitRegularExpressionLiteral(ast, context) {
|
|
14288
|
-
|
|
14077
|
+
const node = new TcbExpr(`/${ast.body}/${ast.flags ?? ""}`);
|
|
14078
|
+
node.wrapForTypeChecker();
|
|
14079
|
+
return node;
|
|
14289
14080
|
}
|
|
14290
14081
|
visitInterpolation(ast) {
|
|
14291
|
-
|
|
14082
|
+
const exprs = ast.expressions.map((e) => {
|
|
14083
|
+
const node = this.translate(e);
|
|
14084
|
+
node.wrapForTypeChecker();
|
|
14085
|
+
return node.print();
|
|
14086
|
+
});
|
|
14087
|
+
return new TcbExpr(`"" + ${exprs.join(" + ")}`);
|
|
14292
14088
|
}
|
|
14293
14089
|
visitKeyedRead(ast) {
|
|
14294
|
-
const receiver =
|
|
14090
|
+
const receiver = this.translate(ast.receiver).wrapForTypeChecker();
|
|
14295
14091
|
const key = this.translate(ast.key);
|
|
14296
|
-
|
|
14297
|
-
addParseSpanInfo(node, ast.sourceSpan);
|
|
14298
|
-
return node;
|
|
14092
|
+
return new TcbExpr(`${receiver.print()}[${key.print()}]`).addParseSpanInfo(ast.sourceSpan);
|
|
14299
14093
|
}
|
|
14300
14094
|
visitLiteralArray(ast) {
|
|
14301
14095
|
const elements = ast.expressions.map((expr) => this.translate(expr));
|
|
14302
|
-
|
|
14303
|
-
|
|
14304
|
-
|
|
14305
|
-
|
|
14096
|
+
let literal4 = `[${elements.map((el) => el.print()).join(", ")}]`;
|
|
14097
|
+
if (!this.config.strictLiteralTypes) {
|
|
14098
|
+
literal4 = `(${literal4} as any)`;
|
|
14099
|
+
}
|
|
14100
|
+
return new TcbExpr(literal4).addParseSpanInfo(ast.sourceSpan);
|
|
14306
14101
|
}
|
|
14307
14102
|
visitLiteralMap(ast) {
|
|
14308
14103
|
const properties = ast.keys.map((key, idx) => {
|
|
14309
14104
|
const value = this.translate(ast.values[idx]);
|
|
14310
14105
|
if (key.kind === "property") {
|
|
14311
|
-
const keyNode =
|
|
14312
|
-
addParseSpanInfo(
|
|
14313
|
-
return
|
|
14106
|
+
const keyNode = new TcbExpr(quoteAndEscape(key.key));
|
|
14107
|
+
keyNode.addParseSpanInfo(key.sourceSpan);
|
|
14108
|
+
return `${keyNode.print()}: ${value.print()}`;
|
|
14314
14109
|
} else {
|
|
14315
|
-
return
|
|
14110
|
+
return `...${value.print()}`;
|
|
14316
14111
|
}
|
|
14317
14112
|
});
|
|
14318
|
-
|
|
14319
|
-
|
|
14320
|
-
|
|
14321
|
-
|
|
14113
|
+
let literal4 = `{ ${properties.join(", ")} }`;
|
|
14114
|
+
if (!this.config.strictLiteralTypes) {
|
|
14115
|
+
literal4 = `${literal4} as any`;
|
|
14116
|
+
}
|
|
14117
|
+
const expression = new TcbExpr(literal4).addParseSpanInfo(ast.sourceSpan);
|
|
14118
|
+
expression.wrapForTypeChecker();
|
|
14119
|
+
return expression;
|
|
14322
14120
|
}
|
|
14323
14121
|
visitLiteralPrimitive(ast) {
|
|
14324
14122
|
let node;
|
|
14325
14123
|
if (ast.value === void 0) {
|
|
14326
|
-
node =
|
|
14124
|
+
node = new TcbExpr("undefined");
|
|
14327
14125
|
} else if (ast.value === null) {
|
|
14328
|
-
node =
|
|
14126
|
+
node = new TcbExpr("null");
|
|
14329
14127
|
} else if (typeof ast.value === "string") {
|
|
14330
|
-
node =
|
|
14128
|
+
node = new TcbExpr(quoteAndEscape(ast.value));
|
|
14331
14129
|
} else if (typeof ast.value === "number") {
|
|
14332
|
-
|
|
14130
|
+
if (Number.isNaN(ast.value)) {
|
|
14131
|
+
node = new TcbExpr("NaN");
|
|
14132
|
+
} else if (!Number.isFinite(ast.value)) {
|
|
14133
|
+
node = new TcbExpr(ast.value > 0 ? "Infinity" : "-Infinity");
|
|
14134
|
+
} else {
|
|
14135
|
+
node = new TcbExpr(ast.value.toString());
|
|
14136
|
+
}
|
|
14333
14137
|
} else if (typeof ast.value === "boolean") {
|
|
14334
|
-
node = ast.value
|
|
14138
|
+
node = new TcbExpr(ast.value + "");
|
|
14335
14139
|
} else {
|
|
14336
14140
|
throw Error(`Unsupported AST value of type ${typeof ast.value}`);
|
|
14337
14141
|
}
|
|
14338
|
-
addParseSpanInfo(
|
|
14142
|
+
node.addParseSpanInfo(ast.sourceSpan);
|
|
14339
14143
|
return node;
|
|
14340
14144
|
}
|
|
14341
14145
|
visitNonNullAssert(ast) {
|
|
14342
|
-
const expr =
|
|
14343
|
-
|
|
14344
|
-
addParseSpanInfo(node, ast.sourceSpan);
|
|
14345
|
-
return node;
|
|
14146
|
+
const expr = this.translate(ast.expression).wrapForTypeChecker();
|
|
14147
|
+
return new TcbExpr(`${expr.print()}!`).addParseSpanInfo(ast.sourceSpan);
|
|
14346
14148
|
}
|
|
14347
14149
|
visitPipe(ast) {
|
|
14348
14150
|
throw new Error("Method not implemented.");
|
|
14349
14151
|
}
|
|
14350
14152
|
visitPrefixNot(ast) {
|
|
14351
|
-
const expression =
|
|
14352
|
-
|
|
14353
|
-
addParseSpanInfo(node, ast.sourceSpan);
|
|
14354
|
-
return node;
|
|
14153
|
+
const expression = this.translate(ast.expression).wrapForTypeChecker();
|
|
14154
|
+
return new TcbExpr(`!${expression.print()}`).addParseSpanInfo(ast.sourceSpan);
|
|
14355
14155
|
}
|
|
14356
14156
|
visitTypeofExpression(ast) {
|
|
14357
|
-
const expression =
|
|
14358
|
-
|
|
14359
|
-
addParseSpanInfo(node, ast.sourceSpan);
|
|
14360
|
-
return node;
|
|
14157
|
+
const expression = this.translate(ast.expression).wrapForTypeChecker();
|
|
14158
|
+
return new TcbExpr(`typeof ${expression.print()}`).addParseSpanInfo(ast.sourceSpan);
|
|
14361
14159
|
}
|
|
14362
14160
|
visitVoidExpression(ast) {
|
|
14363
|
-
const expression =
|
|
14364
|
-
|
|
14365
|
-
addParseSpanInfo(node, ast.sourceSpan);
|
|
14366
|
-
return node;
|
|
14161
|
+
const expression = this.translate(ast.expression).wrapForTypeChecker();
|
|
14162
|
+
return new TcbExpr(`void ${expression.print()}`).addParseSpanInfo(ast.sourceSpan);
|
|
14367
14163
|
}
|
|
14368
14164
|
visitPropertyRead(ast) {
|
|
14369
|
-
const receiver =
|
|
14370
|
-
|
|
14371
|
-
addParseSpanInfo(name, ast.nameSpan);
|
|
14372
|
-
const node = wrapForDiagnostics(name);
|
|
14373
|
-
addParseSpanInfo(node, ast.sourceSpan);
|
|
14374
|
-
return node;
|
|
14165
|
+
const receiver = this.translate(ast.receiver).wrapForTypeChecker();
|
|
14166
|
+
return new TcbExpr(`${receiver.print()}.${ast.name}`).addParseSpanInfo(ast.nameSpan).wrapForTypeChecker().addParseSpanInfo(ast.sourceSpan);
|
|
14375
14167
|
}
|
|
14376
14168
|
visitSafePropertyRead(ast) {
|
|
14377
14169
|
let node;
|
|
14378
|
-
const receiver =
|
|
14170
|
+
const receiver = this.translate(ast.receiver).wrapForTypeChecker();
|
|
14171
|
+
const name = new TcbExpr(ast.name).addParseSpanInfo(ast.nameSpan);
|
|
14379
14172
|
if (this.config.strictSafeNavigationTypes) {
|
|
14380
|
-
|
|
14381
|
-
addParseSpanInfo(expr, ast.nameSpan);
|
|
14382
|
-
node = ts63.factory.createParenthesizedExpression(ts63.factory.createConditionalExpression(getAnyExpression(), void 0, expr, void 0, this.UNDEFINED));
|
|
14173
|
+
node = new TcbExpr(`(0 as any ? ${receiver.print()}!.${name.print()} : undefined)`);
|
|
14383
14174
|
} else if (VeSafeLhsInferenceBugDetector.veWillInferAnyFor(ast)) {
|
|
14384
|
-
node =
|
|
14175
|
+
node = new TcbExpr(`(${receiver.print()} as any).${name.print()}`);
|
|
14385
14176
|
} else {
|
|
14386
|
-
|
|
14387
|
-
addParseSpanInfo(expr, ast.nameSpan);
|
|
14388
|
-
node = tsCastToAny(expr);
|
|
14177
|
+
node = new TcbExpr(`(${receiver.print()}!.${name.print()} as any)`);
|
|
14389
14178
|
}
|
|
14390
|
-
addParseSpanInfo(
|
|
14391
|
-
return node;
|
|
14179
|
+
return node.addParseSpanInfo(ast.sourceSpan);
|
|
14392
14180
|
}
|
|
14393
14181
|
visitSafeKeyedRead(ast) {
|
|
14394
|
-
const receiver =
|
|
14182
|
+
const receiver = this.translate(ast.receiver).wrapForTypeChecker();
|
|
14395
14183
|
const key = this.translate(ast.key);
|
|
14396
14184
|
let node;
|
|
14397
14185
|
if (this.config.strictSafeNavigationTypes) {
|
|
14398
|
-
const
|
|
14399
|
-
|
|
14400
|
-
node = ts63.factory.createParenthesizedExpression(ts63.factory.createConditionalExpression(getAnyExpression(), void 0, expr, void 0, this.UNDEFINED));
|
|
14186
|
+
const elementAccess = new TcbExpr(`${receiver.print()}![${key.print()}]`).addParseSpanInfo(ast.sourceSpan);
|
|
14187
|
+
node = new TcbExpr(`(0 as any ? ${elementAccess.print()} : undefined)`);
|
|
14401
14188
|
} else if (VeSafeLhsInferenceBugDetector.veWillInferAnyFor(ast)) {
|
|
14402
|
-
node =
|
|
14189
|
+
node = new TcbExpr(`(${receiver.print()} as any)[${key.print()}]`);
|
|
14403
14190
|
} else {
|
|
14404
|
-
const
|
|
14405
|
-
|
|
14406
|
-
node = tsCastToAny(expr);
|
|
14191
|
+
const elementAccess = new TcbExpr(`${receiver.print()}![${key.print()}]`).addParseSpanInfo(ast.sourceSpan);
|
|
14192
|
+
node = new TcbExpr(`(${elementAccess.print()} as any)`);
|
|
14407
14193
|
}
|
|
14408
|
-
addParseSpanInfo(
|
|
14409
|
-
return node;
|
|
14194
|
+
return node.addParseSpanInfo(ast.sourceSpan);
|
|
14410
14195
|
}
|
|
14411
14196
|
visitCall(ast) {
|
|
14412
14197
|
const args = ast.args.map((expr2) => this.translate(expr2));
|
|
14413
|
-
let expr;
|
|
14414
14198
|
const receiver = ast.receiver;
|
|
14199
|
+
let expr;
|
|
14415
14200
|
if (receiver instanceof PropertyRead3) {
|
|
14416
14201
|
const resolved = this.maybeResolve(receiver);
|
|
14417
14202
|
if (resolved !== null) {
|
|
14418
14203
|
expr = resolved;
|
|
14419
14204
|
} else {
|
|
14420
|
-
const propertyReceiver =
|
|
14421
|
-
expr =
|
|
14422
|
-
addParseSpanInfo(expr, receiver.nameSpan);
|
|
14205
|
+
const propertyReceiver = this.translate(receiver.receiver).wrapForTypeChecker();
|
|
14206
|
+
expr = new TcbExpr(`${propertyReceiver.print()}.${receiver.name}`).addParseSpanInfo(receiver.nameSpan);
|
|
14423
14207
|
}
|
|
14424
14208
|
} else {
|
|
14425
14209
|
expr = this.translate(receiver);
|
|
@@ -14428,87 +14212,84 @@ var AstTranslator = class {
|
|
|
14428
14212
|
if (ast.receiver instanceof SafePropertyRead2 || ast.receiver instanceof SafeKeyedRead) {
|
|
14429
14213
|
node = this.convertToSafeCall(ast, expr, args);
|
|
14430
14214
|
} else {
|
|
14431
|
-
node =
|
|
14215
|
+
node = new TcbExpr(`${expr.print()}(${args.map((arg) => arg.print()).join(", ")})`);
|
|
14432
14216
|
}
|
|
14433
|
-
addParseSpanInfo(
|
|
14434
|
-
return node;
|
|
14217
|
+
return node.addParseSpanInfo(ast.sourceSpan);
|
|
14435
14218
|
}
|
|
14436
14219
|
visitSafeCall(ast) {
|
|
14437
14220
|
const args = ast.args.map((expr2) => this.translate(expr2));
|
|
14438
|
-
const expr =
|
|
14439
|
-
|
|
14440
|
-
addParseSpanInfo(node, ast.sourceSpan);
|
|
14441
|
-
return node;
|
|
14221
|
+
const expr = this.translate(ast.receiver).wrapForTypeChecker();
|
|
14222
|
+
return this.convertToSafeCall(ast, expr, args).addParseSpanInfo(ast.sourceSpan);
|
|
14442
14223
|
}
|
|
14443
14224
|
visitTemplateLiteral(ast) {
|
|
14444
14225
|
const length = ast.elements.length;
|
|
14445
14226
|
const head = ast.elements[0];
|
|
14446
14227
|
let result;
|
|
14447
14228
|
if (length === 1) {
|
|
14448
|
-
result =
|
|
14229
|
+
result = `\`${head.text}\``;
|
|
14449
14230
|
} else {
|
|
14450
|
-
|
|
14231
|
+
let parts = [`\`${head.text}`];
|
|
14451
14232
|
const tailIndex = length - 1;
|
|
14452
14233
|
for (let i = 1; i < tailIndex; i++) {
|
|
14453
|
-
const
|
|
14454
|
-
|
|
14234
|
+
const expr = this.translate(ast.expressions[i - 1]);
|
|
14235
|
+
parts.push(`\${${expr.print()}}${ast.elements[i].text}`);
|
|
14455
14236
|
}
|
|
14456
14237
|
const resolvedExpression = this.translate(ast.expressions[tailIndex - 1]);
|
|
14457
|
-
|
|
14458
|
-
|
|
14459
|
-
result = ts63.factory.createTemplateExpression(ts63.factory.createTemplateHead(head.text), spans);
|
|
14238
|
+
parts.push(`\${${resolvedExpression.print()}}${ast.elements[tailIndex].text}\``);
|
|
14239
|
+
result = parts.join("");
|
|
14460
14240
|
}
|
|
14461
|
-
return result;
|
|
14241
|
+
return new TcbExpr(result);
|
|
14462
14242
|
}
|
|
14463
|
-
visitTemplateLiteralElement(
|
|
14243
|
+
visitTemplateLiteralElement() {
|
|
14464
14244
|
throw new Error("Method not implemented");
|
|
14465
14245
|
}
|
|
14466
14246
|
visitTaggedTemplateLiteral(ast) {
|
|
14467
|
-
|
|
14247
|
+
const tag = this.translate(ast.tag);
|
|
14248
|
+
const template = this.visitTemplateLiteral(ast.template);
|
|
14249
|
+
return new TcbExpr(`${tag.print()}${template.print()}`);
|
|
14468
14250
|
}
|
|
14469
14251
|
visitParenthesizedExpression(ast) {
|
|
14470
|
-
|
|
14252
|
+
const expr = this.translate(ast.expression);
|
|
14253
|
+
return new TcbExpr(`(${expr.print()})`);
|
|
14471
14254
|
}
|
|
14472
14255
|
visitSpreadElement(ast) {
|
|
14473
|
-
const expression =
|
|
14474
|
-
|
|
14475
|
-
|
|
14256
|
+
const expression = this.translate(ast.expression);
|
|
14257
|
+
expression.wrapForTypeChecker();
|
|
14258
|
+
const node = new TcbExpr(`...${expression.print()}`);
|
|
14259
|
+
node.addParseSpanInfo(ast.sourceSpan);
|
|
14476
14260
|
return node;
|
|
14477
14261
|
}
|
|
14478
|
-
visitEmptyExpr(ast
|
|
14479
|
-
const node =
|
|
14480
|
-
addParseSpanInfo(
|
|
14262
|
+
visitEmptyExpr(ast) {
|
|
14263
|
+
const node = new TcbExpr("undefined");
|
|
14264
|
+
node.addParseSpanInfo(ast.sourceSpan);
|
|
14481
14265
|
return node;
|
|
14482
14266
|
}
|
|
14483
14267
|
visitArrowFunction(ast) {
|
|
14484
|
-
const params = ast.parameters.map((param) =>
|
|
14485
|
-
|
|
14486
|
-
markIgnoreDiagnostics(paramNode);
|
|
14487
|
-
return paramNode;
|
|
14488
|
-
});
|
|
14489
|
-
const body = astToTypescript(ast.body, (innerAst) => {
|
|
14268
|
+
const params = ast.parameters.map((param) => new TcbExpr(param.name).markIgnoreDiagnostics().print()).join(", ");
|
|
14269
|
+
const body = astToTcbExpr(ast.body, (innerAst) => {
|
|
14490
14270
|
if (!(innerAst instanceof PropertyRead3) || innerAst.receiver instanceof ThisReceiver3 || !(innerAst.receiver instanceof ImplicitReceiver3)) {
|
|
14491
14271
|
return this.maybeResolve(innerAst);
|
|
14492
14272
|
}
|
|
14493
14273
|
const correspondingParam = ast.parameters.find((arg) => arg.name === innerAst.name);
|
|
14494
14274
|
if (correspondingParam) {
|
|
14495
|
-
const node =
|
|
14496
|
-
addParseSpanInfo(
|
|
14275
|
+
const node = new TcbExpr(innerAst.name);
|
|
14276
|
+
node.addParseSpanInfo(innerAst.sourceSpan);
|
|
14497
14277
|
return node;
|
|
14498
14278
|
}
|
|
14499
14279
|
return this.maybeResolve(innerAst);
|
|
14500
14280
|
}, this.config);
|
|
14501
|
-
return
|
|
14281
|
+
return new TcbExpr(`${ast.parameters.length === 1 ? params : `(${params})`} => ${body.print()}`);
|
|
14502
14282
|
}
|
|
14503
|
-
convertToSafeCall(ast,
|
|
14283
|
+
convertToSafeCall(ast, exprNode, argNodes) {
|
|
14284
|
+
const expr = exprNode.print();
|
|
14285
|
+
const args = argNodes.map((node) => node.print()).join(", ");
|
|
14504
14286
|
if (this.config.strictSafeNavigationTypes) {
|
|
14505
|
-
|
|
14506
|
-
return ts63.factory.createParenthesizedExpression(ts63.factory.createConditionalExpression(getAnyExpression(), void 0, call, void 0, this.UNDEFINED));
|
|
14287
|
+
return new TcbExpr(`(0 as any ? ${expr}!(${args}) : undefined)`);
|
|
14507
14288
|
}
|
|
14508
14289
|
if (VeSafeLhsInferenceBugDetector.veWillInferAnyFor(ast)) {
|
|
14509
|
-
return
|
|
14290
|
+
return new TcbExpr(`(${expr} as any)(${args})`);
|
|
14510
14291
|
}
|
|
14511
|
-
return
|
|
14292
|
+
return new TcbExpr(`(${expr}!(${args}) as any)`);
|
|
14512
14293
|
}
|
|
14513
14294
|
};
|
|
14514
14295
|
var VeSafeLhsInferenceBugDetector = class _VeSafeLhsInferenceBugDetector {
|
|
@@ -14610,7 +14391,7 @@ function tcbExpression(ast, tcb, scope) {
|
|
|
14610
14391
|
}
|
|
14611
14392
|
function unwrapWritableSignal(expression, tcb) {
|
|
14612
14393
|
const unwrapRef = tcb.env.referenceExternalSymbol(R3Identifiers4.unwrapWritableSignal.moduleName, R3Identifiers4.unwrapWritableSignal.name);
|
|
14613
|
-
return
|
|
14394
|
+
return new TcbExpr(`${unwrapRef.print()}(${expression.print()})`);
|
|
14614
14395
|
}
|
|
14615
14396
|
var TcbExpressionOp = class extends TcbOp {
|
|
14616
14397
|
tcb;
|
|
@@ -14627,7 +14408,7 @@ var TcbExpressionOp = class extends TcbOp {
|
|
|
14627
14408
|
}
|
|
14628
14409
|
execute() {
|
|
14629
14410
|
const expr = tcbExpression(this.expression, this.tcb, this.scope);
|
|
14630
|
-
this.scope.addStatement(
|
|
14411
|
+
this.scope.addStatement(expr);
|
|
14631
14412
|
return null;
|
|
14632
14413
|
}
|
|
14633
14414
|
};
|
|
@@ -14646,7 +14427,7 @@ var TcbConditionOp = class extends TcbOp {
|
|
|
14646
14427
|
}
|
|
14647
14428
|
execute() {
|
|
14648
14429
|
const expr = tcbExpression(this.expression, this.tcb, this.scope);
|
|
14649
|
-
this.scope.addStatement(
|
|
14430
|
+
this.scope.addStatement(new TcbExpr(`if (${expr.print()}) {}`));
|
|
14650
14431
|
return null;
|
|
14651
14432
|
}
|
|
14652
14433
|
};
|
|
@@ -14658,7 +14439,7 @@ var TcbExpressionTranslator = class {
|
|
|
14658
14439
|
this.scope = scope;
|
|
14659
14440
|
}
|
|
14660
14441
|
translate(ast) {
|
|
14661
|
-
return
|
|
14442
|
+
return astToTcbExpr(ast, (ast2) => this.resolve(ast2), this.tcb.env.config);
|
|
14662
14443
|
}
|
|
14663
14444
|
/**
|
|
14664
14445
|
* Resolve an `AST` expression within the given scope.
|
|
@@ -14673,7 +14454,7 @@ var TcbExpressionTranslator = class {
|
|
|
14673
14454
|
if (target instanceof TmplAstLetDeclaration2 && !this.isValidLetDeclarationAccess(target, ast)) {
|
|
14674
14455
|
this.tcb.oobRecorder.letUsedBeforeDefinition(this.tcb.id, ast, target);
|
|
14675
14456
|
if (targetExpression !== null) {
|
|
14676
|
-
return
|
|
14457
|
+
return new TcbExpr(`${targetExpression.print()} as any`);
|
|
14677
14458
|
}
|
|
14678
14459
|
}
|
|
14679
14460
|
return targetExpression;
|
|
@@ -14685,62 +14466,51 @@ var TcbExpressionTranslator = class {
|
|
|
14685
14466
|
}
|
|
14686
14467
|
const targetExpression = this.getTargetNodeExpression(target, read);
|
|
14687
14468
|
const expr = this.translate(ast.right);
|
|
14688
|
-
const result =
|
|
14689
|
-
addParseSpanInfo(
|
|
14469
|
+
const result = new TcbExpr(`(${targetExpression.print()} = ${expr.print()})`);
|
|
14470
|
+
result.addParseSpanInfo(read.sourceSpan);
|
|
14690
14471
|
if (target instanceof TmplAstLetDeclaration2) {
|
|
14691
|
-
markIgnoreDiagnostics(
|
|
14472
|
+
result.markIgnoreDiagnostics();
|
|
14692
14473
|
this.tcb.oobRecorder.illegalWriteToLetDeclaration(this.tcb.id, read, target);
|
|
14693
14474
|
}
|
|
14694
14475
|
return result;
|
|
14695
14476
|
} else if (ast instanceof ImplicitReceiver4 || ast instanceof ThisReceiver4) {
|
|
14696
|
-
return
|
|
14477
|
+
return new TcbExpr("this");
|
|
14697
14478
|
} else if (ast instanceof BindingPipe) {
|
|
14698
14479
|
const expr = this.translate(ast.exp);
|
|
14699
14480
|
const pipeMeta = this.tcb.getPipeByName(ast.name);
|
|
14700
14481
|
let pipe;
|
|
14701
14482
|
if (pipeMeta === null) {
|
|
14702
14483
|
this.tcb.oobRecorder.missingPipe(this.tcb.id, ast, this.tcb.hostIsStandalone);
|
|
14703
|
-
pipe =
|
|
14484
|
+
pipe = new TcbExpr("(0 as any)");
|
|
14704
14485
|
} else if (pipeMeta.isExplicitlyDeferred && this.tcb.boundTarget.getEagerlyUsedPipes().includes(ast.name)) {
|
|
14705
14486
|
this.tcb.oobRecorder.deferredPipeUsedEagerly(this.tcb.id, ast);
|
|
14706
|
-
pipe =
|
|
14487
|
+
pipe = new TcbExpr("(0 as any)");
|
|
14707
14488
|
} else {
|
|
14708
14489
|
pipe = this.tcb.env.pipeInst(pipeMeta.ref);
|
|
14709
14490
|
}
|
|
14710
|
-
const args = ast.args.map((arg) => this.translate(arg));
|
|
14711
|
-
let methodAccess =
|
|
14712
|
-
addParseSpanInfo(methodAccess, ast.nameSpan);
|
|
14491
|
+
const args = ast.args.map((arg) => this.translate(arg).print());
|
|
14492
|
+
let methodAccess = new TcbExpr(`${pipe.print()}.transform`).addParseSpanInfo(ast.nameSpan);
|
|
14713
14493
|
if (!this.tcb.env.config.checkTypeOfPipes) {
|
|
14714
|
-
methodAccess =
|
|
14494
|
+
methodAccess = new TcbExpr(`(${methodAccess.print()} as any)`);
|
|
14715
14495
|
}
|
|
14716
|
-
const result =
|
|
14717
|
-
|
|
14718
|
-
methodAccess,
|
|
14719
|
-
/* typeArguments */
|
|
14720
|
-
void 0,
|
|
14721
|
-
/* argumentsArray */
|
|
14722
|
-
[expr, ...args]
|
|
14723
|
-
);
|
|
14724
|
-
addParseSpanInfo(result, ast.sourceSpan);
|
|
14725
|
-
return result;
|
|
14496
|
+
const result = new TcbExpr(`${methodAccess.print()}(${[expr.print(), ...args].join(", ")})`);
|
|
14497
|
+
return result.addParseSpanInfo(ast.sourceSpan);
|
|
14726
14498
|
} else if ((ast instanceof Call3 || ast instanceof SafeCall2) && (ast.receiver instanceof PropertyRead4 || ast.receiver instanceof SafePropertyRead3)) {
|
|
14727
14499
|
if (ast.receiver.receiver instanceof ImplicitReceiver4 && ast.receiver.name === "$any" && ast.args.length === 1) {
|
|
14728
14500
|
const expr = this.translate(ast.args[0]);
|
|
14729
|
-
const
|
|
14730
|
-
|
|
14731
|
-
addParseSpanInfo(result, ast.sourceSpan);
|
|
14501
|
+
const result = new TcbExpr(`(${expr.print()} as any)`);
|
|
14502
|
+
result.addParseSpanInfo(ast.sourceSpan);
|
|
14732
14503
|
return result;
|
|
14733
14504
|
}
|
|
14734
14505
|
const target = this.tcb.boundTarget.getExpressionTarget(ast);
|
|
14735
14506
|
if (target === null) {
|
|
14736
14507
|
return null;
|
|
14737
14508
|
}
|
|
14738
|
-
const
|
|
14739
|
-
|
|
14740
|
-
|
|
14741
|
-
const
|
|
14742
|
-
|
|
14743
|
-
addParseSpanInfo(node, ast.sourceSpan);
|
|
14509
|
+
const method = this.getTargetNodeExpression(target, ast);
|
|
14510
|
+
method.addParseSpanInfo(ast.receiver.nameSpan).wrapForTypeChecker();
|
|
14511
|
+
const args = ast.args.map((arg) => this.translate(arg).print());
|
|
14512
|
+
const node = new TcbExpr(`${method.print()}(${args.join(", ")})`);
|
|
14513
|
+
node.addParseSpanInfo(ast.sourceSpan);
|
|
14744
14514
|
return node;
|
|
14745
14515
|
} else {
|
|
14746
14516
|
return null;
|
|
@@ -14748,7 +14518,7 @@ var TcbExpressionTranslator = class {
|
|
|
14748
14518
|
}
|
|
14749
14519
|
getTargetNodeExpression(targetNode, expressionNode) {
|
|
14750
14520
|
const expr = this.scope.resolve(targetNode);
|
|
14751
|
-
addParseSpanInfo(
|
|
14521
|
+
expr.addParseSpanInfo(expressionNode.sourceSpan);
|
|
14752
14522
|
return expr;
|
|
14753
14523
|
}
|
|
14754
14524
|
isValidLetDeclarationAccess(target, ast) {
|
|
@@ -14771,9 +14541,8 @@ var TcbTemplateContextOp = class extends TcbOp {
|
|
|
14771
14541
|
// The declaration of the context variable is only needed when the context is actually referenced.
|
|
14772
14542
|
optional = true;
|
|
14773
14543
|
execute() {
|
|
14774
|
-
const ctx = this.tcb.allocateId();
|
|
14775
|
-
|
|
14776
|
-
this.scope.addStatement(tsDeclareVariable(ctx, type));
|
|
14544
|
+
const ctx = new TcbExpr(this.tcb.allocateId());
|
|
14545
|
+
this.scope.addStatement(declareVariable(ctx, new TcbExpr("any")));
|
|
14777
14546
|
return ctx;
|
|
14778
14547
|
}
|
|
14779
14548
|
};
|
|
@@ -14798,23 +14567,19 @@ var TcbTemplateBodyOp = class extends TcbOp {
|
|
|
14798
14567
|
this.addDirectiveGuards(directiveGuards, directive, this.tcb.boundTarget.getDirectivesOfNode(directive));
|
|
14799
14568
|
}
|
|
14800
14569
|
if (directiveGuards.length > 0) {
|
|
14801
|
-
guard = directiveGuards.reduce((expr, dirGuard) =>
|
|
14570
|
+
guard = directiveGuards.reduce((expr, dirGuard) => new TcbExpr(`${expr.print()} && ${dirGuard.print()}`), directiveGuards.pop());
|
|
14802
14571
|
}
|
|
14803
14572
|
const tmplScope = this.scope.createChildScope(this.scope, this.template, this.template.children, guard);
|
|
14804
14573
|
const statements = tmplScope.render();
|
|
14805
14574
|
if (statements.length === 0) {
|
|
14806
14575
|
return null;
|
|
14807
14576
|
}
|
|
14808
|
-
let tmplBlock =
|
|
14577
|
+
let tmplBlock = `{
|
|
14578
|
+
${getStatementsBlock(statements)}}`;
|
|
14809
14579
|
if (guard !== null) {
|
|
14810
|
-
tmplBlock =
|
|
14811
|
-
/* expression */
|
|
14812
|
-
guard,
|
|
14813
|
-
/* thenStatement */
|
|
14814
|
-
tmplBlock
|
|
14815
|
-
);
|
|
14580
|
+
tmplBlock = `if (${guard.print()}) ${tmplBlock}`;
|
|
14816
14581
|
}
|
|
14817
|
-
this.scope.addStatement(tmplBlock);
|
|
14582
|
+
this.scope.addStatement(new TcbExpr(tmplBlock));
|
|
14818
14583
|
return null;
|
|
14819
14584
|
}
|
|
14820
14585
|
addDirectiveGuards(guards, hostNode, directives) {
|
|
@@ -14831,15 +14596,12 @@ var TcbTemplateBodyOp = class extends TcbOp {
|
|
|
14831
14596
|
}) : void 0);
|
|
14832
14597
|
if (boundInput !== void 0) {
|
|
14833
14598
|
const expr = tcbExpression(boundInput.value, this.tcb, this.scope);
|
|
14834
|
-
markIgnoreDiagnostics(
|
|
14599
|
+
expr.markIgnoreDiagnostics();
|
|
14835
14600
|
if (guard.type === "binding") {
|
|
14836
14601
|
guards.push(expr);
|
|
14837
14602
|
} else {
|
|
14838
|
-
const guardInvoke =
|
|
14839
|
-
|
|
14840
|
-
expr
|
|
14841
|
-
]);
|
|
14842
|
-
addParseSpanInfo(guardInvoke, boundInput.value.sourceSpan);
|
|
14603
|
+
const guardInvoke = new TcbExpr(`${dirId.print()}.ngTemplateGuard_${guard.inputName}(${dirInstId.print()}, ${expr.print()})`);
|
|
14604
|
+
guardInvoke.addParseSpanInfo(boundInput.value.sourceSpan);
|
|
14843
14605
|
guards.push(guardInvoke);
|
|
14844
14606
|
}
|
|
14845
14607
|
}
|
|
@@ -14847,9 +14609,9 @@ var TcbTemplateBodyOp = class extends TcbOp {
|
|
|
14847
14609
|
if (dir.hasNgTemplateContextGuard) {
|
|
14848
14610
|
if (this.tcb.env.config.applyTemplateContextGuards) {
|
|
14849
14611
|
const ctx = this.scope.resolve(hostNode);
|
|
14850
|
-
const guardInvoke =
|
|
14851
|
-
markIgnoreDiagnostics(
|
|
14852
|
-
addParseSpanInfo(
|
|
14612
|
+
const guardInvoke = new TcbExpr(`${dirId.print()}.ngTemplateContextGuard(${dirInstId.print()}, ${ctx.print()})`);
|
|
14613
|
+
guardInvoke.markIgnoreDiagnostics();
|
|
14614
|
+
guardInvoke.addParseSpanInfo(hostNode.sourceSpan);
|
|
14853
14615
|
guards.push(guardInvoke);
|
|
14854
14616
|
} else if (isTemplate && hostNode.variables.length > 0 && this.tcb.env.config.suggestionsForSuboptimalTypeInference) {
|
|
14855
14617
|
this.tcb.oobRecorder.suboptimalTypeInference(this.tcb.id, hostNode.variables);
|
|
@@ -14875,15 +14637,18 @@ var TcbElementOp = class extends TcbOp {
|
|
|
14875
14637
|
}
|
|
14876
14638
|
execute() {
|
|
14877
14639
|
const id = this.tcb.allocateId();
|
|
14878
|
-
const
|
|
14879
|
-
addParseSpanInfo(
|
|
14880
|
-
this.
|
|
14881
|
-
|
|
14640
|
+
const idNode = new TcbExpr(id);
|
|
14641
|
+
idNode.addParseSpanInfo(this.element.startSourceSpan || this.element.sourceSpan);
|
|
14642
|
+
const initializer = new TcbExpr(`document.createElement("${this.element.name}")`);
|
|
14643
|
+
initializer.addParseSpanInfo(this.element.startSourceSpan || this.element.sourceSpan);
|
|
14644
|
+
const stmt = new TcbExpr(`var ${idNode.print()} = ${initializer.print()}`);
|
|
14645
|
+
stmt.addParseSpanInfo(this.element.startSourceSpan || this.element.sourceSpan);
|
|
14646
|
+
this.scope.addStatement(stmt);
|
|
14647
|
+
return idNode;
|
|
14882
14648
|
}
|
|
14883
14649
|
};
|
|
14884
14650
|
|
|
14885
14651
|
// packages/compiler-cli/src/ngtsc/typecheck/src/ops/variables.js
|
|
14886
|
-
import ts66 from "typescript";
|
|
14887
14652
|
var TcbBlockImplicitVariableOp = class extends TcbOp {
|
|
14888
14653
|
tcb;
|
|
14889
14654
|
scope;
|
|
@@ -14898,10 +14663,10 @@ var TcbBlockImplicitVariableOp = class extends TcbOp {
|
|
|
14898
14663
|
}
|
|
14899
14664
|
optional = true;
|
|
14900
14665
|
execute() {
|
|
14901
|
-
const id = this.tcb.allocateId();
|
|
14902
|
-
addParseSpanInfo(
|
|
14903
|
-
const variable =
|
|
14904
|
-
addParseSpanInfo(
|
|
14666
|
+
const id = new TcbExpr(this.tcb.allocateId());
|
|
14667
|
+
id.addParseSpanInfo(this.variable.keySpan);
|
|
14668
|
+
const variable = declareVariable(id, this.type);
|
|
14669
|
+
variable.addParseSpanInfo(this.variable.sourceSpan);
|
|
14905
14670
|
this.scope.addStatement(variable);
|
|
14906
14671
|
return id;
|
|
14907
14672
|
}
|
|
@@ -14923,22 +14688,15 @@ var TcbTemplateVariableOp = class extends TcbOp {
|
|
|
14923
14688
|
}
|
|
14924
14689
|
execute() {
|
|
14925
14690
|
const ctx = this.scope.resolve(this.template);
|
|
14926
|
-
const id = this.tcb.allocateId();
|
|
14927
|
-
const initializer =
|
|
14928
|
-
|
|
14929
|
-
ctx,
|
|
14930
|
-
/* name */
|
|
14931
|
-
this.variable.value || "$implicit"
|
|
14932
|
-
);
|
|
14933
|
-
addParseSpanInfo(id, this.variable.keySpan);
|
|
14934
|
-
let variable;
|
|
14691
|
+
const id = new TcbExpr(this.tcb.allocateId());
|
|
14692
|
+
const initializer = new TcbExpr(`${ctx.print()}.${this.variable.value || "$implicit"}`);
|
|
14693
|
+
id.addParseSpanInfo(this.variable.keySpan);
|
|
14935
14694
|
if (this.variable.valueSpan !== void 0) {
|
|
14936
|
-
addParseSpanInfo(
|
|
14937
|
-
variable = tsCreateVariable(id, wrapForTypeChecker(initializer));
|
|
14695
|
+
initializer.addParseSpanInfo(this.variable.valueSpan).wrapForTypeChecker();
|
|
14938
14696
|
} else {
|
|
14939
|
-
variable = tsCreateVariable(id, initializer);
|
|
14940
14697
|
}
|
|
14941
|
-
|
|
14698
|
+
const variable = new TcbExpr(`var ${id.print()} = ${initializer.print()}`);
|
|
14699
|
+
variable.addParseSpanInfo(this.variable.sourceSpan);
|
|
14942
14700
|
this.scope.addStatement(variable);
|
|
14943
14701
|
return id;
|
|
14944
14702
|
}
|
|
@@ -14959,17 +14717,17 @@ var TcbBlockVariableOp = class extends TcbOp {
|
|
|
14959
14717
|
return false;
|
|
14960
14718
|
}
|
|
14961
14719
|
execute() {
|
|
14962
|
-
const id = this.tcb.allocateId();
|
|
14963
|
-
addParseSpanInfo(
|
|
14964
|
-
|
|
14965
|
-
|
|
14720
|
+
const id = new TcbExpr(this.tcb.allocateId());
|
|
14721
|
+
id.addParseSpanInfo(this.variable.keySpan);
|
|
14722
|
+
this.initializer.wrapForTypeChecker();
|
|
14723
|
+
const variable = new TcbExpr(`var ${id.print()} = ${this.initializer.print()}`);
|
|
14724
|
+
variable.addParseSpanInfo(this.variable.sourceSpan);
|
|
14966
14725
|
this.scope.addStatement(variable);
|
|
14967
14726
|
return id;
|
|
14968
14727
|
}
|
|
14969
14728
|
};
|
|
14970
14729
|
|
|
14971
14730
|
// packages/compiler-cli/src/ngtsc/typecheck/src/ops/completions.js
|
|
14972
|
-
import ts67 from "typescript";
|
|
14973
14731
|
var TcbComponentContextCompletionOp = class extends TcbOp {
|
|
14974
14732
|
scope;
|
|
14975
14733
|
constructor(scope) {
|
|
@@ -14978,18 +14736,16 @@ var TcbComponentContextCompletionOp = class extends TcbOp {
|
|
|
14978
14736
|
}
|
|
14979
14737
|
optional = false;
|
|
14980
14738
|
execute() {
|
|
14981
|
-
const ctx =
|
|
14982
|
-
|
|
14983
|
-
|
|
14984
|
-
|
|
14985
|
-
this.scope.addStatement(ts67.factory.createExpressionStatement(ctxDot));
|
|
14739
|
+
const ctx = new TcbExpr("this.");
|
|
14740
|
+
ctx.markIgnoreDiagnostics();
|
|
14741
|
+
ctx.addExpressionIdentifier(ExpressionIdentifier.COMPONENT_COMPLETION);
|
|
14742
|
+
this.scope.addStatement(ctx);
|
|
14986
14743
|
return null;
|
|
14987
14744
|
}
|
|
14988
14745
|
};
|
|
14989
14746
|
|
|
14990
14747
|
// packages/compiler-cli/src/ngtsc/typecheck/src/ops/references.js
|
|
14991
|
-
import {
|
|
14992
|
-
import ts68 from "typescript";
|
|
14748
|
+
import { TmplAstElement as TmplAstElement2, TmplAstTemplate as TmplAstTemplate2 } from "@angular/compiler";
|
|
14993
14749
|
var TcbReferenceOp = class extends TcbOp {
|
|
14994
14750
|
tcb;
|
|
14995
14751
|
scope;
|
|
@@ -15008,18 +14764,17 @@ var TcbReferenceOp = class extends TcbOp {
|
|
|
15008
14764
|
// so it can map a reference variable in the template directly to a node in the TCB.
|
|
15009
14765
|
optional = true;
|
|
15010
14766
|
execute() {
|
|
15011
|
-
const id = this.tcb.allocateId();
|
|
14767
|
+
const id = new TcbExpr(this.tcb.allocateId());
|
|
15012
14768
|
let initializer = this.target instanceof TmplAstTemplate2 || this.target instanceof TmplAstElement2 ? this.scope.resolve(this.target) : this.scope.resolve(this.host, this.target);
|
|
15013
14769
|
if (this.target instanceof TmplAstElement2 && !this.tcb.env.config.checkTypeOfDomReferences || !this.tcb.env.config.checkTypeOfNonDomReferences) {
|
|
15014
|
-
initializer =
|
|
14770
|
+
initializer = new TcbExpr(`${initializer.print()} as any`);
|
|
15015
14771
|
} else if (this.target instanceof TmplAstTemplate2) {
|
|
15016
|
-
|
|
15017
|
-
initializer =
|
|
15018
|
-
initializer = ts68.factory.createParenthesizedExpression(initializer);
|
|
14772
|
+
const templateRef = this.tcb.env.referenceExternalSymbol("@angular/core", "TemplateRef");
|
|
14773
|
+
initializer = new TcbExpr(`(${initializer.print()} as any as ${templateRef.print()}<any>)`);
|
|
15019
14774
|
}
|
|
15020
|
-
addParseSpanInfo(
|
|
15021
|
-
addParseSpanInfo(
|
|
15022
|
-
this.scope.addStatement(
|
|
14775
|
+
initializer.addParseSpanInfo(this.node.sourceSpan);
|
|
14776
|
+
id.addParseSpanInfo(this.node.keySpan);
|
|
14777
|
+
this.scope.addStatement(new TcbExpr(`var ${id.print()} = ${initializer.print()}`));
|
|
15023
14778
|
return id;
|
|
15024
14779
|
}
|
|
15025
14780
|
};
|
|
@@ -15034,14 +14789,13 @@ var TcbInvalidReferenceOp = class extends TcbOp {
|
|
|
15034
14789
|
// The declaration of a missing reference is only needed when the reference is resolved.
|
|
15035
14790
|
optional = true;
|
|
15036
14791
|
execute() {
|
|
15037
|
-
const id = this.tcb.allocateId();
|
|
15038
|
-
this.scope.addStatement(
|
|
14792
|
+
const id = new TcbExpr(this.tcb.allocateId());
|
|
14793
|
+
this.scope.addStatement(new TcbExpr(`var ${id.print()} = any`));
|
|
15039
14794
|
return id;
|
|
15040
14795
|
}
|
|
15041
14796
|
};
|
|
15042
14797
|
|
|
15043
14798
|
// packages/compiler-cli/src/ngtsc/typecheck/src/ops/if_block.js
|
|
15044
|
-
import ts69 from "typescript";
|
|
15045
14799
|
var TcbIfOp = class extends TcbOp {
|
|
15046
14800
|
tcb;
|
|
15047
14801
|
scope;
|
|
@@ -15068,17 +14822,21 @@ var TcbIfOp = class extends TcbOp {
|
|
|
15068
14822
|
}
|
|
15069
14823
|
if (branch.expression === null) {
|
|
15070
14824
|
const branchScope = this.getBranchScope(this.scope, branch, index);
|
|
15071
|
-
return
|
|
14825
|
+
return new TcbExpr(`{
|
|
14826
|
+
${getStatementsBlock(branchScope.render())}}`);
|
|
15072
14827
|
}
|
|
15073
14828
|
const outerScope = this.scope.createChildScope(this.scope, branch, [], null);
|
|
15074
14829
|
outerScope.render().forEach((stmt) => this.scope.addStatement(stmt));
|
|
15075
14830
|
this.expressionScopes.set(branch, outerScope);
|
|
15076
14831
|
let expression = tcbExpression(branch.expression, this.tcb, this.scope);
|
|
15077
14832
|
if (branch.expressionAlias !== null) {
|
|
15078
|
-
expression =
|
|
14833
|
+
expression = new TcbExpr(`(${expression.print()}) && ${outerScope.resolve(branch.expressionAlias).print()}`);
|
|
15079
14834
|
}
|
|
15080
14835
|
const bodyScope = this.getBranchScope(outerScope, branch, index);
|
|
15081
|
-
|
|
14836
|
+
const ifStatement = `if (${expression.print()}) {
|
|
14837
|
+
${getStatementsBlock(bodyScope.render())}}`;
|
|
14838
|
+
const elseBranch = this.generateBranch(index + 1);
|
|
14839
|
+
return new TcbExpr(ifStatement + (elseBranch ? " else " + elseBranch.print() : ""));
|
|
15082
14840
|
}
|
|
15083
14841
|
getBranchScope(parentScope, branch, index) {
|
|
15084
14842
|
const checkBody = this.tcb.env.config.checkControlFlowBodies;
|
|
@@ -15098,18 +14856,17 @@ var TcbIfOp = class extends TcbOp {
|
|
|
15098
14856
|
let expression;
|
|
15099
14857
|
expression = tcbExpression(branch.expression, this.tcb, expressionScope);
|
|
15100
14858
|
if (branch.expressionAlias !== null) {
|
|
15101
|
-
expression =
|
|
14859
|
+
expression = new TcbExpr(`(${expression.print()}) && ${expressionScope.resolve(branch.expressionAlias).print()}`);
|
|
15102
14860
|
}
|
|
15103
|
-
markIgnoreDiagnostics(
|
|
15104
|
-
const comparisonExpression = i === index ? expression :
|
|
15105
|
-
guard = guard === null ? comparisonExpression :
|
|
14861
|
+
expression.markIgnoreDiagnostics();
|
|
14862
|
+
const comparisonExpression = i === index ? expression : new TcbExpr(`!(${expression.print()})`);
|
|
14863
|
+
guard = guard === null ? comparisonExpression : new TcbExpr(`(${guard.print()}) && (${comparisonExpression.print()})`);
|
|
15106
14864
|
}
|
|
15107
14865
|
return guard;
|
|
15108
14866
|
}
|
|
15109
14867
|
};
|
|
15110
14868
|
|
|
15111
14869
|
// packages/compiler-cli/src/ngtsc/typecheck/src/ops/switch_block.js
|
|
15112
|
-
import ts70 from "typescript";
|
|
15113
14870
|
var TcbSwitchOp = class extends TcbOp {
|
|
15114
14871
|
tcb;
|
|
15115
14872
|
scope;
|
|
@@ -15128,21 +14885,23 @@ var TcbSwitchOp = class extends TcbOp {
|
|
|
15128
14885
|
const clauses = this.block.groups.flatMap((current) => {
|
|
15129
14886
|
const checkBody = this.tcb.env.config.checkControlFlowBodies;
|
|
15130
14887
|
const clauseScope = this.scope.createChildScope(this.scope, null, checkBody ? current.children : [], checkBody ? this.generateGuard(current, switchExpression) : null);
|
|
15131
|
-
const statements = [...clauseScope.render(),
|
|
14888
|
+
const statements = [...clauseScope.render(), new TcbExpr("break")];
|
|
15132
14889
|
return current.cases.map((switchCase, index) => {
|
|
15133
|
-
const
|
|
15134
|
-
|
|
14890
|
+
const statementsStr = getStatementsBlock(
|
|
14891
|
+
index === current.cases.length - 1 ? statements : [],
|
|
14892
|
+
true
|
|
14893
|
+
/* singleLine */
|
|
14894
|
+
);
|
|
14895
|
+
const source = switchCase.expression === null ? `default: ${statementsStr}` : `case ${tcbExpression(switchCase.expression, this.tcb, this.scope).print()}: ${statementsStr}`;
|
|
14896
|
+
return new TcbExpr(source);
|
|
15135
14897
|
});
|
|
15136
14898
|
});
|
|
15137
14899
|
if (this.block.exhaustiveCheck) {
|
|
15138
14900
|
const switchValue = tcbExpression(this.block.expression, this.tcb, this.scope);
|
|
15139
|
-
|
|
15140
|
-
|
|
15141
|
-
ts70.factory.createVariableDeclaration(ts70.factory.createUniqueName("tcbExhaustive"), void 0, ts70.factory.createKeywordTypeNode(ts70.SyntaxKind.NeverKeyword), switchValue)
|
|
15142
|
-
], ts70.NodeFlags.Const))
|
|
15143
|
-
]));
|
|
14901
|
+
const exhaustiveId = this.tcb.allocateId();
|
|
14902
|
+
clauses.push(new TcbExpr(`default: const tcbExhaustive${exhaustiveId}: never = ${switchValue.print()};`));
|
|
15144
14903
|
}
|
|
15145
|
-
this.scope.addStatement(
|
|
14904
|
+
this.scope.addStatement(new TcbExpr(`switch (${switchExpression.print()}) { ${clauses.map((c) => c.print()).join("\n")} }`));
|
|
15146
14905
|
return null;
|
|
15147
14906
|
}
|
|
15148
14907
|
generateGuard(group, switchValue) {
|
|
@@ -15152,12 +14911,12 @@ var TcbSwitchOp = class extends TcbOp {
|
|
|
15152
14911
|
for (const switchCase of group.cases) {
|
|
15153
14912
|
if (switchCase.expression !== null) {
|
|
15154
14913
|
const expression = tcbExpression(switchCase.expression, this.tcb, this.scope);
|
|
15155
|
-
markIgnoreDiagnostics(
|
|
15156
|
-
const comparison =
|
|
14914
|
+
expression.markIgnoreDiagnostics();
|
|
14915
|
+
const comparison = new TcbExpr(`${switchValue.print()} === ${expression.print()}`);
|
|
15157
14916
|
if (guard2 === null) {
|
|
15158
14917
|
guard2 = comparison;
|
|
15159
14918
|
} else {
|
|
15160
|
-
guard2 =
|
|
14919
|
+
guard2 = new TcbExpr(`(${guard2.print()}) || (${comparison.print()})`);
|
|
15161
14920
|
}
|
|
15162
14921
|
}
|
|
15163
14922
|
}
|
|
@@ -15173,12 +14932,12 @@ var TcbSwitchOp = class extends TcbOp {
|
|
|
15173
14932
|
continue;
|
|
15174
14933
|
}
|
|
15175
14934
|
const expression = tcbExpression(switchCase.expression, this.tcb, this.scope);
|
|
15176
|
-
markIgnoreDiagnostics(
|
|
15177
|
-
const comparison =
|
|
14935
|
+
expression.markIgnoreDiagnostics();
|
|
14936
|
+
const comparison = new TcbExpr(`${switchValue.print()} !== ${expression.print()}`);
|
|
15178
14937
|
if (guard === null) {
|
|
15179
14938
|
guard = comparison;
|
|
15180
14939
|
} else {
|
|
15181
|
-
guard =
|
|
14940
|
+
guard = new TcbExpr(`(${guard.print()}) && (${comparison.print()})`);
|
|
15182
14941
|
}
|
|
15183
14942
|
}
|
|
15184
14943
|
}
|
|
@@ -15188,7 +14947,6 @@ var TcbSwitchOp = class extends TcbOp {
|
|
|
15188
14947
|
|
|
15189
14948
|
// packages/compiler-cli/src/ngtsc/typecheck/src/ops/for_block.js
|
|
15190
14949
|
import { ImplicitReceiver as ImplicitReceiver5, PropertyRead as PropertyRead5, ThisReceiver as ThisReceiver5, TmplAstVariable } from "@angular/compiler";
|
|
15191
|
-
import ts71 from "typescript";
|
|
15192
14950
|
var TcbForOfOp = class extends TcbOp {
|
|
15193
14951
|
tcb;
|
|
15194
14952
|
scope;
|
|
@@ -15205,19 +14963,14 @@ var TcbForOfOp = class extends TcbOp {
|
|
|
15205
14963
|
execute() {
|
|
15206
14964
|
const loopScope = this.scope.createChildScope(this.scope, this.block, this.tcb.env.config.checkControlFlowBodies ? this.block.children : [], null);
|
|
15207
14965
|
const initializerId = loopScope.resolve(this.block.item);
|
|
15208
|
-
|
|
15209
|
-
|
|
15210
|
-
}
|
|
15211
|
-
const initializer = ts71.factory.createVariableDeclarationList([ts71.factory.createVariableDeclaration(initializerId)], ts71.NodeFlags.Const);
|
|
15212
|
-
addParseSpanInfo(initializer, this.block.item.keySpan);
|
|
15213
|
-
const expression = ts71.factory.createNonNullExpression(tcbExpression(this.block.expression, this.tcb, this.scope));
|
|
14966
|
+
const initializer = new TcbExpr(`const ${initializerId.print()}`);
|
|
14967
|
+
initializer.addParseSpanInfo(this.block.item.keySpan);
|
|
14968
|
+
const expression = new TcbExpr(`${tcbExpression(this.block.expression, this.tcb, this.scope).print()}!`);
|
|
15214
14969
|
const trackTranslator = new TcbForLoopTrackTranslator(this.tcb, loopScope, this.block);
|
|
15215
14970
|
const trackExpression = trackTranslator.translate(this.block.trackBy);
|
|
15216
|
-
const
|
|
15217
|
-
|
|
15218
|
-
|
|
15219
|
-
];
|
|
15220
|
-
this.scope.addStatement(ts71.factory.createForOfStatement(void 0, initializer, expression, ts71.factory.createBlock(statements)));
|
|
14971
|
+
const block = getStatementsBlock([...loopScope.render(), trackExpression]);
|
|
14972
|
+
this.scope.addStatement(new TcbExpr(`for (${initializer.print()} of ${expression.print()}) {
|
|
14973
|
+
${block} }`));
|
|
15221
14974
|
return null;
|
|
15222
14975
|
}
|
|
15223
14976
|
};
|
|
@@ -15246,7 +14999,6 @@ var TcbForLoopTrackTranslator = class extends TcbExpressionTranslator {
|
|
|
15246
14999
|
};
|
|
15247
15000
|
|
|
15248
15001
|
// packages/compiler-cli/src/ngtsc/typecheck/src/ops/let.js
|
|
15249
|
-
import ts72 from "typescript";
|
|
15250
15002
|
var TcbLetDeclarationOp = class extends TcbOp {
|
|
15251
15003
|
tcb;
|
|
15252
15004
|
scope;
|
|
@@ -15263,11 +15015,10 @@ var TcbLetDeclarationOp = class extends TcbOp {
|
|
|
15263
15015
|
*/
|
|
15264
15016
|
optional = false;
|
|
15265
15017
|
execute() {
|
|
15266
|
-
const id = this.tcb.allocateId();
|
|
15267
|
-
|
|
15268
|
-
const
|
|
15269
|
-
|
|
15270
|
-
addParseSpanInfo(varStatement.declarationList.declarations[0], this.node.sourceSpan);
|
|
15018
|
+
const id = new TcbExpr(this.tcb.allocateId()).addParseSpanInfo(this.node.nameSpan);
|
|
15019
|
+
const value = tcbExpression(this.node.value, this.tcb, this.scope).wrapForTypeChecker();
|
|
15020
|
+
const varStatement = new TcbExpr(`const ${id.print()} = ${value.print()}`);
|
|
15021
|
+
varStatement.addParseSpanInfo(this.node.sourceSpan);
|
|
15271
15022
|
this.scope.addStatement(varStatement);
|
|
15272
15023
|
return id;
|
|
15273
15024
|
}
|
|
@@ -15275,11 +15026,11 @@ var TcbLetDeclarationOp = class extends TcbOp {
|
|
|
15275
15026
|
|
|
15276
15027
|
// packages/compiler-cli/src/ngtsc/typecheck/src/ops/inputs.js
|
|
15277
15028
|
import { BindingType as BindingType5, R3Identifiers as R3Identifiers5, TransplantedType } from "@angular/compiler";
|
|
15278
|
-
import
|
|
15029
|
+
import ts63 from "typescript";
|
|
15279
15030
|
|
|
15280
15031
|
// packages/compiler-cli/src/ngtsc/typecheck/src/ops/signal_forms.js
|
|
15281
15032
|
import { BindingType as BindingType3, Call as Call4, PropertyRead as PropertyRead6, SafeCall as SafeCall3, TmplAstElement as TmplAstElement3, TmplAstHostElement as TmplAstHostElement2 } from "@angular/compiler";
|
|
15282
|
-
import
|
|
15033
|
+
import ts62 from "typescript";
|
|
15283
15034
|
var formControlInputFields = [
|
|
15284
15035
|
// Should be kept in sync with the `FormUiControl` bindings,
|
|
15285
15036
|
// defined in `packages/forms/signals/src/api/control.ts`.
|
|
@@ -15343,58 +15094,43 @@ var TcbNativeFieldOp = class extends TcbOp {
|
|
|
15343
15094
|
return null;
|
|
15344
15095
|
}
|
|
15345
15096
|
checkUnsupportedFieldBindings(this.node, this.unsupportedBindingFields, this.tcb);
|
|
15346
|
-
const expectedType = this.getExpectedTypeFromDomNode(this.node);
|
|
15097
|
+
const expectedType = new TcbExpr(this.getExpectedTypeFromDomNode(this.node));
|
|
15347
15098
|
const value = extractFieldValue(fieldBinding.value, this.tcb, this.scope);
|
|
15348
|
-
const id = this.tcb.allocateId();
|
|
15349
|
-
const assignment =
|
|
15350
|
-
addParseSpanInfo(
|
|
15351
|
-
this.scope.addStatement(
|
|
15352
|
-
this.scope.addStatement(
|
|
15099
|
+
const id = new TcbExpr(this.tcb.allocateId());
|
|
15100
|
+
const assignment = new TcbExpr(`${id.print()} = ${value.print()}`);
|
|
15101
|
+
assignment.addParseSpanInfo(fieldBinding.valueSpan ?? fieldBinding.sourceSpan);
|
|
15102
|
+
this.scope.addStatement(declareVariable(id, expectedType));
|
|
15103
|
+
this.scope.addStatement(assignment);
|
|
15353
15104
|
return null;
|
|
15354
15105
|
}
|
|
15355
15106
|
getExpectedTypeFromDomNode(node) {
|
|
15356
15107
|
if (node.name === "textarea" || node.name === "select") {
|
|
15357
|
-
return
|
|
15108
|
+
return "string";
|
|
15358
15109
|
}
|
|
15359
15110
|
if (node.name !== "input") {
|
|
15360
15111
|
return this.getUnsupportedType();
|
|
15361
15112
|
}
|
|
15362
15113
|
switch (this.inputType) {
|
|
15363
15114
|
case "checkbox":
|
|
15364
|
-
return
|
|
15115
|
+
return "boolean";
|
|
15365
15116
|
case "number":
|
|
15366
15117
|
case "range":
|
|
15367
15118
|
case "datetime-local":
|
|
15368
|
-
return
|
|
15369
|
-
ts73.factory.createKeywordTypeNode(ts73.SyntaxKind.StringKeyword),
|
|
15370
|
-
ts73.factory.createKeywordTypeNode(ts73.SyntaxKind.NumberKeyword),
|
|
15371
|
-
ts73.factory.createLiteralTypeNode(ts73.factory.createNull())
|
|
15372
|
-
]);
|
|
15119
|
+
return "string | number | null";
|
|
15373
15120
|
case "date":
|
|
15374
15121
|
case "month":
|
|
15375
15122
|
case "time":
|
|
15376
15123
|
case "week":
|
|
15377
|
-
return
|
|
15378
|
-
ts73.factory.createKeywordTypeNode(ts73.SyntaxKind.StringKeyword),
|
|
15379
|
-
ts73.factory.createKeywordTypeNode(ts73.SyntaxKind.NumberKeyword),
|
|
15380
|
-
ts73.factory.createTypeReferenceNode("Date"),
|
|
15381
|
-
ts73.factory.createLiteralTypeNode(ts73.factory.createNull())
|
|
15382
|
-
]);
|
|
15124
|
+
return "string | number | Date | null";
|
|
15383
15125
|
}
|
|
15384
15126
|
const hasDynamicType = this.inputType === null && this.node.inputs.some((input) => (input.type === BindingType3.Property || input.type === BindingType3.Attribute) && input.name === "type");
|
|
15385
15127
|
if (hasDynamicType) {
|
|
15386
|
-
return
|
|
15387
|
-
ts73.factory.createKeywordTypeNode(ts73.SyntaxKind.StringKeyword),
|
|
15388
|
-
ts73.factory.createKeywordTypeNode(ts73.SyntaxKind.NumberKeyword),
|
|
15389
|
-
ts73.factory.createKeywordTypeNode(ts73.SyntaxKind.BooleanKeyword),
|
|
15390
|
-
ts73.factory.createTypeReferenceNode("Date"),
|
|
15391
|
-
ts73.factory.createLiteralTypeNode(ts73.factory.createNull())
|
|
15392
|
-
]);
|
|
15128
|
+
return "string | number | boolean | Date | null";
|
|
15393
15129
|
}
|
|
15394
|
-
return
|
|
15130
|
+
return "string";
|
|
15395
15131
|
}
|
|
15396
15132
|
getUnsupportedType() {
|
|
15397
|
-
return
|
|
15133
|
+
return "never";
|
|
15398
15134
|
}
|
|
15399
15135
|
};
|
|
15400
15136
|
var TcbNativeRadioButtonFieldOp = class extends TcbNativeFieldOp {
|
|
@@ -15408,12 +15144,12 @@ var TcbNativeRadioButtonFieldOp = class extends TcbNativeFieldOp {
|
|
|
15408
15144
|
return attr.type === BindingType3.Property && attr.name === "value";
|
|
15409
15145
|
});
|
|
15410
15146
|
if (valueBinding !== void 0) {
|
|
15411
|
-
const id = this.tcb.allocateId();
|
|
15147
|
+
const id = new TcbExpr(this.tcb.allocateId());
|
|
15412
15148
|
const value = tcbExpression(valueBinding.value, this.tcb, this.scope);
|
|
15413
|
-
const assignment =
|
|
15414
|
-
addParseSpanInfo(
|
|
15415
|
-
this.scope.addStatement(
|
|
15416
|
-
this.scope.addStatement(
|
|
15149
|
+
const assignment = new TcbExpr(`${id.print()} = ${value.print()}`);
|
|
15150
|
+
assignment.addParseSpanInfo(valueBinding.sourceSpan);
|
|
15151
|
+
this.scope.addStatement(declareVariable(id, new TcbExpr("string")));
|
|
15152
|
+
this.scope.addStatement(assignment);
|
|
15417
15153
|
}
|
|
15418
15154
|
return null;
|
|
15419
15155
|
}
|
|
@@ -15452,7 +15188,7 @@ function isFieldDirective(meta) {
|
|
|
15452
15188
|
if (meta.ref.bestGuessOwningModule?.specifier === "@angular/forms/signals") {
|
|
15453
15189
|
return true;
|
|
15454
15190
|
}
|
|
15455
|
-
return
|
|
15191
|
+
return ts62.isClassDeclaration(meta.ref.node) && meta.ref.node.members.some((member) => ts62.isPropertyDeclaration(member) && ts62.isComputedPropertyName(member.name) && ts62.isIdentifier(member.name.expression) && member.name.expression.text === "\u0275NgFieldDirective");
|
|
15456
15192
|
}
|
|
15457
15193
|
function getSyntheticFieldBoundInput(dir, inputName, fieldPropertyName, fieldBinding, customFieldType) {
|
|
15458
15194
|
const inputs = dir.inputs.getByBindingPropertyName(inputName);
|
|
@@ -15524,9 +15260,9 @@ function checkUnsupportedFieldBindings(node, unsupportedBindingFields, tcb) {
|
|
|
15524
15260
|
}
|
|
15525
15261
|
}
|
|
15526
15262
|
function extractFieldValue(expression, tcb, scope) {
|
|
15527
|
-
const innerCall =
|
|
15528
|
-
markIgnoreDiagnostics(
|
|
15529
|
-
return
|
|
15263
|
+
const innerCall = new TcbExpr(tcbExpression(expression, tcb, scope).print() + "()");
|
|
15264
|
+
innerCall.markIgnoreDiagnostics();
|
|
15265
|
+
return new TcbExpr(`${innerCall.print()}.value()`);
|
|
15530
15266
|
}
|
|
15531
15267
|
function hasModelInput(name, meta) {
|
|
15532
15268
|
return meta.inputs.hasBindingPropertyName(name) && meta.outputs.hasBindingPropertyName(name + "Change");
|
|
@@ -15545,8 +15281,7 @@ function isFormControl(allDirectiveMatches) {
|
|
|
15545
15281
|
}
|
|
15546
15282
|
|
|
15547
15283
|
// packages/compiler-cli/src/ngtsc/typecheck/src/ops/bindings.js
|
|
15548
|
-
import { BindingType as BindingType4, TmplAstBoundAttribute as TmplAstBoundAttribute4, TmplAstElement as TmplAstElement4, TmplAstTemplate as TmplAstTemplate3 } from "@angular/compiler";
|
|
15549
|
-
import ts74 from "typescript";
|
|
15284
|
+
import { BindingType as BindingType4, LiteralArray, LiteralMap, TmplAstBoundAttribute as TmplAstBoundAttribute4, TmplAstElement as TmplAstElement4, TmplAstTemplate as TmplAstTemplate3 } from "@angular/compiler";
|
|
15550
15285
|
function getBoundAttributes(directive, node) {
|
|
15551
15286
|
const boundInputs = [];
|
|
15552
15287
|
const processAttribute = (attr) => {
|
|
@@ -15602,14 +15337,14 @@ function checkSplitTwoWayBinding(inputName, output, inputs, tcb) {
|
|
|
15602
15337
|
}
|
|
15603
15338
|
return false;
|
|
15604
15339
|
}
|
|
15605
|
-
function widenBinding(expr, tcb) {
|
|
15340
|
+
function widenBinding(expr, tcb, originalValue) {
|
|
15606
15341
|
if (!tcb.env.config.checkTypeOfInputBindings) {
|
|
15607
|
-
return
|
|
15342
|
+
return new TcbExpr(`((${expr.print()}) as any)`);
|
|
15608
15343
|
} else if (!tcb.env.config.strictNullInputBindings) {
|
|
15609
|
-
if (
|
|
15344
|
+
if (originalValue instanceof LiteralMap || originalValue instanceof LiteralArray) {
|
|
15610
15345
|
return expr;
|
|
15611
15346
|
} else {
|
|
15612
|
-
return
|
|
15347
|
+
return new TcbExpr(`(${expr.print()})!`);
|
|
15613
15348
|
}
|
|
15614
15349
|
} else {
|
|
15615
15350
|
return expr;
|
|
@@ -15619,7 +15354,7 @@ function widenBinding(expr, tcb) {
|
|
|
15619
15354
|
// packages/compiler-cli/src/ngtsc/typecheck/src/ops/inputs.js
|
|
15620
15355
|
function translateInput(value, tcb, scope) {
|
|
15621
15356
|
if (typeof value === "string") {
|
|
15622
|
-
return
|
|
15357
|
+
return new TcbExpr(quoteAndEscape(value));
|
|
15623
15358
|
} else {
|
|
15624
15359
|
return tcbExpression(value, tcb, scope);
|
|
15625
15360
|
}
|
|
@@ -15657,8 +15392,8 @@ var TcbDirectiveInputsOp = class extends TcbOp {
|
|
|
15657
15392
|
}
|
|
15658
15393
|
}
|
|
15659
15394
|
for (const attr of boundAttrs) {
|
|
15660
|
-
|
|
15661
|
-
|
|
15395
|
+
let assignment = widenBinding(translateInput(attr.value, this.tcb, this.scope), this.tcb, attr.value);
|
|
15396
|
+
assignment.wrapForTypeChecker();
|
|
15662
15397
|
for (const { fieldName, required, transformType, isSignal, isTwoWayBinding } of attr.inputs) {
|
|
15663
15398
|
let target;
|
|
15664
15399
|
if (required) {
|
|
@@ -15667,16 +15402,18 @@ var TcbDirectiveInputsOp = class extends TcbOp {
|
|
|
15667
15402
|
if (this.dir.coercedInputFields.has(fieldName)) {
|
|
15668
15403
|
let type;
|
|
15669
15404
|
if (transformType !== null) {
|
|
15670
|
-
|
|
15405
|
+
const tsType = this.tcb.env.referenceTransplantedType(new TransplantedType(transformType));
|
|
15406
|
+
type = new TcbExpr(tempPrint(tsType, transformType.node.getSourceFile()));
|
|
15671
15407
|
} else {
|
|
15672
15408
|
const dirTypeRef = this.tcb.env.referenceType(this.dir.ref);
|
|
15673
|
-
if (!
|
|
15409
|
+
if (!ts63.isTypeReferenceNode(dirTypeRef)) {
|
|
15674
15410
|
throw new Error(`Expected TypeReferenceNode from reference to ${this.dir.ref.debugName}`);
|
|
15675
15411
|
}
|
|
15676
|
-
|
|
15412
|
+
const typeName = ts63.isIdentifier(dirTypeRef.typeName) ? dirTypeRef.typeName.text : tempPrint(dirTypeRef.typeName, dirTypeRef.typeName.getSourceFile());
|
|
15413
|
+
type = new TcbExpr(`typeof ${typeName}.ngAcceptInputType_${fieldName}`);
|
|
15677
15414
|
}
|
|
15678
|
-
const id = this.tcb.allocateId();
|
|
15679
|
-
this.scope.addStatement(
|
|
15415
|
+
const id = new TcbExpr(this.tcb.allocateId());
|
|
15416
|
+
this.scope.addStatement(declareVariable(id, type));
|
|
15680
15417
|
target = id;
|
|
15681
15418
|
} else if (this.dir.undeclaredInputFields.has(fieldName)) {
|
|
15682
15419
|
continue;
|
|
@@ -15684,41 +15421,38 @@ var TcbDirectiveInputsOp = class extends TcbOp {
|
|
|
15684
15421
|
if (dirId === null) {
|
|
15685
15422
|
dirId = this.scope.resolve(this.node, this.dir);
|
|
15686
15423
|
}
|
|
15687
|
-
const id = this.tcb.allocateId();
|
|
15424
|
+
const id = new TcbExpr(this.tcb.allocateId());
|
|
15688
15425
|
const dirTypeRef = this.tcb.env.referenceType(this.dir.ref);
|
|
15689
|
-
if (!
|
|
15426
|
+
if (!ts63.isTypeReferenceNode(dirTypeRef)) {
|
|
15690
15427
|
throw new Error(`Expected TypeReferenceNode from reference to ${this.dir.ref.debugName}`);
|
|
15691
15428
|
}
|
|
15692
|
-
const type =
|
|
15693
|
-
const temp =
|
|
15429
|
+
const type = new TcbExpr(`(typeof ${dirId.print()})[${quoteAndEscape(fieldName)}]`);
|
|
15430
|
+
const temp = declareVariable(id, type);
|
|
15694
15431
|
this.scope.addStatement(temp);
|
|
15695
15432
|
target = id;
|
|
15696
15433
|
} else {
|
|
15697
15434
|
if (dirId === null) {
|
|
15698
15435
|
dirId = this.scope.resolve(this.node, this.dir);
|
|
15699
15436
|
}
|
|
15700
|
-
target = this.dir.stringLiteralInputFields.has(fieldName) ?
|
|
15437
|
+
target = this.dir.stringLiteralInputFields.has(fieldName) ? new TcbExpr(`${dirId.print()}[${quoteAndEscape(fieldName)}]`) : new TcbExpr(`${dirId.print()}.${fieldName}`);
|
|
15701
15438
|
}
|
|
15702
15439
|
if (isSignal) {
|
|
15703
15440
|
const inputSignalBrandWriteSymbol = this.tcb.env.referenceExternalSymbol(R3Identifiers5.InputSignalBrandWriteType.moduleName, R3Identifiers5.InputSignalBrandWriteType.name);
|
|
15704
|
-
|
|
15705
|
-
throw new Error(`Expected identifier or property access for reference to ${R3Identifiers5.InputSignalBrandWriteType.name}`);
|
|
15706
|
-
}
|
|
15707
|
-
target = ts75.factory.createElementAccessExpression(target, inputSignalBrandWriteSymbol);
|
|
15441
|
+
target = new TcbExpr(`${target.print()}[${inputSignalBrandWriteSymbol.print()}]`);
|
|
15708
15442
|
}
|
|
15709
15443
|
if (attr.keySpan !== null) {
|
|
15710
|
-
addParseSpanInfo(
|
|
15444
|
+
target.addParseSpanInfo(attr.keySpan);
|
|
15711
15445
|
}
|
|
15712
15446
|
if (isTwoWayBinding && this.tcb.env.config.allowSignalsInTwoWayBindings) {
|
|
15713
15447
|
assignment = unwrapWritableSignal(assignment, this.tcb);
|
|
15714
15448
|
}
|
|
15715
|
-
assignment =
|
|
15449
|
+
assignment = new TcbExpr(`${target.print()} = ${assignment.print()}`);
|
|
15716
15450
|
}
|
|
15717
|
-
addParseSpanInfo(
|
|
15451
|
+
assignment.addParseSpanInfo(attr.sourceSpan);
|
|
15718
15452
|
if (!this.tcb.env.config.checkTypeOfAttributes && typeof attr.value === "string") {
|
|
15719
|
-
markIgnoreDiagnostics(
|
|
15453
|
+
assignment.markIgnoreDiagnostics();
|
|
15720
15454
|
}
|
|
15721
|
-
this.scope.addStatement(
|
|
15455
|
+
this.scope.addStatement(assignment);
|
|
15722
15456
|
}
|
|
15723
15457
|
this.checkRequiredInputs(seenRequiredInputs);
|
|
15724
15458
|
return null;
|
|
@@ -15759,22 +15493,20 @@ var TcbUnclaimedInputsOp = class extends TcbOp {
|
|
|
15759
15493
|
if (isPropertyBinding && this.claimedInputs?.has(binding.name)) {
|
|
15760
15494
|
continue;
|
|
15761
15495
|
}
|
|
15762
|
-
const expr = widenBinding(tcbExpression(binding.value, this.tcb, this.scope), this.tcb);
|
|
15496
|
+
const expr = widenBinding(tcbExpression(binding.value, this.tcb, this.scope), this.tcb, binding.value);
|
|
15763
15497
|
if (this.tcb.env.config.checkTypeOfDomBindings && isPropertyBinding) {
|
|
15764
15498
|
if (binding.name !== "style" && binding.name !== "class") {
|
|
15765
15499
|
if (elId === null) {
|
|
15766
15500
|
elId = this.scope.resolve(this.target);
|
|
15767
15501
|
}
|
|
15768
15502
|
const propertyName = REGISTRY.getMappedPropName(binding.name);
|
|
15769
|
-
const
|
|
15770
|
-
|
|
15771
|
-
addParseSpanInfo(stmt, binding.sourceSpan);
|
|
15772
|
-
this.scope.addStatement(ts75.factory.createExpressionStatement(stmt));
|
|
15503
|
+
const stmt = new TcbExpr(`${elId.print()}[${quoteAndEscape(propertyName)}] = ${expr.wrapForTypeChecker().print()}`).addParseSpanInfo(binding.sourceSpan);
|
|
15504
|
+
this.scope.addStatement(stmt);
|
|
15773
15505
|
} else {
|
|
15774
|
-
this.scope.addStatement(
|
|
15506
|
+
this.scope.addStatement(expr);
|
|
15775
15507
|
}
|
|
15776
15508
|
} else {
|
|
15777
|
-
this.scope.addStatement(
|
|
15509
|
+
this.scope.addStatement(expr);
|
|
15778
15510
|
}
|
|
15779
15511
|
}
|
|
15780
15512
|
return null;
|
|
@@ -15801,10 +15533,10 @@ var TcbComponentNodeOp = class extends TcbOp {
|
|
|
15801
15533
|
}
|
|
15802
15534
|
execute() {
|
|
15803
15535
|
const id = this.tcb.allocateId();
|
|
15804
|
-
const initializer =
|
|
15805
|
-
addParseSpanInfo(
|
|
15806
|
-
this.scope.addStatement(
|
|
15807
|
-
return id;
|
|
15536
|
+
const initializer = new TcbExpr(`document.createElement("${getComponentTagName(this.component)}")`);
|
|
15537
|
+
initializer.addParseSpanInfo(this.component.startSourceSpan || this.component.sourceSpan);
|
|
15538
|
+
this.scope.addStatement(new TcbExpr(`var ${id} = ${initializer.print()}`));
|
|
15539
|
+
return new TcbExpr(id);
|
|
15808
15540
|
}
|
|
15809
15541
|
};
|
|
15810
15542
|
|
|
@@ -15854,7 +15586,6 @@ var TcbDomSchemaCheckerOp = class extends TcbOp {
|
|
|
15854
15586
|
|
|
15855
15587
|
// packages/compiler-cli/src/ngtsc/typecheck/src/ops/events.js
|
|
15856
15588
|
import { ImplicitReceiver as ImplicitReceiver6, ParsedEventType as ParsedEventType2, PropertyRead as PropertyRead7, TmplAstElement as TmplAstElement6 } from "@angular/compiler";
|
|
15857
|
-
import ts76 from "typescript";
|
|
15858
15589
|
var EVENT_PARAMETER = "$event";
|
|
15859
15590
|
function tcbEventHandlerExpression(ast, tcb, scope) {
|
|
15860
15591
|
const translator = new TcbEventHandlerTranslator(tcb, scope);
|
|
@@ -15894,8 +15625,8 @@ var TcbDirectiveOutputsOp = class extends TcbOp {
|
|
|
15894
15625
|
if (dirId === null) {
|
|
15895
15626
|
dirId = this.scope.resolve(this.node, this.dir);
|
|
15896
15627
|
}
|
|
15897
|
-
const outputField =
|
|
15898
|
-
addParseSpanInfo(
|
|
15628
|
+
const outputField = new TcbExpr(`${dirId.print()}[${quoteAndEscape(field)}]`);
|
|
15629
|
+
outputField.addParseSpanInfo(output.keySpan);
|
|
15899
15630
|
if (this.tcb.env.config.checkTypeOfOutputEvents) {
|
|
15900
15631
|
const handler = tcbCreateEventHandler(
|
|
15901
15632
|
output,
|
|
@@ -15904,19 +15635,11 @@ var TcbDirectiveOutputsOp = class extends TcbOp {
|
|
|
15904
15635
|
0
|
|
15905
15636
|
/* EventParamType.Infer */
|
|
15906
15637
|
);
|
|
15907
|
-
const
|
|
15908
|
-
|
|
15909
|
-
|
|
15910
|
-
/* typeArguments */
|
|
15911
|
-
void 0,
|
|
15912
|
-
[
|
|
15913
|
-
handler
|
|
15914
|
-
]
|
|
15915
|
-
);
|
|
15916
|
-
addParseSpanInfo(call, output.sourceSpan);
|
|
15917
|
-
this.scope.addStatement(ts76.factory.createExpressionStatement(call));
|
|
15638
|
+
const call = new TcbExpr(`${outputField.print()}.subscribe(${handler.print()})`);
|
|
15639
|
+
call.addParseSpanInfo(output.sourceSpan);
|
|
15640
|
+
this.scope.addStatement(call);
|
|
15918
15641
|
} else {
|
|
15919
|
-
this.scope.addStatement(
|
|
15642
|
+
this.scope.addStatement(outputField);
|
|
15920
15643
|
const handler = tcbCreateEventHandler(
|
|
15921
15644
|
output,
|
|
15922
15645
|
this.tcb,
|
|
@@ -15924,7 +15647,7 @@ var TcbDirectiveOutputsOp = class extends TcbOp {
|
|
|
15924
15647
|
1
|
|
15925
15648
|
/* EventParamType.Any */
|
|
15926
15649
|
);
|
|
15927
|
-
this.scope.addStatement(
|
|
15650
|
+
this.scope.addStatement(handler);
|
|
15928
15651
|
}
|
|
15929
15652
|
}
|
|
15930
15653
|
return null;
|
|
@@ -15962,41 +15685,32 @@ var TcbUnclaimedOutputsOp = class extends TcbOp {
|
|
|
15962
15685
|
}
|
|
15963
15686
|
}
|
|
15964
15687
|
if (output.type === ParsedEventType2.LegacyAnimation) {
|
|
15965
|
-
const eventType = this.tcb.env.config.checkTypeOfAnimationEvents ? this.tcb.env.
|
|
15688
|
+
const eventType = this.tcb.env.config.checkTypeOfAnimationEvents ? this.tcb.env.referenceExternalSymbol("@angular/animations", "AnimationEvent").print() : 1;
|
|
15966
15689
|
const handler = tcbCreateEventHandler(output, this.tcb, this.scope, eventType);
|
|
15967
|
-
this.scope.addStatement(
|
|
15690
|
+
this.scope.addStatement(handler);
|
|
15968
15691
|
} else if (output.type === ParsedEventType2.Animation) {
|
|
15969
|
-
const eventType = this.tcb.env.
|
|
15970
|
-
const handler = tcbCreateEventHandler(output, this.tcb, this.scope, eventType);
|
|
15971
|
-
this.scope.addStatement(
|
|
15692
|
+
const eventType = this.tcb.env.referenceExternalSymbol("@angular/core", "AnimationCallbackEvent");
|
|
15693
|
+
const handler = tcbCreateEventHandler(output, this.tcb, this.scope, eventType.print());
|
|
15694
|
+
this.scope.addStatement(handler);
|
|
15972
15695
|
} else if (this.tcb.env.config.checkTypeOfDomEvents) {
|
|
15973
15696
|
let target;
|
|
15974
15697
|
let domEventAssertion;
|
|
15975
15698
|
if (output.target === "window" || output.target === "document") {
|
|
15976
|
-
target =
|
|
15699
|
+
target = new TcbExpr(output.target);
|
|
15977
15700
|
} else if (elId === null) {
|
|
15978
15701
|
target = elId = this.scope.resolve(this.target);
|
|
15979
15702
|
} else {
|
|
15980
15703
|
target = elId;
|
|
15981
15704
|
}
|
|
15982
|
-
if (this.target instanceof TmplAstElement6 && this.target.isVoid &&
|
|
15983
|
-
|
|
15984
|
-
|
|
15985
|
-
]);
|
|
15705
|
+
if (this.target instanceof TmplAstElement6 && this.target.isVoid && this.tcb.env.config.allowDomEventAssertion) {
|
|
15706
|
+
const assertUtil = this.tcb.env.referenceExternalSymbol("@angular/core", "\u0275assertType");
|
|
15707
|
+
domEventAssertion = new TcbExpr(`${assertUtil.print()}<typeof ${target.print()}>(${EVENT_PARAMETER}.target)`);
|
|
15986
15708
|
}
|
|
15987
|
-
const propertyAccess =
|
|
15988
|
-
addParseSpanInfo(propertyAccess, output.keySpan);
|
|
15709
|
+
const propertyAccess = new TcbExpr(`${target.print()}.addEventListener`).addParseSpanInfo(output.keySpan);
|
|
15989
15710
|
const handler = tcbCreateEventHandler(output, this.tcb, this.scope, 0, domEventAssertion);
|
|
15990
|
-
const call =
|
|
15991
|
-
|
|
15992
|
-
|
|
15993
|
-
/* typeArguments */
|
|
15994
|
-
void 0,
|
|
15995
|
-
/* arguments */
|
|
15996
|
-
[ts76.factory.createStringLiteral(output.name), handler]
|
|
15997
|
-
);
|
|
15998
|
-
addParseSpanInfo(call, output.sourceSpan);
|
|
15999
|
-
this.scope.addStatement(ts76.factory.createExpressionStatement(call));
|
|
15711
|
+
const call = new TcbExpr(`${propertyAccess.print()}(${quoteAndEscape(output.name)}, ${handler.print()})`);
|
|
15712
|
+
call.addParseSpanInfo(output.sourceSpan);
|
|
15713
|
+
this.scope.addStatement(call);
|
|
16000
15714
|
} else {
|
|
16001
15715
|
const handler = tcbCreateEventHandler(
|
|
16002
15716
|
output,
|
|
@@ -16005,7 +15719,7 @@ var TcbUnclaimedOutputsOp = class extends TcbOp {
|
|
|
16005
15719
|
1
|
|
16006
15720
|
/* EventParamType.Any */
|
|
16007
15721
|
);
|
|
16008
|
-
this.scope.addStatement(
|
|
15722
|
+
this.scope.addStatement(handler);
|
|
16009
15723
|
}
|
|
16010
15724
|
}
|
|
16011
15725
|
return null;
|
|
@@ -16014,9 +15728,7 @@ var TcbUnclaimedOutputsOp = class extends TcbOp {
|
|
|
16014
15728
|
var TcbEventHandlerTranslator = class extends TcbExpressionTranslator {
|
|
16015
15729
|
resolve(ast) {
|
|
16016
15730
|
if (ast instanceof PropertyRead7 && ast.receiver instanceof ImplicitReceiver6 && ast.name === EVENT_PARAMETER) {
|
|
16017
|
-
|
|
16018
|
-
addParseSpanInfo(event, ast.nameSpan);
|
|
16019
|
-
return event;
|
|
15731
|
+
return new TcbExpr(EVENT_PARAMETER).addParseSpanInfo(ast.nameSpan);
|
|
16020
15732
|
}
|
|
16021
15733
|
return super.resolve(ast);
|
|
16022
15734
|
}
|
|
@@ -16028,60 +15740,37 @@ function tcbCreateEventHandler(event, tcb, scope, eventType, assertionExpression
|
|
|
16028
15740
|
const handler = tcbEventHandlerExpression(event.handler, tcb, scope);
|
|
16029
15741
|
const statements = [];
|
|
16030
15742
|
if (assertionExpression !== void 0) {
|
|
16031
|
-
statements.push(
|
|
15743
|
+
statements.push(assertionExpression);
|
|
16032
15744
|
}
|
|
16033
15745
|
if (event.type === ParsedEventType2.TwoWay && tcb.env.config.checkTwoWayBoundEvents) {
|
|
16034
15746
|
const target = tcb.allocateId();
|
|
16035
|
-
const
|
|
16036
|
-
statements.push(
|
|
15747
|
+
const initializer = tcb.env.config.allowSignalsInTwoWayBindings ? unwrapWritableSignal(handler, tcb) : handler;
|
|
15748
|
+
statements.push(new TcbExpr(`var ${target} = ${initializer.print()}`), new TcbExpr(`${target} = ${EVENT_PARAMETER}`));
|
|
16037
15749
|
} else {
|
|
16038
|
-
statements.push(
|
|
15750
|
+
statements.push(handler);
|
|
16039
15751
|
}
|
|
16040
15752
|
let eventParamType;
|
|
16041
15753
|
if (eventType === 0) {
|
|
16042
15754
|
eventParamType = void 0;
|
|
16043
15755
|
} else if (eventType === 1) {
|
|
16044
|
-
eventParamType =
|
|
15756
|
+
eventParamType = "any";
|
|
16045
15757
|
} else {
|
|
16046
15758
|
eventParamType = eventType;
|
|
16047
15759
|
}
|
|
16048
15760
|
const guards = scope.guards();
|
|
16049
|
-
let body =
|
|
15761
|
+
let body = `{
|
|
15762
|
+
${getStatementsBlock(statements)} }`;
|
|
16050
15763
|
if (guards !== null) {
|
|
16051
|
-
body =
|
|
15764
|
+
body = `{ if (${guards.print()}) ${body} }`;
|
|
16052
15765
|
}
|
|
16053
|
-
const eventParam =
|
|
16054
|
-
|
|
16055
|
-
|
|
16056
|
-
/* dotDotDotToken */
|
|
16057
|
-
void 0,
|
|
16058
|
-
/* name */
|
|
16059
|
-
EVENT_PARAMETER,
|
|
16060
|
-
/* questionToken */
|
|
16061
|
-
void 0,
|
|
16062
|
-
/* type */
|
|
16063
|
-
eventParamType
|
|
16064
|
-
);
|
|
16065
|
-
addExpressionIdentifier(eventParam, ExpressionIdentifier.EVENT_PARAMETER);
|
|
16066
|
-
return ts76.factory.createArrowFunction(
|
|
16067
|
-
/* modifiers */
|
|
16068
|
-
void 0,
|
|
16069
|
-
/* typeParameters */
|
|
16070
|
-
void 0,
|
|
16071
|
-
/* parameters */
|
|
16072
|
-
[eventParam],
|
|
16073
|
-
/* type */
|
|
16074
|
-
ts76.factory.createKeywordTypeNode(ts76.SyntaxKind.AnyKeyword),
|
|
16075
|
-
/* equalsGreaterThanToken */
|
|
16076
|
-
void 0,
|
|
16077
|
-
/* body */
|
|
16078
|
-
body
|
|
16079
|
-
);
|
|
15766
|
+
const eventParam = new TcbExpr(`${EVENT_PARAMETER}${eventParamType === void 0 ? "" : ": " + eventParamType}`);
|
|
15767
|
+
eventParam.addExpressionIdentifier(ExpressionIdentifier.EVENT_PARAMETER);
|
|
15768
|
+
return new TcbExpr(`(${eventParam.print()}): any => ${body}`);
|
|
16080
15769
|
}
|
|
16081
15770
|
|
|
16082
15771
|
// packages/compiler-cli/src/ngtsc/typecheck/src/ops/directive_type.js
|
|
16083
15772
|
import { TmplAstHostElement as TmplAstHostElement3 } from "@angular/compiler";
|
|
16084
|
-
import
|
|
15773
|
+
import ts64 from "typescript";
|
|
16085
15774
|
var TcbDirectiveTypeOpBase = class extends TcbOp {
|
|
16086
15775
|
tcb;
|
|
16087
15776
|
scope;
|
|
@@ -16103,23 +15792,21 @@ var TcbDirectiveTypeOpBase = class extends TcbOp {
|
|
|
16103
15792
|
let type;
|
|
16104
15793
|
let span;
|
|
16105
15794
|
if (this.dir.isGeneric === false || dirRef.node.typeParameters === void 0) {
|
|
16106
|
-
type = rawType;
|
|
15795
|
+
type = new TcbExpr(tempPrint(rawType, dirRef.node.getSourceFile()));
|
|
16107
15796
|
} else {
|
|
16108
|
-
if (!
|
|
15797
|
+
if (!ts64.isTypeReferenceNode(rawType)) {
|
|
16109
15798
|
throw new Error(`Expected TypeReferenceNode when referencing the type for ${this.dir.ref.debugName}`);
|
|
16110
15799
|
}
|
|
16111
|
-
const typeArguments = dirRef.node.typeParameters.map(() =>
|
|
16112
|
-
type =
|
|
15800
|
+
const typeArguments = dirRef.node.typeParameters.map(() => ts64.factory.createKeywordTypeNode(ts64.SyntaxKind.AnyKeyword));
|
|
15801
|
+
type = new TcbExpr(tempPrint(ts64.factory.createTypeReferenceNode(rawType.typeName, typeArguments), dirRef.node.getSourceFile()));
|
|
16113
15802
|
}
|
|
16114
15803
|
if (this.node instanceof TmplAstHostElement3) {
|
|
16115
15804
|
span = this.node.sourceSpan;
|
|
16116
15805
|
} else {
|
|
16117
15806
|
span = this.node.startSourceSpan || this.node.sourceSpan;
|
|
16118
15807
|
}
|
|
16119
|
-
const id = this.tcb.allocateId();
|
|
16120
|
-
|
|
16121
|
-
addParseSpanInfo(id, span);
|
|
16122
|
-
this.scope.addStatement(tsDeclareVariable(id, type));
|
|
15808
|
+
const id = new TcbExpr(this.tcb.allocateId()).addExpressionIdentifier(ExpressionIdentifier.DIRECTIVE).addParseSpanInfo(span);
|
|
15809
|
+
this.scope.addStatement(declareVariable(id, type));
|
|
16123
15810
|
return id;
|
|
16124
15811
|
}
|
|
16125
15812
|
};
|
|
@@ -16148,7 +15835,6 @@ var TcbGenericDirectiveTypeWithAnyParamsOp = class extends TcbDirectiveTypeOpBas
|
|
|
16148
15835
|
|
|
16149
15836
|
// packages/compiler-cli/src/ngtsc/typecheck/src/ops/directive_constructor.js
|
|
16150
15837
|
import { TmplAstHostElement as TmplAstHostElement4 } from "@angular/compiler";
|
|
16151
|
-
import ts78 from "typescript";
|
|
16152
15838
|
var TcbDirectiveCtorOp = class extends TcbOp {
|
|
16153
15839
|
tcb;
|
|
16154
15840
|
scope;
|
|
@@ -16168,7 +15854,7 @@ var TcbDirectiveCtorOp = class extends TcbOp {
|
|
|
16168
15854
|
}
|
|
16169
15855
|
execute() {
|
|
16170
15856
|
const genericInputs = /* @__PURE__ */ new Map();
|
|
16171
|
-
const id = this.tcb.allocateId();
|
|
15857
|
+
const id = new TcbExpr(this.tcb.allocateId());
|
|
16172
15858
|
let boundAttrs;
|
|
16173
15859
|
let span;
|
|
16174
15860
|
if (this.node instanceof TmplAstHostElement4) {
|
|
@@ -16184,8 +15870,7 @@ var TcbDirectiveCtorOp = class extends TcbOp {
|
|
|
16184
15870
|
}
|
|
16185
15871
|
}
|
|
16186
15872
|
}
|
|
16187
|
-
addExpressionIdentifier(
|
|
16188
|
-
addParseSpanInfo(id, span);
|
|
15873
|
+
id.addExpressionIdentifier(ExpressionIdentifier.DIRECTIVE).addParseSpanInfo(span);
|
|
16189
15874
|
for (const attr of boundAttrs) {
|
|
16190
15875
|
if (!this.tcb.env.config.checkTypeOfAttributes && typeof attr.value === "string") {
|
|
16191
15876
|
continue;
|
|
@@ -16199,6 +15884,7 @@ var TcbDirectiveCtorOp = class extends TcbOp {
|
|
|
16199
15884
|
type: "binding",
|
|
16200
15885
|
field: fieldName,
|
|
16201
15886
|
expression,
|
|
15887
|
+
originalExpression: attr.value,
|
|
16202
15888
|
sourceSpan: attr.sourceSpan,
|
|
16203
15889
|
isTwoWayBinding
|
|
16204
15890
|
});
|
|
@@ -16210,8 +15896,8 @@ var TcbDirectiveCtorOp = class extends TcbOp {
|
|
|
16210
15896
|
}
|
|
16211
15897
|
}
|
|
16212
15898
|
const typeCtor = tcbCallTypeCtor(this.dir, this.tcb, Array.from(genericInputs.values()));
|
|
16213
|
-
markIgnoreDiagnostics(
|
|
16214
|
-
this.scope.addStatement(
|
|
15899
|
+
typeCtor.markIgnoreDiagnostics();
|
|
15900
|
+
this.scope.addStatement(new TcbExpr(`var ${id.print()} = ${typeCtor.print()}`));
|
|
16215
15901
|
return id;
|
|
16216
15902
|
}
|
|
16217
15903
|
circularFallback() {
|
|
@@ -16234,45 +15920,37 @@ var TcbDirectiveCtorCircularFallbackOp = class extends TcbOp {
|
|
|
16234
15920
|
execute() {
|
|
16235
15921
|
const id = this.tcb.allocateId();
|
|
16236
15922
|
const typeCtor = this.tcb.env.typeCtorFor(this.dir);
|
|
16237
|
-
|
|
16238
|
-
|
|
16239
|
-
/* typeArguments */
|
|
16240
|
-
void 0,
|
|
16241
|
-
[ts78.factory.createNonNullExpression(ts78.factory.createNull())]
|
|
16242
|
-
);
|
|
16243
|
-
this.scope.addStatement(tsCreateVariable(id, circularPlaceholder));
|
|
16244
|
-
return id;
|
|
15923
|
+
this.scope.addStatement(new TcbExpr(`var ${id} = ${typeCtor.print()}(null!)`));
|
|
15924
|
+
return new TcbExpr(id);
|
|
16245
15925
|
}
|
|
16246
15926
|
};
|
|
16247
15927
|
function tcbCallTypeCtor(dir, tcb, inputs) {
|
|
16248
15928
|
const typeCtor = tcb.env.typeCtorFor(dir);
|
|
16249
|
-
|
|
16250
|
-
|
|
15929
|
+
let literal4 = "{ ";
|
|
15930
|
+
for (let i = 0; i < inputs.length; i++) {
|
|
15931
|
+
const input = inputs[i];
|
|
15932
|
+
const propertyName = quoteAndEscape(input.field);
|
|
15933
|
+
const isLast = i === inputs.length - 1;
|
|
16251
15934
|
if (input.type === "binding") {
|
|
16252
|
-
let expr = widenBinding(input.expression, tcb);
|
|
15935
|
+
let expr = widenBinding(input.expression, tcb, input.originalExpression);
|
|
16253
15936
|
if (input.isTwoWayBinding && tcb.env.config.allowSignalsInTwoWayBindings) {
|
|
16254
15937
|
expr = unwrapWritableSignal(expr, tcb);
|
|
16255
15938
|
}
|
|
16256
|
-
const assignment =
|
|
16257
|
-
addParseSpanInfo(
|
|
16258
|
-
|
|
15939
|
+
const assignment = new TcbExpr(`${propertyName}: ${expr.wrapForTypeChecker().print()}`);
|
|
15940
|
+
assignment.addParseSpanInfo(input.sourceSpan);
|
|
15941
|
+
literal4 += assignment.print();
|
|
16259
15942
|
} else {
|
|
16260
|
-
|
|
15943
|
+
literal4 += `${propertyName}: 0 as any`;
|
|
16261
15944
|
}
|
|
16262
|
-
|
|
16263
|
-
|
|
16264
|
-
|
|
16265
|
-
|
|
16266
|
-
/* typeArguments */
|
|
16267
|
-
void 0,
|
|
16268
|
-
/* argumentsArray */
|
|
16269
|
-
[ts78.factory.createObjectLiteralExpression(members)]
|
|
16270
|
-
);
|
|
15945
|
+
literal4 += `${isLast ? "" : ","} `;
|
|
15946
|
+
}
|
|
15947
|
+
literal4 += "}";
|
|
15948
|
+
return new TcbExpr(`${typeCtor.print()}(${literal4})`);
|
|
16271
15949
|
}
|
|
16272
15950
|
|
|
16273
15951
|
// packages/compiler-cli/src/ngtsc/typecheck/src/ops/content_projection.js
|
|
16274
15952
|
import { createCssSelectorFromNode, CssSelector as CssSelector3, SelectorMatcher as SelectorMatcher2, TmplAstElement as TmplAstElement7, TmplAstForLoopBlock, TmplAstIfBlock, TmplAstSwitchBlock, TmplAstTemplate as TmplAstTemplate4, TmplAstText } from "@angular/compiler";
|
|
16275
|
-
import
|
|
15953
|
+
import ts65 from "typescript";
|
|
16276
15954
|
var TcbControlFlowContentProjectionOp = class extends TcbOp {
|
|
16277
15955
|
tcb;
|
|
16278
15956
|
element;
|
|
@@ -16285,7 +15963,7 @@ var TcbControlFlowContentProjectionOp = class extends TcbOp {
|
|
|
16285
15963
|
this.element = element;
|
|
16286
15964
|
this.ngContentSelectors = ngContentSelectors;
|
|
16287
15965
|
this.componentName = componentName;
|
|
16288
|
-
this.category = tcb.env.config.controlFlowPreventingContentProjection === "error" ?
|
|
15966
|
+
this.category = tcb.env.config.controlFlowPreventingContentProjection === "error" ? ts65.DiagnosticCategory.Error : ts65.DiagnosticCategory.Warning;
|
|
16289
15967
|
}
|
|
16290
15968
|
optional = false;
|
|
16291
15969
|
execute() {
|
|
@@ -16353,7 +16031,6 @@ var TcbControlFlowContentProjectionOp = class extends TcbOp {
|
|
|
16353
16031
|
};
|
|
16354
16032
|
|
|
16355
16033
|
// packages/compiler-cli/src/ngtsc/typecheck/src/ops/intersection_observer.js
|
|
16356
|
-
import ts80 from "typescript";
|
|
16357
16034
|
var TcbIntersectionObserverOp = class extends TcbOp {
|
|
16358
16035
|
tcb;
|
|
16359
16036
|
scope;
|
|
@@ -16367,9 +16044,7 @@ var TcbIntersectionObserverOp = class extends TcbOp {
|
|
|
16367
16044
|
optional = false;
|
|
16368
16045
|
execute() {
|
|
16369
16046
|
const options = tcbExpression(this.options, this.tcb, this.scope);
|
|
16370
|
-
|
|
16371
|
-
const expression = ts80.factory.createNewExpression(ts80.factory.createIdentifier("IntersectionObserver"), void 0, [callback, options]);
|
|
16372
|
-
this.scope.addStatement(ts80.factory.createExpressionStatement(expression));
|
|
16047
|
+
this.scope.addStatement(new TcbExpr(`new IntersectionObserver(null!, ${options.print()})`));
|
|
16373
16048
|
return null;
|
|
16374
16049
|
}
|
|
16375
16050
|
};
|
|
@@ -16388,10 +16063,16 @@ var TcbHostElementOp = class extends TcbOp {
|
|
|
16388
16063
|
}
|
|
16389
16064
|
execute() {
|
|
16390
16065
|
const id = this.tcb.allocateId();
|
|
16391
|
-
|
|
16392
|
-
|
|
16393
|
-
|
|
16394
|
-
|
|
16066
|
+
let tagNames;
|
|
16067
|
+
if (this.element.tagNames.length === 1) {
|
|
16068
|
+
tagNames = `"${this.element.tagNames[0]}"`;
|
|
16069
|
+
} else {
|
|
16070
|
+
tagNames = `null! as ${this.element.tagNames.map((t) => `"${t}"`).join(" | ")}`;
|
|
16071
|
+
}
|
|
16072
|
+
const initializer = new TcbExpr(`document.createElement(${tagNames})`);
|
|
16073
|
+
initializer.addParseSpanInfo(this.element.sourceSpan);
|
|
16074
|
+
this.scope.addStatement(new TcbExpr(`var ${id} = ${initializer.print()}`));
|
|
16075
|
+
return new TcbExpr(id);
|
|
16395
16076
|
}
|
|
16396
16077
|
};
|
|
16397
16078
|
|
|
@@ -16403,7 +16084,7 @@ var Scope = class _Scope {
|
|
|
16403
16084
|
/**
|
|
16404
16085
|
* A queue of operations which need to be performed to generate the TCB code for this scope.
|
|
16405
16086
|
*
|
|
16406
|
-
* This array can contain either a `TcbOp` which has yet to be executed, or a `
|
|
16087
|
+
* This array can contain either a `TcbOp` which has yet to be executed, or a `TcbExpr|null`
|
|
16407
16088
|
* representing the memoized result of executing the operation. As operations are executed, their
|
|
16408
16089
|
* results are written into the `opQueue`, overwriting the original operation.
|
|
16409
16090
|
*
|
|
@@ -16463,12 +16144,12 @@ var Scope = class _Scope {
|
|
|
16463
16144
|
*/
|
|
16464
16145
|
static getForLoopContextVariableTypes() {
|
|
16465
16146
|
return /* @__PURE__ */ new Map([
|
|
16466
|
-
["$first",
|
|
16467
|
-
["$last",
|
|
16468
|
-
["$even",
|
|
16469
|
-
["$odd",
|
|
16470
|
-
["$index",
|
|
16471
|
-
["$count",
|
|
16147
|
+
["$first", "boolean"],
|
|
16148
|
+
["$last", "boolean"],
|
|
16149
|
+
["$even", "boolean"],
|
|
16150
|
+
["$odd", "boolean"],
|
|
16151
|
+
["$index", "number"],
|
|
16152
|
+
["$count", "number"]
|
|
16472
16153
|
]);
|
|
16473
16154
|
}
|
|
16474
16155
|
constructor(tcb, parent = null, guard = null) {
|
|
@@ -16509,15 +16190,15 @@ var Scope = class _Scope {
|
|
|
16509
16190
|
_Scope.registerVariable(scope, expressionAlias, new TcbBlockVariableOp(tcb, scope, tcbExpression(expression, tcb, scope), expressionAlias));
|
|
16510
16191
|
}
|
|
16511
16192
|
} else if (scopedNode instanceof TmplAstForLoopBlock2) {
|
|
16512
|
-
const loopInitializer = tcb.allocateId();
|
|
16513
|
-
addParseSpanInfo(
|
|
16193
|
+
const loopInitializer = new TcbExpr(tcb.allocateId());
|
|
16194
|
+
loopInitializer.addParseSpanInfo(scopedNode.item.sourceSpan);
|
|
16514
16195
|
scope.varMap.set(scopedNode.item, loopInitializer);
|
|
16515
16196
|
const forLoopContextVariableTypes = _Scope.getForLoopContextVariableTypes();
|
|
16516
16197
|
for (const variable of scopedNode.contextVariables) {
|
|
16517
16198
|
if (!forLoopContextVariableTypes.has(variable.value)) {
|
|
16518
16199
|
throw new Error(`Unrecognized for loop context variable ${variable.name}`);
|
|
16519
16200
|
}
|
|
16520
|
-
const type =
|
|
16201
|
+
const type = new TcbExpr(forLoopContextVariableTypes.get(variable.value));
|
|
16521
16202
|
_Scope.registerVariable(scope, variable, new TcbBlockImplicitVariableOp(tcb, scope, type, variable));
|
|
16522
16203
|
}
|
|
16523
16204
|
} else if (scopedNode instanceof TmplAstHostElement5) {
|
|
@@ -16563,17 +16244,7 @@ var Scope = class _Scope {
|
|
|
16563
16244
|
resolve(node, directive) {
|
|
16564
16245
|
const res = this.resolveLocal(node, directive);
|
|
16565
16246
|
if (res !== null) {
|
|
16566
|
-
|
|
16567
|
-
if (ts81.isIdentifier(res)) {
|
|
16568
|
-
clone = ts81.factory.createIdentifier(res.text);
|
|
16569
|
-
} else if (ts81.isNonNullExpression(res)) {
|
|
16570
|
-
clone = ts81.factory.createNonNullExpression(res.expression);
|
|
16571
|
-
} else {
|
|
16572
|
-
throw new Error(`Could not resolve ${node} to an Identifier or a NonNullExpression`);
|
|
16573
|
-
}
|
|
16574
|
-
ts81.setOriginalNode(clone, res);
|
|
16575
|
-
clone.parent = clone.parent;
|
|
16576
|
-
return ts81.setSyntheticTrailingComments(clone, []);
|
|
16247
|
+
return res;
|
|
16577
16248
|
} else if (this.parent !== null) {
|
|
16578
16249
|
return this.parent.resolve(node, directive);
|
|
16579
16250
|
} else {
|
|
@@ -16608,9 +16279,10 @@ var Scope = class _Scope {
|
|
|
16608
16279
|
if (this.guard === null) {
|
|
16609
16280
|
return parentGuards;
|
|
16610
16281
|
} else if (parentGuards === null) {
|
|
16611
|
-
return this.guard;
|
|
16282
|
+
return typeof this.guard === "string" ? new TcbExpr(this.guard) : this.guard;
|
|
16612
16283
|
} else {
|
|
16613
|
-
|
|
16284
|
+
const guard = typeof this.guard === "string" ? this.guard : this.guard.print();
|
|
16285
|
+
return new TcbExpr(`(${parentGuards.print()}) && (${guard})`);
|
|
16614
16286
|
}
|
|
16615
16287
|
}
|
|
16616
16288
|
/** Returns whether a template symbol is defined locally within the current scope. */
|
|
@@ -16644,7 +16316,10 @@ var Scope = class _Scope {
|
|
|
16644
16316
|
return this.resolveOp(this.letDeclOpMap.get(ref.name).opIndex);
|
|
16645
16317
|
} else if (ref instanceof TmplAstVariable2 && this.varMap.has(ref)) {
|
|
16646
16318
|
const opIndexOrNode = this.varMap.get(ref);
|
|
16647
|
-
return typeof opIndexOrNode === "number" ? this.resolveOp(opIndexOrNode) : opIndexOrNode
|
|
16319
|
+
return typeof opIndexOrNode === "number" ? this.resolveOp(opIndexOrNode) : new TcbExpr(opIndexOrNode.print(
|
|
16320
|
+
true
|
|
16321
|
+
/* ignoreComments */
|
|
16322
|
+
));
|
|
16648
16323
|
} else if (ref instanceof TmplAstTemplate5 && directive === void 0 && this.templateCtxOpMap.has(ref)) {
|
|
16649
16324
|
return this.resolveOp(this.templateCtxOpMap.get(ref));
|
|
16650
16325
|
} else if ((ref instanceof TmplAstElement8 || ref instanceof TmplAstTemplate5 || ref instanceof TmplAstComponent3 || ref instanceof TmplAstDirective2 || ref instanceof TmplAstHostElement5) && directive !== void 0 && this.directiveOpMap.has(ref)) {
|
|
@@ -16661,7 +16336,7 @@ var Scope = class _Scope {
|
|
|
16661
16336
|
}
|
|
16662
16337
|
}
|
|
16663
16338
|
/**
|
|
16664
|
-
* Like `executeOp`, but assert that the operation actually returned `
|
|
16339
|
+
* Like `executeOp`, but assert that the operation actually returned `TcbExpr`.
|
|
16665
16340
|
*/
|
|
16666
16341
|
resolveOp(opIndex) {
|
|
16667
16342
|
const res = this.executeOp(
|
|
@@ -16684,13 +16359,22 @@ var Scope = class _Scope {
|
|
|
16684
16359
|
executeOp(opIndex, skipOptional) {
|
|
16685
16360
|
const op = this.opQueue[opIndex];
|
|
16686
16361
|
if (!(op instanceof TcbOp)) {
|
|
16687
|
-
return op
|
|
16362
|
+
return op === null ? null : new TcbExpr(op.print(
|
|
16363
|
+
true
|
|
16364
|
+
/* ignoreComments */
|
|
16365
|
+
));
|
|
16688
16366
|
}
|
|
16689
16367
|
if (skipOptional && op.optional) {
|
|
16690
16368
|
return null;
|
|
16691
16369
|
}
|
|
16692
16370
|
this.opQueue[opIndex] = op.circularFallback();
|
|
16693
|
-
|
|
16371
|
+
let res = op.execute();
|
|
16372
|
+
if (res !== null) {
|
|
16373
|
+
res = new TcbExpr(res.print(
|
|
16374
|
+
true
|
|
16375
|
+
/* ignoreComments */
|
|
16376
|
+
));
|
|
16377
|
+
}
|
|
16694
16378
|
this.opQueue[opIndex] = res;
|
|
16695
16379
|
return res;
|
|
16696
16380
|
}
|
|
@@ -17070,7 +16754,7 @@ var Scope = class _Scope {
|
|
|
17070
16754
|
function generateTypeCheckBlock(env, ref, name, meta, domSchemaChecker, oobRecorder, genericContextBehavior) {
|
|
17071
16755
|
const tcb = new Context2(env, domSchemaChecker, oobRecorder, meta.id, meta.boundTarget, meta.pipes, meta.schemas, meta.isStandalone, meta.preserveWhitespaces);
|
|
17072
16756
|
const ctxRawType = env.referenceType(ref);
|
|
17073
|
-
if (!
|
|
16757
|
+
if (!ts66.isTypeReferenceNode(ctxRawType)) {
|
|
17074
16758
|
throw new Error(`Expected TypeReferenceNode when referencing the ctx param for ${ref.debugName}`);
|
|
17075
16759
|
}
|
|
17076
16760
|
let typeParameters = void 0;
|
|
@@ -17081,19 +16765,23 @@ function generateTypeCheckBlock(env, ref, name, meta, domSchemaChecker, oobRecor
|
|
|
17081
16765
|
}
|
|
17082
16766
|
switch (genericContextBehavior) {
|
|
17083
16767
|
case TcbGenericContextBehavior.UseEmitter:
|
|
17084
|
-
typeParameters = new TypeParameterEmitter(ref.node.typeParameters, env.reflector).emit((
|
|
17085
|
-
typeArguments = typeParameters.map((param) =>
|
|
16768
|
+
typeParameters = new TypeParameterEmitter(ref.node.typeParameters, env.reflector).emit((typeRef2) => env.referenceType(typeRef2));
|
|
16769
|
+
typeArguments = typeParameters.map((param) => ts66.factory.createTypeReferenceNode(param.name));
|
|
17086
16770
|
break;
|
|
17087
16771
|
case TcbGenericContextBehavior.CopyClassNodes:
|
|
17088
16772
|
typeParameters = [...ref.node.typeParameters];
|
|
17089
|
-
typeArguments = typeParameters.map((param) =>
|
|
16773
|
+
typeArguments = typeParameters.map((param) => ts66.factory.createTypeReferenceNode(param.name));
|
|
17090
16774
|
break;
|
|
17091
16775
|
case TcbGenericContextBehavior.FallbackToAny:
|
|
17092
|
-
typeArguments = ref.node.typeParameters.map(() =>
|
|
16776
|
+
typeArguments = ref.node.typeParameters.map(() => ts66.factory.createKeywordTypeNode(ts66.SyntaxKind.AnyKeyword));
|
|
17093
16777
|
break;
|
|
17094
16778
|
}
|
|
17095
16779
|
}
|
|
17096
|
-
const
|
|
16780
|
+
const sourceFile = env.contextFile;
|
|
16781
|
+
const typeParamsStr = typeParameters === void 0 || typeParameters.length === 0 ? "" : `<${typeParameters.map((p) => tempPrint(p, sourceFile)).join(", ")}>`;
|
|
16782
|
+
const typeArgsStr = typeArguments === void 0 || typeArguments.length === 0 ? "" : `<${typeArguments.map((p) => tempPrint(p, sourceFile)).join(", ")}>`;
|
|
16783
|
+
const typeRef = ts66.isIdentifier(ctxRawType.typeName) ? ctxRawType.typeName.text : tempPrint(ctxRawType.typeName, sourceFile);
|
|
16784
|
+
const thisParamStr = `this: ${typeRef}${typeArgsStr}`;
|
|
17097
16785
|
const statements = [];
|
|
17098
16786
|
if (tcb.boundTarget.target.template !== void 0) {
|
|
17099
16787
|
const templateScope = Scope.forNodes(
|
|
@@ -17104,56 +16792,29 @@ function generateTypeCheckBlock(env, ref, name, meta, domSchemaChecker, oobRecor
|
|
|
17104
16792
|
/* guard */
|
|
17105
16793
|
null
|
|
17106
16794
|
);
|
|
17107
|
-
statements.push(renderBlockStatements(env, templateScope,
|
|
16795
|
+
statements.push(renderBlockStatements(env, templateScope, "true"));
|
|
17108
16796
|
}
|
|
17109
16797
|
if (tcb.boundTarget.target.host !== void 0) {
|
|
17110
16798
|
const hostScope = Scope.forNodes(tcb, null, tcb.boundTarget.target.host.node, null, null);
|
|
17111
16799
|
statements.push(renderBlockStatements(env, hostScope, createHostBindingsBlockGuard()));
|
|
17112
16800
|
}
|
|
17113
|
-
const
|
|
17114
|
-
|
|
17115
|
-
|
|
17116
|
-
|
|
17117
|
-
|
|
17118
|
-
|
|
17119
|
-
/* name */
|
|
17120
|
-
name,
|
|
17121
|
-
/* typeParameters */
|
|
17122
|
-
env.config.useContextGenericType ? typeParameters : void 0,
|
|
17123
|
-
/* parameters */
|
|
17124
|
-
paramList,
|
|
17125
|
-
/* type */
|
|
17126
|
-
void 0,
|
|
17127
|
-
/* body */
|
|
17128
|
-
body
|
|
17129
|
-
);
|
|
17130
|
-
addTypeCheckId(fnDecl, meta.id);
|
|
17131
|
-
return fnDecl;
|
|
16801
|
+
const bodyStr = `{
|
|
16802
|
+
${statements.join("\n")}
|
|
16803
|
+
}`;
|
|
16804
|
+
const funcDeclStr = `function ${name.text}${typeParamsStr}(${thisParamStr}) ${bodyStr}`;
|
|
16805
|
+
return `/*${meta.id}*/
|
|
16806
|
+
${funcDeclStr}`;
|
|
17132
16807
|
}
|
|
17133
16808
|
function renderBlockStatements(env, scope, wrapperExpression) {
|
|
17134
16809
|
const scopeStatements = scope.render();
|
|
17135
|
-
const
|
|
17136
|
-
return
|
|
17137
|
-
}
|
|
17138
|
-
|
|
17139
|
-
return ts82.factory.createParameterDeclaration(
|
|
17140
|
-
/* modifiers */
|
|
17141
|
-
void 0,
|
|
17142
|
-
/* dotDotDotToken */
|
|
17143
|
-
void 0,
|
|
17144
|
-
/* name */
|
|
17145
|
-
"this",
|
|
17146
|
-
/* questionToken */
|
|
17147
|
-
void 0,
|
|
17148
|
-
/* type */
|
|
17149
|
-
ts82.factory.createTypeReferenceNode(name, typeArguments),
|
|
17150
|
-
/* initializer */
|
|
17151
|
-
void 0
|
|
17152
|
-
);
|
|
16810
|
+
const statements = getStatementsBlock([...env.getPreludeStatements(), ...scopeStatements]);
|
|
16811
|
+
return `if (${wrapperExpression}) {
|
|
16812
|
+
${statements}
|
|
16813
|
+
}`;
|
|
17153
16814
|
}
|
|
17154
16815
|
|
|
17155
16816
|
// packages/compiler-cli/src/ngtsc/typecheck/src/type_check_file.js
|
|
17156
|
-
import
|
|
16817
|
+
import ts67 from "typescript";
|
|
17157
16818
|
var TypeCheckFile = class extends Environment {
|
|
17158
16819
|
fileName;
|
|
17159
16820
|
nextTcbId = 1;
|
|
@@ -17165,36 +16826,32 @@ var TypeCheckFile = class extends Environment {
|
|
|
17165
16826
|
// Type check block code affects code completion and fix suggestions.
|
|
17166
16827
|
// We want to encourage single quotes for now, like we always did.
|
|
17167
16828
|
shouldUseSingleQuotes: () => true
|
|
17168
|
-
}), refEmitter, reflector,
|
|
16829
|
+
}), refEmitter, reflector, ts67.createSourceFile(compilerHost.getCanonicalFileName(fileName), "", ts67.ScriptTarget.Latest, true));
|
|
17169
16830
|
this.fileName = fileName;
|
|
17170
16831
|
}
|
|
17171
16832
|
addTypeCheckBlock(ref, meta, domSchemaChecker, oobRecorder, genericContextBehavior) {
|
|
17172
|
-
const fnId =
|
|
16833
|
+
const fnId = ts67.factory.createIdentifier(`_tcb${this.nextTcbId++}`);
|
|
17173
16834
|
const fn = generateTypeCheckBlock(this, ref, fnId, meta, domSchemaChecker, oobRecorder, genericContextBehavior);
|
|
17174
16835
|
this.tcbStatements.push(fn);
|
|
17175
16836
|
}
|
|
17176
|
-
render(
|
|
16837
|
+
render() {
|
|
17177
16838
|
ensureTypeCheckFilePreparationImports(this);
|
|
17178
16839
|
const importChanges = this.importManager.finalize();
|
|
17179
16840
|
if (importChanges.updatedImports.size > 0) {
|
|
17180
16841
|
throw new Error("AssertionError: Expected no imports to be updated for a new type check file.");
|
|
17181
16842
|
}
|
|
17182
|
-
const printer =
|
|
16843
|
+
const printer = ts67.createPrinter();
|
|
17183
16844
|
let source = "";
|
|
17184
16845
|
const newImports = importChanges.newImports.get(this.contextFile.fileName);
|
|
17185
16846
|
if (newImports !== void 0) {
|
|
17186
|
-
source += newImports.map((i) => printer.printNode(
|
|
16847
|
+
source += newImports.map((i) => printer.printNode(ts67.EmitHint.Unspecified, i, this.contextFile)).join("\n");
|
|
17187
16848
|
}
|
|
17188
16849
|
source += "\n";
|
|
17189
|
-
|
|
17190
|
-
|
|
17191
|
-
}
|
|
17192
|
-
for (const stmt of this.typeCtorStatements) {
|
|
17193
|
-
source += printer.printNode(ts83.EmitHint.Unspecified, stmt, this.contextFile) + "\n";
|
|
17194
|
-
}
|
|
16850
|
+
source += getStatementsBlock(this.pipeInstStatements);
|
|
16851
|
+
source += getStatementsBlock(this.typeCtorStatements);
|
|
17195
16852
|
source += "\n";
|
|
17196
16853
|
for (const stmt of this.tcbStatements) {
|
|
17197
|
-
source +=
|
|
16854
|
+
source += stmt + "\n";
|
|
17198
16855
|
}
|
|
17199
16856
|
source += "\nexport const IS_A_MODULE = true;\n";
|
|
17200
16857
|
return source;
|
|
@@ -17360,7 +17017,7 @@ var TypeCheckContextImpl = class {
|
|
|
17360
17017
|
if (!this.opMap.has(sf)) {
|
|
17361
17018
|
return null;
|
|
17362
17019
|
}
|
|
17363
|
-
const printer =
|
|
17020
|
+
const printer = ts68.createPrinter({ omitTrailingSemicolon: true });
|
|
17364
17021
|
const importManager = new ImportManager({
|
|
17365
17022
|
// This minimizes noticeable changes with older versions of `ImportManager`.
|
|
17366
17023
|
forceGenerateNamespacesForNewImports: true,
|
|
@@ -17371,7 +17028,7 @@ var TypeCheckContextImpl = class {
|
|
|
17371
17028
|
const updates = this.opMap.get(sf).map((op) => {
|
|
17372
17029
|
return {
|
|
17373
17030
|
pos: op.splitPoint,
|
|
17374
|
-
text: op.execute(importManager, sf, this.refEmitter
|
|
17031
|
+
text: op.execute(importManager, sf, this.refEmitter)
|
|
17375
17032
|
};
|
|
17376
17033
|
});
|
|
17377
17034
|
const { newImports, updatedImports } = importManager.finalize();
|
|
@@ -17379,7 +17036,7 @@ var TypeCheckContextImpl = class {
|
|
|
17379
17036
|
newImports.get(sf.fileName).forEach((newImport) => {
|
|
17380
17037
|
updates.push({
|
|
17381
17038
|
pos: 0,
|
|
17382
|
-
text: printer.printNode(
|
|
17039
|
+
text: printer.printNode(ts68.EmitHint.Unspecified, newImport, sf)
|
|
17383
17040
|
});
|
|
17384
17041
|
});
|
|
17385
17042
|
}
|
|
@@ -17390,7 +17047,7 @@ var TypeCheckContextImpl = class {
|
|
|
17390
17047
|
updates.push({
|
|
17391
17048
|
pos: oldBindings.getStart(),
|
|
17392
17049
|
deletePos: oldBindings.getEnd(),
|
|
17393
|
-
text: printer.printNode(
|
|
17050
|
+
text: printer.printNode(ts68.EmitHint.Unspecified, newBindings, sf)
|
|
17394
17051
|
});
|
|
17395
17052
|
}
|
|
17396
17053
|
const result = new MagicString(sf.text, { filename: sf.fileName });
|
|
@@ -17424,10 +17081,7 @@ var TypeCheckContextImpl = class {
|
|
|
17424
17081
|
path: pendingShimData.file.fileName,
|
|
17425
17082
|
data: pendingShimData.data
|
|
17426
17083
|
});
|
|
17427
|
-
const sfText = pendingShimData.file.render(
|
|
17428
|
-
false
|
|
17429
|
-
/* removeComments */
|
|
17430
|
-
);
|
|
17084
|
+
const sfText = pendingShimData.file.render();
|
|
17431
17085
|
updates.set(pendingShimData.file.fileName, {
|
|
17432
17086
|
newText: sfText,
|
|
17433
17087
|
// Shim files do not have an associated original file.
|
|
@@ -17478,7 +17132,7 @@ function getTemplateDiagnostics(parseErrors, templateId, sourceMapping) {
|
|
|
17478
17132
|
if (span.start.offset === span.end.offset) {
|
|
17479
17133
|
span.end.offset++;
|
|
17480
17134
|
}
|
|
17481
|
-
return makeTemplateDiagnostic(templateId, sourceMapping, span,
|
|
17135
|
+
return makeTemplateDiagnostic(templateId, sourceMapping, span, ts68.DiagnosticCategory.Error, ngErrorCode(ErrorCode.TEMPLATE_PARSE_ERROR), error.msg);
|
|
17482
17136
|
});
|
|
17483
17137
|
}
|
|
17484
17138
|
var InlineTcbOp = class {
|
|
@@ -17502,11 +17156,11 @@ var InlineTcbOp = class {
|
|
|
17502
17156
|
get splitPoint() {
|
|
17503
17157
|
return this.ref.node.end + 1;
|
|
17504
17158
|
}
|
|
17505
|
-
execute(im, sf, refEmitter
|
|
17159
|
+
execute(im, sf, refEmitter) {
|
|
17506
17160
|
const env = new Environment(this.config, im, refEmitter, this.reflector, sf);
|
|
17507
|
-
const fnName =
|
|
17161
|
+
const fnName = ts68.factory.createIdentifier(`_tcb_${this.ref.node.pos}`);
|
|
17508
17162
|
const fn = generateTypeCheckBlock(env, this.ref, fnName, this.meta, this.domSchemaChecker, this.oobRecorder, TcbGenericContextBehavior.CopyClassNodes);
|
|
17509
|
-
return
|
|
17163
|
+
return fn;
|
|
17510
17164
|
}
|
|
17511
17165
|
};
|
|
17512
17166
|
var TypeCtorOp = class {
|
|
@@ -17524,13 +17178,49 @@ var TypeCtorOp = class {
|
|
|
17524
17178
|
get splitPoint() {
|
|
17525
17179
|
return this.ref.node.end - 1;
|
|
17526
17180
|
}
|
|
17527
|
-
execute(im, sf, refEmitter
|
|
17181
|
+
execute(im, sf, refEmitter) {
|
|
17528
17182
|
const emitEnv = new ReferenceEmitEnvironment(im, refEmitter, this.reflector, sf);
|
|
17529
|
-
|
|
17530
|
-
return printer.printNode(ts84.EmitHint.Unspecified, tcb, sf);
|
|
17183
|
+
return generateInlineTypeCtor(emitEnv, this.ref.node, this.meta);
|
|
17531
17184
|
}
|
|
17532
17185
|
};
|
|
17533
17186
|
|
|
17187
|
+
// packages/compiler-cli/src/ngtsc/typecheck/src/diagnostics.js
|
|
17188
|
+
import { AbsoluteSourceSpan as AbsoluteSourceSpan5 } from "@angular/compiler";
|
|
17189
|
+
import ts69 from "typescript";
|
|
17190
|
+
function shouldReportDiagnostic(diagnostic) {
|
|
17191
|
+
const { code } = diagnostic;
|
|
17192
|
+
if (code === 6133) {
|
|
17193
|
+
return false;
|
|
17194
|
+
} else if (code === 6199) {
|
|
17195
|
+
return false;
|
|
17196
|
+
} else if (code === 2695) {
|
|
17197
|
+
return false;
|
|
17198
|
+
} else if (code === 7006) {
|
|
17199
|
+
return false;
|
|
17200
|
+
}
|
|
17201
|
+
return true;
|
|
17202
|
+
}
|
|
17203
|
+
function translateDiagnostic(diagnostic, resolver) {
|
|
17204
|
+
if (diagnostic.file === void 0 || diagnostic.start === void 0) {
|
|
17205
|
+
return null;
|
|
17206
|
+
}
|
|
17207
|
+
const fullMapping = getSourceMapping(
|
|
17208
|
+
diagnostic.file,
|
|
17209
|
+
diagnostic.start,
|
|
17210
|
+
resolver,
|
|
17211
|
+
/*isDiagnosticsRequest*/
|
|
17212
|
+
true
|
|
17213
|
+
);
|
|
17214
|
+
if (fullMapping === null) {
|
|
17215
|
+
return null;
|
|
17216
|
+
}
|
|
17217
|
+
const { sourceLocation, sourceMapping: templateSourceMapping, span } = fullMapping;
|
|
17218
|
+
return makeTemplateDiagnostic(sourceLocation.id, templateSourceMapping, span, diagnostic.category, diagnostic.code, diagnostic.messageText, void 0, diagnostic.reportsDeprecated !== void 0 ? {
|
|
17219
|
+
reportsDeprecated: diagnostic.reportsDeprecated,
|
|
17220
|
+
relatedMessages: diagnostic.relatedInformation
|
|
17221
|
+
} : void 0);
|
|
17222
|
+
}
|
|
17223
|
+
|
|
17534
17224
|
// packages/compiler-cli/src/ngtsc/typecheck/src/source.js
|
|
17535
17225
|
import { ParseLocation as ParseLocation2, ParseSourceSpan as ParseSourceSpan3 } from "@angular/compiler";
|
|
17536
17226
|
|
|
@@ -17649,7 +17339,7 @@ var DirectiveSourceManager = class {
|
|
|
17649
17339
|
|
|
17650
17340
|
// packages/compiler-cli/src/ngtsc/typecheck/src/template_symbol_builder.js
|
|
17651
17341
|
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";
|
|
17652
|
-
import
|
|
17342
|
+
import ts70 from "typescript";
|
|
17653
17343
|
var SymbolBuilder = class {
|
|
17654
17344
|
tcbPath;
|
|
17655
17345
|
tcbIsShim;
|
|
@@ -17706,7 +17396,7 @@ var SymbolBuilder = class {
|
|
|
17706
17396
|
const elementSourceSpan = element.startSourceSpan ?? element.sourceSpan;
|
|
17707
17397
|
const node = findFirstMatchingNode(this.typeCheckBlock, {
|
|
17708
17398
|
withSpan: elementSourceSpan,
|
|
17709
|
-
filter:
|
|
17399
|
+
filter: ts70.isVariableDeclaration
|
|
17710
17400
|
});
|
|
17711
17401
|
if (node === null) {
|
|
17712
17402
|
return null;
|
|
@@ -17763,7 +17453,7 @@ var SymbolBuilder = class {
|
|
|
17763
17453
|
const seenDirectives = /* @__PURE__ */ new Set();
|
|
17764
17454
|
for (const node of nodes) {
|
|
17765
17455
|
const symbol = this.getSymbolOfTsNode(node.parent);
|
|
17766
|
-
if (symbol === null || !isSymbolWithValueDeclaration(symbol.tsSymbol) || !
|
|
17456
|
+
if (symbol === null || !isSymbolWithValueDeclaration(symbol.tsSymbol) || !ts70.isClassDeclaration(symbol.tsSymbol.valueDeclaration)) {
|
|
17767
17457
|
continue;
|
|
17768
17458
|
}
|
|
17769
17459
|
const declaration = symbol.tsSymbol.valueDeclaration;
|
|
@@ -17798,7 +17488,7 @@ var SymbolBuilder = class {
|
|
|
17798
17488
|
throw new Error("Impossible state: typecheck code path in local compilation mode.");
|
|
17799
17489
|
}
|
|
17800
17490
|
const node = current.directive.node;
|
|
17801
|
-
if (!
|
|
17491
|
+
if (!ts70.isClassDeclaration(node) || seenDirectives.has(node)) {
|
|
17802
17492
|
continue;
|
|
17803
17493
|
}
|
|
17804
17494
|
const symbol = this.getSymbolOfTsNode(node);
|
|
@@ -17888,10 +17578,10 @@ var SymbolBuilder = class {
|
|
|
17888
17578
|
if (!isAccessExpression(n2)) {
|
|
17889
17579
|
return false;
|
|
17890
17580
|
}
|
|
17891
|
-
if (
|
|
17581
|
+
if (ts70.isPropertyAccessExpression(n2)) {
|
|
17892
17582
|
return n2.name.getText() === expectedAccess;
|
|
17893
17583
|
} else {
|
|
17894
|
-
return
|
|
17584
|
+
return ts70.isStringLiteral(n2.argumentExpression) && n2.argumentExpression.text === expectedAccess;
|
|
17895
17585
|
}
|
|
17896
17586
|
}
|
|
17897
17587
|
const outputFieldAccesses = findAllMatchingNodes(this.typeCheckBlock, {
|
|
@@ -17901,7 +17591,7 @@ var SymbolBuilder = class {
|
|
|
17901
17591
|
const bindings = [];
|
|
17902
17592
|
for (const outputFieldAccess of outputFieldAccesses) {
|
|
17903
17593
|
if (consumer instanceof TmplAstTemplate6 || consumer instanceof TmplAstElement9) {
|
|
17904
|
-
if (!
|
|
17594
|
+
if (!ts70.isPropertyAccessExpression(outputFieldAccess)) {
|
|
17905
17595
|
continue;
|
|
17906
17596
|
}
|
|
17907
17597
|
const addEventListener = outputFieldAccess.name;
|
|
@@ -17924,7 +17614,7 @@ var SymbolBuilder = class {
|
|
|
17924
17614
|
}
|
|
17925
17615
|
});
|
|
17926
17616
|
} else {
|
|
17927
|
-
if (!
|
|
17617
|
+
if (!ts70.isElementAccessExpression(outputFieldAccess)) {
|
|
17928
17618
|
continue;
|
|
17929
17619
|
}
|
|
17930
17620
|
const tsSymbol = this.getTypeChecker().getSymbolAtLocation(outputFieldAccess.argumentExpression);
|
|
@@ -17977,7 +17667,7 @@ var SymbolBuilder = class {
|
|
|
17977
17667
|
let fieldAccessExpr;
|
|
17978
17668
|
let symbolInfo = null;
|
|
17979
17669
|
if (signalInputAssignment !== null) {
|
|
17980
|
-
if (
|
|
17670
|
+
if (ts70.isIdentifier(signalInputAssignment.fieldExpr)) {
|
|
17981
17671
|
continue;
|
|
17982
17672
|
}
|
|
17983
17673
|
const fieldSymbol = this.getSymbolOfTsNode(signalInputAssignment.fieldExpr);
|
|
@@ -18017,7 +17707,7 @@ var SymbolBuilder = class {
|
|
|
18017
17707
|
return null;
|
|
18018
17708
|
}
|
|
18019
17709
|
const [declaration] = tsSymbol.declarations;
|
|
18020
|
-
if (!
|
|
17710
|
+
if (!ts70.isVariableDeclaration(declaration) || !hasExpressionIdentifier(
|
|
18021
17711
|
// The expression identifier could be on the type (for regular directives) or the name
|
|
18022
17712
|
// (for generic directives and the ctor op).
|
|
18023
17713
|
declaration.getSourceFile(),
|
|
@@ -18027,7 +17717,7 @@ var SymbolBuilder = class {
|
|
|
18027
17717
|
return null;
|
|
18028
17718
|
}
|
|
18029
17719
|
const symbol = this.getSymbolOfTsNode(declaration);
|
|
18030
|
-
if (symbol === null || !isSymbolWithValueDeclaration(symbol.tsSymbol) || !
|
|
17720
|
+
if (symbol === null || !isSymbolWithValueDeclaration(symbol.tsSymbol) || !ts70.isClassDeclaration(symbol.tsSymbol.valueDeclaration)) {
|
|
18031
17721
|
return null;
|
|
18032
17722
|
}
|
|
18033
17723
|
const ref = new Reference(symbol.tsSymbol.valueDeclaration);
|
|
@@ -18051,13 +17741,13 @@ var SymbolBuilder = class {
|
|
|
18051
17741
|
getSymbolOfVariable(variable) {
|
|
18052
17742
|
const node = findFirstMatchingNode(this.typeCheckBlock, {
|
|
18053
17743
|
withSpan: variable.sourceSpan,
|
|
18054
|
-
filter:
|
|
17744
|
+
filter: ts70.isVariableDeclaration
|
|
18055
17745
|
});
|
|
18056
17746
|
if (node === null) {
|
|
18057
17747
|
return null;
|
|
18058
17748
|
}
|
|
18059
17749
|
let nodeValueSymbol = null;
|
|
18060
|
-
if (
|
|
17750
|
+
if (ts70.isForOfStatement(node.parent.parent)) {
|
|
18061
17751
|
nodeValueSymbol = this.getSymbolOfTsNode(node);
|
|
18062
17752
|
} else if (node.initializer !== void 0) {
|
|
18063
17753
|
nodeValueSymbol = this.getSymbolOfTsNode(node.initializer);
|
|
@@ -18082,12 +17772,12 @@ var SymbolBuilder = class {
|
|
|
18082
17772
|
const target = this.typeCheckData.boundTarget.getReferenceTarget(ref);
|
|
18083
17773
|
let node = findFirstMatchingNode(this.typeCheckBlock, {
|
|
18084
17774
|
withSpan: ref.sourceSpan,
|
|
18085
|
-
filter:
|
|
17775
|
+
filter: ts70.isVariableDeclaration
|
|
18086
17776
|
});
|
|
18087
17777
|
if (node === null || target === null || node.initializer === void 0) {
|
|
18088
17778
|
return null;
|
|
18089
17779
|
}
|
|
18090
|
-
const originalDeclaration =
|
|
17780
|
+
const originalDeclaration = ts70.isParenthesizedExpression(node.initializer) && ts70.isAsExpression(node.initializer.expression) ? this.getTypeChecker().getSymbolAtLocation(node.name) : this.getTypeChecker().getSymbolAtLocation(node.initializer);
|
|
18091
17781
|
if (originalDeclaration === void 0 || originalDeclaration.valueDeclaration === void 0) {
|
|
18092
17782
|
return null;
|
|
18093
17783
|
}
|
|
@@ -18111,7 +17801,7 @@ var SymbolBuilder = class {
|
|
|
18111
17801
|
referenceVarLocation: referenceVarTcbLocation
|
|
18112
17802
|
};
|
|
18113
17803
|
} else {
|
|
18114
|
-
if (!
|
|
17804
|
+
if (!ts70.isClassDeclaration(target.directive.ref.node)) {
|
|
18115
17805
|
return null;
|
|
18116
17806
|
}
|
|
18117
17807
|
return {
|
|
@@ -18128,7 +17818,7 @@ var SymbolBuilder = class {
|
|
|
18128
17818
|
getSymbolOfLetDeclaration(decl) {
|
|
18129
17819
|
const node = findFirstMatchingNode(this.typeCheckBlock, {
|
|
18130
17820
|
withSpan: decl.sourceSpan,
|
|
18131
|
-
filter:
|
|
17821
|
+
filter: ts70.isVariableDeclaration
|
|
18132
17822
|
});
|
|
18133
17823
|
if (node === null) {
|
|
18134
17824
|
return null;
|
|
@@ -18153,7 +17843,7 @@ var SymbolBuilder = class {
|
|
|
18153
17843
|
getSymbolOfPipe(expression) {
|
|
18154
17844
|
const methodAccess = findFirstMatchingNode(this.typeCheckBlock, {
|
|
18155
17845
|
withSpan: expression.nameSpan,
|
|
18156
|
-
filter:
|
|
17846
|
+
filter: ts70.isPropertyAccessExpression
|
|
18157
17847
|
});
|
|
18158
17848
|
if (methodAccess === null) {
|
|
18159
17849
|
return null;
|
|
@@ -18198,7 +17888,7 @@ var SymbolBuilder = class {
|
|
|
18198
17888
|
if (expression instanceof PropertyRead8) {
|
|
18199
17889
|
node = findFirstMatchingNode(this.typeCheckBlock, {
|
|
18200
17890
|
withSpan,
|
|
18201
|
-
filter:
|
|
17891
|
+
filter: ts70.isPropertyAccessExpression
|
|
18202
17892
|
});
|
|
18203
17893
|
}
|
|
18204
17894
|
if (node === null) {
|
|
@@ -18207,10 +17897,10 @@ var SymbolBuilder = class {
|
|
|
18207
17897
|
if (node === null) {
|
|
18208
17898
|
return null;
|
|
18209
17899
|
}
|
|
18210
|
-
while (
|
|
17900
|
+
while (ts70.isParenthesizedExpression(node)) {
|
|
18211
17901
|
node = node.expression;
|
|
18212
17902
|
}
|
|
18213
|
-
if (expression instanceof SafePropertyRead4 &&
|
|
17903
|
+
if (expression instanceof SafePropertyRead4 && ts70.isConditionalExpression(node)) {
|
|
18214
17904
|
const whenTrueSymbol = this.getSymbolOfTsNode(node.whenTrue);
|
|
18215
17905
|
if (whenTrueSymbol === null) {
|
|
18216
17906
|
return null;
|
|
@@ -18228,13 +17918,13 @@ var SymbolBuilder = class {
|
|
|
18228
17918
|
}
|
|
18229
17919
|
}
|
|
18230
17920
|
getSymbolOfTsNode(node) {
|
|
18231
|
-
while (
|
|
17921
|
+
while (ts70.isParenthesizedExpression(node)) {
|
|
18232
17922
|
node = node.expression;
|
|
18233
17923
|
}
|
|
18234
17924
|
let tsSymbol;
|
|
18235
|
-
if (
|
|
17925
|
+
if (ts70.isPropertyAccessExpression(node)) {
|
|
18236
17926
|
tsSymbol = this.getTypeChecker().getSymbolAtLocation(node.name);
|
|
18237
|
-
} else if (
|
|
17927
|
+
} else if (ts70.isCallExpression(node)) {
|
|
18238
17928
|
tsSymbol = this.getTypeChecker().getSymbolAtLocation(node.expression);
|
|
18239
17929
|
} else {
|
|
18240
17930
|
tsSymbol = this.getTypeChecker().getSymbolAtLocation(node);
|
|
@@ -18255,13 +17945,13 @@ var SymbolBuilder = class {
|
|
|
18255
17945
|
};
|
|
18256
17946
|
}
|
|
18257
17947
|
getTcbPositionForNode(node) {
|
|
18258
|
-
if (
|
|
17948
|
+
if (ts70.isTypeReferenceNode(node)) {
|
|
18259
17949
|
return this.getTcbPositionForNode(node.typeName);
|
|
18260
|
-
} else if (
|
|
17950
|
+
} else if (ts70.isQualifiedName(node)) {
|
|
18261
17951
|
return node.right.getStart();
|
|
18262
|
-
} else if (
|
|
17952
|
+
} else if (ts70.isPropertyAccessExpression(node)) {
|
|
18263
17953
|
return node.name.getStart();
|
|
18264
|
-
} else if (
|
|
17954
|
+
} else if (ts70.isElementAccessExpression(node)) {
|
|
18265
17955
|
return node.argumentExpression.getStart();
|
|
18266
17956
|
} else {
|
|
18267
17957
|
return node.getStart();
|
|
@@ -18275,13 +17965,13 @@ function sourceSpanEqual(a, b) {
|
|
|
18275
17965
|
return a.start.offset === b.start.offset && a.end.offset === b.end.offset;
|
|
18276
17966
|
}
|
|
18277
17967
|
function unwrapSignalInputWriteTAccessor(expr) {
|
|
18278
|
-
if (!
|
|
17968
|
+
if (!ts70.isElementAccessExpression(expr) || !ts70.isPropertyAccessExpression(expr.argumentExpression)) {
|
|
18279
17969
|
return null;
|
|
18280
17970
|
}
|
|
18281
|
-
if (!
|
|
17971
|
+
if (!ts70.isIdentifier(expr.argumentExpression.name) || expr.argumentExpression.name.text !== R3Identifiers6.InputSignalBrandWriteType.name) {
|
|
18282
17972
|
return null;
|
|
18283
17973
|
}
|
|
18284
|
-
if (!
|
|
17974
|
+
if (!ts70.isPropertyAccessExpression(expr.expression) && !ts70.isElementAccessExpression(expr.expression) && !ts70.isIdentifier(expr.expression)) {
|
|
18285
17975
|
throw new Error("Unexpected expression for signal input write type.");
|
|
18286
17976
|
}
|
|
18287
17977
|
return {
|
|
@@ -18298,10 +17988,10 @@ function findMatchingDirective(originalSourceFile, directiveDeclarationInTypeChe
|
|
|
18298
17988
|
function collectClassesWithName(sourceFile, className) {
|
|
18299
17989
|
const classes = [];
|
|
18300
17990
|
function visit2(node) {
|
|
18301
|
-
if (
|
|
17991
|
+
if (ts70.isClassDeclaration(node) && node.name?.text === className) {
|
|
18302
17992
|
classes.push(node);
|
|
18303
17993
|
}
|
|
18304
|
-
|
|
17994
|
+
ts70.forEachChild(node, visit2);
|
|
18305
17995
|
}
|
|
18306
17996
|
sourceFile.forEachChild(visit2);
|
|
18307
17997
|
return classes;
|
|
@@ -19101,7 +18791,7 @@ var TemplateTypeCheckerImpl = class {
|
|
|
19101
18791
|
return null;
|
|
19102
18792
|
}
|
|
19103
18793
|
const emitted = emittedRef.expression;
|
|
19104
|
-
if (emitted instanceof
|
|
18794
|
+
if (emitted instanceof WrappedNodeExpr7) {
|
|
19105
18795
|
if (refTo.node === inContext) {
|
|
19106
18796
|
return null;
|
|
19107
18797
|
}
|
|
@@ -19330,11 +19020,11 @@ function getClassDeclFromSymbol(symbol, checker) {
|
|
|
19330
19020
|
if (decl === void 0) {
|
|
19331
19021
|
return null;
|
|
19332
19022
|
}
|
|
19333
|
-
if (
|
|
19023
|
+
if (ts71.isExportAssignment(decl)) {
|
|
19334
19024
|
const symbol2 = checker.getTypeAtLocation(decl.expression).getSymbol();
|
|
19335
19025
|
return getClassDeclFromSymbol(symbol2, checker);
|
|
19336
19026
|
}
|
|
19337
|
-
if (
|
|
19027
|
+
if (ts71.isExportSpecifier(decl)) {
|
|
19338
19028
|
const symbol2 = checker.getTypeAtLocation(decl).getSymbol();
|
|
19339
19029
|
return getClassDeclFromSymbol(symbol2, checker);
|
|
19340
19030
|
}
|
|
@@ -19367,7 +19057,7 @@ function getTheElementTagDeprecatedSuggestionDiagnostics(shimPath, program, file
|
|
|
19367
19057
|
const nodeType = typeChecker.getTypeAtLocation(diagNode);
|
|
19368
19058
|
const nodeSymbolDeclarations = nodeType.getSymbol()?.declarations;
|
|
19369
19059
|
const decl = nodeSymbolDeclarations !== void 0 && nodeSymbolDeclarations.length > 0 ? nodeSymbolDeclarations[0] : void 0;
|
|
19370
|
-
if (decl === void 0 || !
|
|
19060
|
+
if (decl === void 0 || !ts71.isClassDeclaration(decl)) {
|
|
19371
19061
|
continue;
|
|
19372
19062
|
}
|
|
19373
19063
|
const directiveForDiagnostic = templateTypeChecker.getDirectiveMetadata(decl);
|
|
@@ -19387,7 +19077,7 @@ function getTheElementTagDeprecatedSuggestionDiagnostics(shimPath, program, file
|
|
|
19387
19077
|
if (decl === void 0) {
|
|
19388
19078
|
continue;
|
|
19389
19079
|
}
|
|
19390
|
-
if (!
|
|
19080
|
+
if (!ts71.isClassDeclaration(decl)) {
|
|
19391
19081
|
continue;
|
|
19392
19082
|
}
|
|
19393
19083
|
const diagnostic = nodeToDiag.get(decl);
|
|
@@ -19666,7 +19356,7 @@ var DirectiveDecoratorHandler = class {
|
|
|
19666
19356
|
if (!this.typeCheckHostBindings) {
|
|
19667
19357
|
return;
|
|
19668
19358
|
}
|
|
19669
|
-
if (!
|
|
19359
|
+
if (!ts72.isClassDeclaration(node) || meta.isPoisoned && !this.usePoisonedData) {
|
|
19670
19360
|
return;
|
|
19671
19361
|
}
|
|
19672
19362
|
const ref = new Reference(node);
|
|
@@ -19693,7 +19383,7 @@ var DirectiveDecoratorHandler = class {
|
|
|
19693
19383
|
symbol.baseClass = this.semanticDepGraphUpdater.getSymbol(analysis.baseClass.node);
|
|
19694
19384
|
}
|
|
19695
19385
|
const diagnostics = [];
|
|
19696
|
-
if (analysis.providersRequiringFactory !== null && analysis.meta.providers instanceof
|
|
19386
|
+
if (analysis.providersRequiringFactory !== null && analysis.meta.providers instanceof WrappedNodeExpr8) {
|
|
19697
19387
|
const providerDiagnostics = getProviderDiagnostics(analysis.providersRequiringFactory, analysis.meta.providers.node, this.injectableRegistry);
|
|
19698
19388
|
diagnostics.push(...providerDiagnostics);
|
|
19699
19389
|
}
|
|
@@ -19775,17 +19465,17 @@ var DirectiveDecoratorHandler = class {
|
|
|
19775
19465
|
};
|
|
19776
19466
|
|
|
19777
19467
|
// packages/compiler-cli/src/ngtsc/annotations/ng_module/src/handler.js
|
|
19778
|
-
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
|
|
19779
|
-
import
|
|
19468
|
+
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 WrappedNodeExpr9 } from "@angular/compiler";
|
|
19469
|
+
import ts74 from "typescript";
|
|
19780
19470
|
|
|
19781
19471
|
// packages/compiler-cli/src/ngtsc/annotations/ng_module/src/module_with_providers.js
|
|
19782
|
-
import
|
|
19472
|
+
import ts73 from "typescript";
|
|
19783
19473
|
function createModuleWithProvidersResolver(reflector, isCore) {
|
|
19784
19474
|
function _reflectModuleFromTypeParam(type, node) {
|
|
19785
|
-
if (!
|
|
19475
|
+
if (!ts73.isTypeReferenceNode(type)) {
|
|
19786
19476
|
return null;
|
|
19787
19477
|
}
|
|
19788
|
-
const typeName = type && (
|
|
19478
|
+
const typeName = type && (ts73.isIdentifier(type.typeName) && type.typeName || ts73.isQualifiedName(type.typeName) && type.typeName.right) || null;
|
|
19789
19479
|
if (typeName === null) {
|
|
19790
19480
|
return null;
|
|
19791
19481
|
}
|
|
@@ -19797,7 +19487,7 @@ function createModuleWithProvidersResolver(reflector, isCore) {
|
|
|
19797
19487
|
return null;
|
|
19798
19488
|
}
|
|
19799
19489
|
if (type.typeArguments === void 0 || type.typeArguments.length !== 1) {
|
|
19800
|
-
const parent =
|
|
19490
|
+
const parent = ts73.isMethodDeclaration(node) && ts73.isClassDeclaration(node.parent) ? node.parent : null;
|
|
19801
19491
|
const symbolName = (parent && parent.name ? parent.name.getText() + "." : "") + (node.name ? node.name.getText() : "anonymous");
|
|
19802
19492
|
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.`);
|
|
19803
19493
|
}
|
|
@@ -19805,15 +19495,15 @@ function createModuleWithProvidersResolver(reflector, isCore) {
|
|
|
19805
19495
|
return typeNodeToValueExpr(arg);
|
|
19806
19496
|
}
|
|
19807
19497
|
function _reflectModuleFromLiteralType(type) {
|
|
19808
|
-
if (!
|
|
19498
|
+
if (!ts73.isIntersectionTypeNode(type)) {
|
|
19809
19499
|
return null;
|
|
19810
19500
|
}
|
|
19811
19501
|
for (const t of type.types) {
|
|
19812
|
-
if (
|
|
19502
|
+
if (ts73.isTypeLiteralNode(t)) {
|
|
19813
19503
|
for (const m of t.members) {
|
|
19814
|
-
const ngModuleType =
|
|
19504
|
+
const ngModuleType = ts73.isPropertySignature(m) && ts73.isIdentifier(m.name) && m.name.text === "ngModule" && m.type || null;
|
|
19815
19505
|
let ngModuleExpression = null;
|
|
19816
|
-
if (ngModuleType !== null &&
|
|
19506
|
+
if (ngModuleType !== null && ts73.isTypeQueryNode(ngModuleType)) {
|
|
19817
19507
|
ngModuleExpression = entityNameToValue(ngModuleType.exprName);
|
|
19818
19508
|
} else if (ngModuleType !== null) {
|
|
19819
19509
|
ngModuleExpression = typeNodeToValueExpr(ngModuleType);
|
|
@@ -19991,8 +19681,8 @@ var NgModuleDecoratorHandler = class {
|
|
|
19991
19681
|
if (decorator.args === null || decorator.args.length > 1) {
|
|
19992
19682
|
throw new FatalDiagnosticError(ErrorCode.DECORATOR_ARITY_WRONG, decorator.node, `Incorrect number of arguments to @NgModule decorator`);
|
|
19993
19683
|
}
|
|
19994
|
-
const meta = decorator.args.length === 1 ? unwrapExpression(decorator.args[0]) :
|
|
19995
|
-
if (!
|
|
19684
|
+
const meta = decorator.args.length === 1 ? unwrapExpression(decorator.args[0]) : ts74.factory.createObjectLiteralExpression([]);
|
|
19685
|
+
if (!ts74.isObjectLiteralExpression(meta)) {
|
|
19996
19686
|
throw new FatalDiagnosticError(ErrorCode.DECORATOR_ARG_NOT_LITERAL, meta, "@NgModule argument must be an object literal");
|
|
19997
19687
|
}
|
|
19998
19688
|
const ngModule = reflectObjectLiteral(meta);
|
|
@@ -20076,10 +19766,10 @@ var NgModuleDecoratorHandler = class {
|
|
|
20076
19766
|
if (ngModule.has("id")) {
|
|
20077
19767
|
const idExpr = ngModule.get("id");
|
|
20078
19768
|
if (!isModuleIdExpression(idExpr)) {
|
|
20079
|
-
id = new
|
|
19769
|
+
id = new WrappedNodeExpr9(idExpr);
|
|
20080
19770
|
} else {
|
|
20081
19771
|
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.`);
|
|
20082
|
-
diag.category =
|
|
19772
|
+
diag.category = ts74.DiagnosticCategory.Warning;
|
|
20083
19773
|
diagnostics.push(diag);
|
|
20084
19774
|
}
|
|
20085
19775
|
}
|
|
@@ -20105,10 +19795,10 @@ var NgModuleDecoratorHandler = class {
|
|
|
20105
19795
|
ngModuleMetadata = {
|
|
20106
19796
|
kind: R3NgModuleMetadataKind.Local,
|
|
20107
19797
|
type,
|
|
20108
|
-
bootstrapExpression: rawBootstrap ? new
|
|
20109
|
-
declarationsExpression: rawDeclarations ? new
|
|
20110
|
-
exportsExpression: rawExports ? new
|
|
20111
|
-
importsExpression: rawImports ? new
|
|
19798
|
+
bootstrapExpression: rawBootstrap ? new WrappedNodeExpr9(rawBootstrap) : null,
|
|
19799
|
+
declarationsExpression: rawDeclarations ? new WrappedNodeExpr9(rawDeclarations) : null,
|
|
19800
|
+
exportsExpression: rawExports ? new WrappedNodeExpr9(rawExports) : null,
|
|
19801
|
+
importsExpression: rawImports ? new WrappedNodeExpr9(rawImports) : null,
|
|
20112
19802
|
id,
|
|
20113
19803
|
// Use `ɵɵsetNgModuleScope` to patch selector scopes onto the generated definition in a
|
|
20114
19804
|
// tree-shakeable way.
|
|
@@ -20139,16 +19829,16 @@ var NgModuleDecoratorHandler = class {
|
|
|
20139
19829
|
}
|
|
20140
19830
|
const rawProviders = ngModule.has("providers") ? ngModule.get("providers") : null;
|
|
20141
19831
|
let wrappedProviders = null;
|
|
20142
|
-
if (rawProviders !== null && (!
|
|
20143
|
-
wrappedProviders = new
|
|
19832
|
+
if (rawProviders !== null && (!ts74.isArrayLiteralExpression(rawProviders) || rawProviders.elements.length > 0)) {
|
|
19833
|
+
wrappedProviders = new WrappedNodeExpr9(this.annotateForClosureCompiler ? wrapFunctionExpressionsInParens(rawProviders) : rawProviders);
|
|
20144
19834
|
}
|
|
20145
19835
|
const topLevelImports = [];
|
|
20146
19836
|
if (!allowUnresolvedReferences && ngModule.has("imports")) {
|
|
20147
19837
|
const rawImports2 = unwrapExpression(ngModule.get("imports"));
|
|
20148
19838
|
let topLevelExpressions = [];
|
|
20149
|
-
if (
|
|
19839
|
+
if (ts74.isArrayLiteralExpression(rawImports2)) {
|
|
20150
19840
|
for (const element of rawImports2.elements) {
|
|
20151
|
-
if (
|
|
19841
|
+
if (ts74.isSpreadElement(element)) {
|
|
20152
19842
|
topLevelExpressions.push(element.expression);
|
|
20153
19843
|
continue;
|
|
20154
19844
|
}
|
|
@@ -20188,12 +19878,12 @@ var NgModuleDecoratorHandler = class {
|
|
|
20188
19878
|
if (exp === null) {
|
|
20189
19879
|
continue;
|
|
20190
19880
|
}
|
|
20191
|
-
if (
|
|
19881
|
+
if (ts74.isArrayLiteralExpression(exp)) {
|
|
20192
19882
|
if (exp.elements) {
|
|
20193
|
-
injectorMetadata.imports.push(...exp.elements.map((n2) => new
|
|
19883
|
+
injectorMetadata.imports.push(...exp.elements.map((n2) => new WrappedNodeExpr9(n2)));
|
|
20194
19884
|
}
|
|
20195
19885
|
} else {
|
|
20196
|
-
injectorMetadata.imports.push(new
|
|
19886
|
+
injectorMetadata.imports.push(new WrappedNodeExpr9(exp));
|
|
20197
19887
|
}
|
|
20198
19888
|
}
|
|
20199
19889
|
}
|
|
@@ -20270,7 +19960,7 @@ var NgModuleDecoratorHandler = class {
|
|
|
20270
19960
|
};
|
|
20271
19961
|
for (const topLevelImport of analysis.imports) {
|
|
20272
19962
|
if (topLevelImport.hasModuleWithProviders) {
|
|
20273
|
-
data.injectorImports.push(new
|
|
19963
|
+
data.injectorImports.push(new WrappedNodeExpr9(topLevelImport.expression));
|
|
20274
19964
|
continue;
|
|
20275
19965
|
}
|
|
20276
19966
|
const refsToEmit = [];
|
|
@@ -20304,7 +19994,7 @@ var NgModuleDecoratorHandler = class {
|
|
|
20304
19994
|
refsToEmit.push(ref);
|
|
20305
19995
|
}
|
|
20306
19996
|
if (refsToEmit.length === topLevelImport.resolvedReferences.length) {
|
|
20307
|
-
data.injectorImports.push(new
|
|
19997
|
+
data.injectorImports.push(new WrappedNodeExpr9(topLevelImport.expression));
|
|
20308
19998
|
} else {
|
|
20309
19999
|
const context = node.getSourceFile();
|
|
20310
20000
|
for (const ref of refsToEmit) {
|
|
@@ -20519,7 +20209,7 @@ function isNgModule(node, compilation) {
|
|
|
20519
20209
|
return !compilation.dependencies.some((dep) => dep.ref.node === node);
|
|
20520
20210
|
}
|
|
20521
20211
|
function isModuleIdExpression(expr) {
|
|
20522
|
-
return
|
|
20212
|
+
return ts74.isPropertyAccessExpression(expr) && ts74.isIdentifier(expr.expression) && expr.expression.text === "module" && expr.name.text === "id";
|
|
20523
20213
|
}
|
|
20524
20214
|
function makeStandaloneBootstrapDiagnostic(ngModuleClass, bootstrappedClassRef, rawBootstrapExpr) {
|
|
20525
20215
|
const componentClassName = bootstrappedClassRef.node.name.text;
|
|
@@ -20592,7 +20282,7 @@ var ComponentSymbol = class _ComponentSymbol extends DirectiveSymbol {
|
|
|
20592
20282
|
};
|
|
20593
20283
|
|
|
20594
20284
|
// packages/compiler-cli/src/ngtsc/annotations/component/src/util.js
|
|
20595
|
-
import
|
|
20285
|
+
import ts75 from "typescript";
|
|
20596
20286
|
function collectLegacyAnimationNames(value, legacyAnimationTriggerNames) {
|
|
20597
20287
|
if (value instanceof Map) {
|
|
20598
20288
|
const name = value.get("name");
|
|
@@ -20639,7 +20329,7 @@ function validateAndFlattenComponentImports(imports, expr, isDeferred) {
|
|
|
20639
20329
|
for (let i = 0; i < imports.length; i++) {
|
|
20640
20330
|
const ref = imports[i];
|
|
20641
20331
|
let refExpr = expr;
|
|
20642
|
-
if (
|
|
20332
|
+
if (ts75.isArrayLiteralExpression(expr) && expr.elements.length === imports.length && !expr.elements.some(ts75.isSpreadAssignment)) {
|
|
20643
20333
|
refExpr = expr.elements[i];
|
|
20644
20334
|
}
|
|
20645
20335
|
if (Array.isArray(ref)) {
|
|
@@ -20701,11 +20391,11 @@ import { outputAst as o4 } from "@angular/compiler";
|
|
|
20701
20391
|
|
|
20702
20392
|
// packages/compiler-cli/src/ngtsc/hmr/src/extract_dependencies.js
|
|
20703
20393
|
import { outputAst as o3 } from "@angular/compiler";
|
|
20704
|
-
import
|
|
20394
|
+
import ts76 from "typescript";
|
|
20705
20395
|
function extractHmrDependencies(node, definition, factory, deferBlockMetadata, classMetadata, debugInfo, reflection, evaluator) {
|
|
20706
|
-
const name =
|
|
20396
|
+
const name = ts76.isClassDeclaration(node) && node.name ? node.name.text : null;
|
|
20707
20397
|
const visitor = new PotentialTopLevelReadsVisitor();
|
|
20708
|
-
const sourceFile =
|
|
20398
|
+
const sourceFile = ts76.getOriginalNode(node).getSourceFile();
|
|
20709
20399
|
definition.expression.visitExpression(visitor, null);
|
|
20710
20400
|
definition.statements.forEach((statement) => statement.visitStatement(visitor, null));
|
|
20711
20401
|
factory.initializer?.visitExpression(visitor, null);
|
|
@@ -20766,21 +20456,21 @@ function getRuntimeRepresentation(node, reflection, evaluator) {
|
|
|
20766
20456
|
function getTopLevelDeclarationNames(sourceFile) {
|
|
20767
20457
|
const results = /* @__PURE__ */ new Set();
|
|
20768
20458
|
for (const node of sourceFile.statements) {
|
|
20769
|
-
if (
|
|
20459
|
+
if (ts76.isClassDeclaration(node) || ts76.isFunctionDeclaration(node) || ts76.isEnumDeclaration(node)) {
|
|
20770
20460
|
if (node.name) {
|
|
20771
20461
|
results.add(node.name.text);
|
|
20772
20462
|
}
|
|
20773
20463
|
continue;
|
|
20774
20464
|
}
|
|
20775
|
-
if (
|
|
20465
|
+
if (ts76.isVariableStatement(node)) {
|
|
20776
20466
|
for (const decl of node.declarationList.declarations) {
|
|
20777
20467
|
trackBindingName(decl.name, results);
|
|
20778
20468
|
}
|
|
20779
20469
|
continue;
|
|
20780
20470
|
}
|
|
20781
|
-
if (
|
|
20471
|
+
if (ts76.isImportDeclaration(node) && node.importClause) {
|
|
20782
20472
|
const importClause = node.importClause;
|
|
20783
|
-
if (importClause.phaseModifier ===
|
|
20473
|
+
if (importClause.phaseModifier === ts76.SyntaxKind.TypeKeyword) {
|
|
20784
20474
|
continue;
|
|
20785
20475
|
}
|
|
20786
20476
|
if (importClause.name) {
|
|
@@ -20788,7 +20478,7 @@ function getTopLevelDeclarationNames(sourceFile) {
|
|
|
20788
20478
|
}
|
|
20789
20479
|
if (importClause.namedBindings) {
|
|
20790
20480
|
const namedBindings = importClause.namedBindings;
|
|
20791
|
-
if (
|
|
20481
|
+
if (ts76.isNamespaceImport(namedBindings)) {
|
|
20792
20482
|
results.add(namedBindings.name.text);
|
|
20793
20483
|
} else {
|
|
20794
20484
|
namedBindings.elements.forEach((el) => {
|
|
@@ -20804,11 +20494,11 @@ function getTopLevelDeclarationNames(sourceFile) {
|
|
|
20804
20494
|
return results;
|
|
20805
20495
|
}
|
|
20806
20496
|
function trackBindingName(node, results) {
|
|
20807
|
-
if (
|
|
20497
|
+
if (ts76.isIdentifier(node)) {
|
|
20808
20498
|
results.add(node.text);
|
|
20809
20499
|
} else {
|
|
20810
20500
|
for (const el of node.elements) {
|
|
20811
|
-
if (!
|
|
20501
|
+
if (!ts76.isOmittedExpression(el)) {
|
|
20812
20502
|
trackBindingName(el.name, results);
|
|
20813
20503
|
}
|
|
20814
20504
|
}
|
|
@@ -20838,10 +20528,10 @@ var PotentialTopLevelReadsVisitor = class extends o3.RecursiveAstVisitor {
|
|
|
20838
20528
|
* @param node Node from which to start the traversal.
|
|
20839
20529
|
*/
|
|
20840
20530
|
addAllTopLevelIdentifiers = (node) => {
|
|
20841
|
-
if (
|
|
20531
|
+
if (ts76.isIdentifier(node) && this.isTopLevelIdentifierReference(node)) {
|
|
20842
20532
|
this.allReads.add(node);
|
|
20843
20533
|
} else {
|
|
20844
|
-
|
|
20534
|
+
ts76.forEachChild(node, this.addAllTopLevelIdentifiers);
|
|
20845
20535
|
}
|
|
20846
20536
|
};
|
|
20847
20537
|
/**
|
|
@@ -20856,52 +20546,52 @@ var PotentialTopLevelReadsVisitor = class extends o3.RecursiveAstVisitor {
|
|
|
20856
20546
|
if (!parent) {
|
|
20857
20547
|
return false;
|
|
20858
20548
|
}
|
|
20859
|
-
if (
|
|
20860
|
-
while (parent &&
|
|
20549
|
+
if (ts76.isParenthesizedExpression(parent) && parent.expression === node) {
|
|
20550
|
+
while (parent && ts76.isParenthesizedExpression(parent)) {
|
|
20861
20551
|
node = parent;
|
|
20862
20552
|
parent = parent.parent;
|
|
20863
20553
|
}
|
|
20864
20554
|
}
|
|
20865
|
-
if (
|
|
20555
|
+
if (ts76.isSourceFile(parent)) {
|
|
20866
20556
|
return true;
|
|
20867
20557
|
}
|
|
20868
|
-
if (
|
|
20558
|
+
if (ts76.isCallExpression(parent)) {
|
|
20869
20559
|
return parent.expression === node || parent.arguments.includes(node);
|
|
20870
20560
|
}
|
|
20871
|
-
if (
|
|
20561
|
+
if (ts76.isExpressionStatement(parent) || ts76.isPropertyAccessExpression(parent) || ts76.isComputedPropertyName(parent) || ts76.isTemplateSpan(parent) || ts76.isSpreadAssignment(parent) || ts76.isSpreadElement(parent) || ts76.isAwaitExpression(parent) || ts76.isNonNullExpression(parent) || ts76.isIfStatement(parent) || ts76.isDoStatement(parent) || ts76.isWhileStatement(parent) || ts76.isSwitchStatement(parent) || ts76.isCaseClause(parent) || ts76.isThrowStatement(parent) || ts76.isNewExpression(parent) || ts76.isExpressionWithTypeArguments(parent)) {
|
|
20872
20562
|
return parent.expression === node;
|
|
20873
20563
|
}
|
|
20874
|
-
if (
|
|
20564
|
+
if (ts76.isArrayLiteralExpression(parent)) {
|
|
20875
20565
|
return parent.elements.includes(node);
|
|
20876
20566
|
}
|
|
20877
|
-
if (
|
|
20567
|
+
if (ts76.isPropertyAssignment(parent) || ts76.isParameter(parent) || ts76.isBindingElement(parent) || ts76.isPropertyDeclaration(parent) || ts76.isEnumMember(parent)) {
|
|
20878
20568
|
return parent.initializer === node;
|
|
20879
20569
|
}
|
|
20880
|
-
if (
|
|
20570
|
+
if (ts76.isVariableDeclaration(parent)) {
|
|
20881
20571
|
return parent.name === node || parent.initializer === node;
|
|
20882
20572
|
}
|
|
20883
|
-
if (
|
|
20573
|
+
if (ts76.isClassDeclaration(parent) || ts76.isFunctionDeclaration(parent) || ts76.isShorthandPropertyAssignment(parent)) {
|
|
20884
20574
|
return parent.name === node;
|
|
20885
20575
|
}
|
|
20886
|
-
if (
|
|
20576
|
+
if (ts76.isElementAccessExpression(parent)) {
|
|
20887
20577
|
return parent.expression === node || parent.argumentExpression === node;
|
|
20888
20578
|
}
|
|
20889
|
-
if (
|
|
20579
|
+
if (ts76.isBinaryExpression(parent)) {
|
|
20890
20580
|
return parent.left === node || parent.right === node;
|
|
20891
20581
|
}
|
|
20892
|
-
if (
|
|
20582
|
+
if (ts76.isForInStatement(parent) || ts76.isForOfStatement(parent)) {
|
|
20893
20583
|
return parent.expression === node || parent.initializer === node;
|
|
20894
20584
|
}
|
|
20895
|
-
if (
|
|
20585
|
+
if (ts76.isForStatement(parent)) {
|
|
20896
20586
|
return parent.condition === node || parent.initializer === node || parent.incrementor === node;
|
|
20897
20587
|
}
|
|
20898
|
-
if (
|
|
20588
|
+
if (ts76.isArrowFunction(parent)) {
|
|
20899
20589
|
return parent.body === node;
|
|
20900
20590
|
}
|
|
20901
|
-
if (
|
|
20591
|
+
if (ts76.isImportSpecifier(parent) || ts76.isExportSpecifier(parent)) {
|
|
20902
20592
|
return (parent.propertyName || parent.name) === node;
|
|
20903
20593
|
}
|
|
20904
|
-
if (
|
|
20594
|
+
if (ts76.isConditionalExpression(parent)) {
|
|
20905
20595
|
return parent.condition === node || parent.whenFalse === node || parent.whenTrue === node;
|
|
20906
20596
|
}
|
|
20907
20597
|
return false;
|
|
@@ -20913,20 +20603,20 @@ var PotentialTopLevelReadsVisitor = class extends o3.RecursiveAstVisitor {
|
|
|
20913
20603
|
};
|
|
20914
20604
|
function isConstEnumReference(node, reflection) {
|
|
20915
20605
|
const parent = node.parent;
|
|
20916
|
-
if (!parent || !
|
|
20606
|
+
if (!parent || !ts76.isPropertyAccessExpression(parent) || parent.expression !== node || !ts76.isIdentifier(parent.name)) {
|
|
20917
20607
|
return false;
|
|
20918
20608
|
}
|
|
20919
20609
|
const declaration = reflection.getDeclarationOfIdentifier(node);
|
|
20920
|
-
return declaration !== null &&
|
|
20610
|
+
return declaration !== null && ts76.isEnumDeclaration(declaration.node) && !!declaration.node.modifiers?.some((m) => m.kind === ts76.SyntaxKind.ConstKeyword);
|
|
20921
20611
|
}
|
|
20922
20612
|
|
|
20923
20613
|
// packages/compiler-cli/src/ngtsc/hmr/src/metadata.js
|
|
20924
|
-
import
|
|
20614
|
+
import ts77 from "typescript";
|
|
20925
20615
|
function extractHmrMetatadata(clazz, reflection, evaluator, compilerHost, rootDirs, definition, factory, deferBlockMetadata, classMetadata, debugInfo) {
|
|
20926
20616
|
if (!reflection.isClass(clazz)) {
|
|
20927
20617
|
return null;
|
|
20928
20618
|
}
|
|
20929
|
-
const sourceFile =
|
|
20619
|
+
const sourceFile = ts77.getOriginalNode(clazz).getSourceFile();
|
|
20930
20620
|
const filePath = getProjectRelativePath(sourceFile.fileName, rootDirs, compilerHost) || compilerHost.getCanonicalFileName(sourceFile.fileName);
|
|
20931
20621
|
const dependencies = extractHmrDependencies(clazz, definition, factory, deferBlockMetadata, classMetadata, debugInfo, reflection, evaluator);
|
|
20932
20622
|
if (dependencies === null) {
|
|
@@ -20944,7 +20634,7 @@ function extractHmrMetatadata(clazz, reflection, evaluator, compilerHost, rootDi
|
|
|
20944
20634
|
|
|
20945
20635
|
// packages/compiler-cli/src/ngtsc/hmr/src/update_declaration.js
|
|
20946
20636
|
import { compileHmrUpdateCallback } from "@angular/compiler";
|
|
20947
|
-
import
|
|
20637
|
+
import ts78 from "typescript";
|
|
20948
20638
|
function getHmrUpdateDeclaration(compilationResults, constantStatements, meta, declaration) {
|
|
20949
20639
|
const namespaceSpecifiers = meta.namespaceDependencies.reduce((result, current) => {
|
|
20950
20640
|
result.set(current.moduleName, current.assignedName);
|
|
@@ -20956,11 +20646,11 @@ function getHmrUpdateDeclaration(compilationResults, constantStatements, meta, d
|
|
|
20956
20646
|
rewriter: importRewriter
|
|
20957
20647
|
});
|
|
20958
20648
|
const callback = compileHmrUpdateCallback(compilationResults, constantStatements, meta);
|
|
20959
|
-
const sourceFile =
|
|
20649
|
+
const sourceFile = ts78.getOriginalNode(declaration).getSourceFile();
|
|
20960
20650
|
const node = translateStatement(sourceFile, callback, importManager);
|
|
20961
|
-
return
|
|
20962
|
-
|
|
20963
|
-
|
|
20651
|
+
return ts78.factory.updateFunctionDeclaration(node, [
|
|
20652
|
+
ts78.factory.createToken(ts78.SyntaxKind.ExportKeyword),
|
|
20653
|
+
ts78.factory.createToken(ts78.SyntaxKind.DefaultKeyword)
|
|
20964
20654
|
], node.asteriskToken, node.name, node.typeParameters, node.parameters, node.type, node.body);
|
|
20965
20655
|
}
|
|
20966
20656
|
var HmrModuleImportRewriter = class {
|
|
@@ -21407,7 +21097,7 @@ var ComponentDecoratorHandler = class {
|
|
|
21407
21097
|
path: absoluteFrom(template.declaration.resolvedTemplateUrl),
|
|
21408
21098
|
node: template.sourceMapping.node
|
|
21409
21099
|
};
|
|
21410
|
-
const relativeTemplatePath = getProjectRelativePath(templateResource.path ??
|
|
21100
|
+
const relativeTemplatePath = getProjectRelativePath(templateResource.path ?? ts79.getOriginalNode(node).getSourceFile().fileName, this.rootDirs, this.compilerHost);
|
|
21411
21101
|
let selectorlessEnabled = false;
|
|
21412
21102
|
let localReferencedSymbols = null;
|
|
21413
21103
|
if (this.enableSelectorless) {
|
|
@@ -21441,7 +21131,7 @@ var ComponentDecoratorHandler = class {
|
|
|
21441
21131
|
externalStyles.push(resourceUrl);
|
|
21442
21132
|
continue;
|
|
21443
21133
|
}
|
|
21444
|
-
if (styleUrl.source === 2 &&
|
|
21134
|
+
if (styleUrl.source === 2 && ts79.isStringLiteralLike(styleUrl.expression)) {
|
|
21445
21135
|
styleResources.add({
|
|
21446
21136
|
path: absoluteFrom(resourceUrl),
|
|
21447
21137
|
node: styleUrl.expression
|
|
@@ -21649,7 +21339,7 @@ var ComponentDecoratorHandler = class {
|
|
|
21649
21339
|
return null;
|
|
21650
21340
|
}
|
|
21651
21341
|
typeCheck(ctx, node, meta) {
|
|
21652
|
-
if (!
|
|
21342
|
+
if (!ts79.isClassDeclaration(node) || meta.isPoisoned && !this.usePoisonedData) {
|
|
21653
21343
|
return;
|
|
21654
21344
|
}
|
|
21655
21345
|
const ref = new Reference(node);
|
|
@@ -22180,12 +21870,12 @@ var ComponentDecoratorHandler = class {
|
|
|
22180
21870
|
*/
|
|
22181
21871
|
collectExplicitlyDeferredSymbols(rawDeferredImports) {
|
|
22182
21872
|
const deferredTypes = /* @__PURE__ */ new Map();
|
|
22183
|
-
if (!
|
|
21873
|
+
if (!ts79.isArrayLiteralExpression(rawDeferredImports)) {
|
|
22184
21874
|
return deferredTypes;
|
|
22185
21875
|
}
|
|
22186
21876
|
for (const element of rawDeferredImports.elements) {
|
|
22187
21877
|
const node = tryUnwrapForwardRef(element, this.reflector) || element;
|
|
22188
|
-
if (!
|
|
21878
|
+
if (!ts79.isIdentifier(node)) {
|
|
22189
21879
|
continue;
|
|
22190
21880
|
}
|
|
22191
21881
|
const imp = this.reflector.getImportOfIdentifier(node);
|
|
@@ -22253,12 +21943,12 @@ var ComponentDecoratorHandler = class {
|
|
|
22253
21943
|
}
|
|
22254
21944
|
}
|
|
22255
21945
|
if (analysisData.meta.isStandalone) {
|
|
22256
|
-
if (analysisData.rawImports !== null &&
|
|
21946
|
+
if (analysisData.rawImports !== null && ts79.isArrayLiteralExpression(analysisData.rawImports)) {
|
|
22257
21947
|
for (const element of analysisData.rawImports.elements) {
|
|
22258
21948
|
this.registerDeferrableCandidate(componentClassDecl, element, false, allDeferredDecls, eagerlyUsedDecls, resolutionData);
|
|
22259
21949
|
}
|
|
22260
21950
|
}
|
|
22261
|
-
if (analysisData.rawDeferredImports !== null &&
|
|
21951
|
+
if (analysisData.rawDeferredImports !== null && ts79.isArrayLiteralExpression(analysisData.rawDeferredImports)) {
|
|
22262
21952
|
for (const element of analysisData.rawDeferredImports.elements) {
|
|
22263
21953
|
this.registerDeferrableCandidate(componentClassDecl, element, false, allDeferredDecls, eagerlyUsedDecls, resolutionData);
|
|
22264
21954
|
}
|
|
@@ -22277,7 +21967,7 @@ var ComponentDecoratorHandler = class {
|
|
|
22277
21967
|
*/
|
|
22278
21968
|
registerDeferrableCandidate(componentClassDecl, element, isDeferredImport, allDeferredDecls, eagerlyUsedDecls, resolutionData) {
|
|
22279
21969
|
const node = tryUnwrapForwardRef(element, this.reflector) || element;
|
|
22280
|
-
if (!
|
|
21970
|
+
if (!ts79.isIdentifier(node)) {
|
|
22281
21971
|
return;
|
|
22282
21972
|
}
|
|
22283
21973
|
const imp = this.reflector.getImportOfIdentifier(node);
|
|
@@ -22411,8 +22101,8 @@ function isDefaultImport(node) {
|
|
|
22411
22101
|
}
|
|
22412
22102
|
|
|
22413
22103
|
// packages/compiler-cli/src/ngtsc/annotations/src/injectable.js
|
|
22414
|
-
import { compileClassMetadata as compileClassMetadata3, compileDeclareClassMetadata as compileDeclareClassMetadata3, compileDeclareInjectableFromMetadata, compileInjectable, createMayBeForwardRefExpression as createMayBeForwardRefExpression3, FactoryTarget as FactoryTarget4, LiteralExpr as LiteralExpr3, WrappedNodeExpr as
|
|
22415
|
-
import
|
|
22104
|
+
import { compileClassMetadata as compileClassMetadata3, compileDeclareClassMetadata as compileDeclareClassMetadata3, compileDeclareInjectableFromMetadata, compileInjectable, createMayBeForwardRefExpression as createMayBeForwardRefExpression3, FactoryTarget as FactoryTarget4, LiteralExpr as LiteralExpr3, WrappedNodeExpr as WrappedNodeExpr10 } from "@angular/compiler";
|
|
22105
|
+
import ts80 from "typescript";
|
|
22416
22106
|
var InjectableDecoratorHandler = class {
|
|
22417
22107
|
reflector;
|
|
22418
22108
|
evaluator;
|
|
@@ -22547,7 +22237,7 @@ function extractInjectableMetadata(clazz, decorator, reflector) {
|
|
|
22547
22237
|
};
|
|
22548
22238
|
} else if (decorator.args.length === 1) {
|
|
22549
22239
|
const metaNode = decorator.args[0];
|
|
22550
|
-
if (!
|
|
22240
|
+
if (!ts80.isObjectLiteralExpression(metaNode)) {
|
|
22551
22241
|
throw new FatalDiagnosticError(ErrorCode.DECORATOR_ARG_NOT_LITERAL, metaNode, `@Injectable argument must be an object literal`);
|
|
22552
22242
|
}
|
|
22553
22243
|
const meta = reflectObjectLiteral(metaNode);
|
|
@@ -22559,7 +22249,7 @@ function extractInjectableMetadata(clazz, decorator, reflector) {
|
|
|
22559
22249
|
let deps = void 0;
|
|
22560
22250
|
if ((meta.has("useClass") || meta.has("useFactory")) && meta.has("deps")) {
|
|
22561
22251
|
const depsExpr = meta.get("deps");
|
|
22562
|
-
if (!
|
|
22252
|
+
if (!ts80.isArrayLiteralExpression(depsExpr)) {
|
|
22563
22253
|
throw new FatalDiagnosticError(ErrorCode.VALUE_NOT_LITERAL, depsExpr, `@Injectable deps metadata must be an inline array`);
|
|
22564
22254
|
}
|
|
22565
22255
|
deps = depsExpr.elements.map((dep) => getDep(dep, reflector));
|
|
@@ -22573,7 +22263,7 @@ function extractInjectableMetadata(clazz, decorator, reflector) {
|
|
|
22573
22263
|
result.useClass = getProviderExpression(meta.get("useClass"), reflector);
|
|
22574
22264
|
result.deps = deps;
|
|
22575
22265
|
} else if (meta.has("useFactory")) {
|
|
22576
|
-
result.useFactory = new
|
|
22266
|
+
result.useFactory = new WrappedNodeExpr10(meta.get("useFactory"));
|
|
22577
22267
|
result.deps = deps;
|
|
22578
22268
|
}
|
|
22579
22269
|
return result;
|
|
@@ -22584,7 +22274,7 @@ function extractInjectableMetadata(clazz, decorator, reflector) {
|
|
|
22584
22274
|
function getProviderExpression(expression, reflector) {
|
|
22585
22275
|
const forwardRefValue = tryUnwrapForwardRef(expression, reflector);
|
|
22586
22276
|
return createMayBeForwardRefExpression3(
|
|
22587
|
-
new
|
|
22277
|
+
new WrappedNodeExpr10(forwardRefValue ?? expression),
|
|
22588
22278
|
forwardRefValue !== null ? 2 : 0
|
|
22589
22279
|
/* ForwardRefHandling.None */
|
|
22590
22280
|
);
|
|
@@ -22616,7 +22306,7 @@ function requiresValidCtor(meta) {
|
|
|
22616
22306
|
}
|
|
22617
22307
|
function getDep(dep, reflector) {
|
|
22618
22308
|
const meta = {
|
|
22619
|
-
token: new
|
|
22309
|
+
token: new WrappedNodeExpr10(dep),
|
|
22620
22310
|
attributeNameType: null,
|
|
22621
22311
|
host: false,
|
|
22622
22312
|
optional: false,
|
|
@@ -22631,7 +22321,7 @@ function getDep(dep, reflector) {
|
|
|
22631
22321
|
switch (source.name) {
|
|
22632
22322
|
case "Inject":
|
|
22633
22323
|
if (token !== void 0) {
|
|
22634
|
-
meta.token = new
|
|
22324
|
+
meta.token = new WrappedNodeExpr10(token);
|
|
22635
22325
|
}
|
|
22636
22326
|
break;
|
|
22637
22327
|
case "Optional":
|
|
@@ -22648,17 +22338,17 @@ function getDep(dep, reflector) {
|
|
|
22648
22338
|
}
|
|
22649
22339
|
return true;
|
|
22650
22340
|
}
|
|
22651
|
-
if (
|
|
22341
|
+
if (ts80.isArrayLiteralExpression(dep)) {
|
|
22652
22342
|
dep.elements.forEach((el) => {
|
|
22653
22343
|
let isDecorator = false;
|
|
22654
|
-
if (
|
|
22344
|
+
if (ts80.isIdentifier(el)) {
|
|
22655
22345
|
isDecorator = maybeUpdateDecorator(el, reflector);
|
|
22656
|
-
} else if (
|
|
22346
|
+
} else if (ts80.isNewExpression(el) && ts80.isIdentifier(el.expression)) {
|
|
22657
22347
|
const token = el.arguments && el.arguments.length > 0 && el.arguments[0] || void 0;
|
|
22658
22348
|
isDecorator = maybeUpdateDecorator(el.expression, reflector, token);
|
|
22659
22349
|
}
|
|
22660
22350
|
if (!isDecorator) {
|
|
22661
|
-
meta.token = new
|
|
22351
|
+
meta.token = new WrappedNodeExpr10(el);
|
|
22662
22352
|
}
|
|
22663
22353
|
});
|
|
22664
22354
|
}
|
|
@@ -22667,7 +22357,7 @@ function getDep(dep, reflector) {
|
|
|
22667
22357
|
|
|
22668
22358
|
// packages/compiler-cli/src/ngtsc/annotations/src/pipe.js
|
|
22669
22359
|
import { compileClassMetadata as compileClassMetadata4, compileDeclareClassMetadata as compileDeclareClassMetadata4, compileDeclarePipeFromMetadata, compilePipeFromMetadata, FactoryTarget as FactoryTarget5 } from "@angular/compiler";
|
|
22670
|
-
import
|
|
22360
|
+
import ts81 from "typescript";
|
|
22671
22361
|
var PipeSymbol = class _PipeSymbol extends SemanticSymbol {
|
|
22672
22362
|
name;
|
|
22673
22363
|
constructor(decl, name) {
|
|
@@ -22737,13 +22427,13 @@ var PipeDecoratorHandler = class {
|
|
|
22737
22427
|
}
|
|
22738
22428
|
const meta = decorator.args.length === 0 || // TODO(crisbeto): temporary for testing until we've changed
|
|
22739
22429
|
// the pipe public API not to require a name.
|
|
22740
|
-
|
|
22430
|
+
ts81.isNonNullExpression(decorator.args[0]) && decorator.args[0].expression.kind === ts81.SyntaxKind.NullKeyword ? null : unwrapExpression(decorator.args[0]);
|
|
22741
22431
|
let pipeName = null;
|
|
22742
22432
|
let pipeNameExpr = null;
|
|
22743
22433
|
let pure = true;
|
|
22744
22434
|
let isStandalone = this.implicitStandaloneValue;
|
|
22745
22435
|
if (meta !== null) {
|
|
22746
|
-
if (!
|
|
22436
|
+
if (!ts81.isObjectLiteralExpression(meta)) {
|
|
22747
22437
|
throw new FatalDiagnosticError(ErrorCode.DECORATOR_ARG_NOT_LITERAL, meta, "@Pipe must have a literal argument");
|
|
22748
22438
|
}
|
|
22749
22439
|
const pipe = reflectObjectLiteral(meta);
|
|
@@ -22869,12 +22559,12 @@ var PipeDecoratorHandler = class {
|
|
|
22869
22559
|
};
|
|
22870
22560
|
|
|
22871
22561
|
// packages/compiler-cli/src/ngtsc/transform/jit/src/initializer_api_transforms/transform.js
|
|
22872
|
-
import
|
|
22562
|
+
import ts84 from "typescript";
|
|
22873
22563
|
|
|
22874
22564
|
// packages/compiler-cli/src/ngtsc/transform/jit/src/initializer_api_transforms/transform_api.js
|
|
22875
|
-
import
|
|
22565
|
+
import ts82 from "typescript";
|
|
22876
22566
|
function createSyntheticAngularCoreDecoratorAccess(factory, importManager, ngClassDecorator, sourceFile, decoratorName) {
|
|
22877
|
-
const classDecoratorIdentifier =
|
|
22567
|
+
const classDecoratorIdentifier = ts82.isIdentifier(ngClassDecorator.identifier) ? ngClassDecorator.identifier : ngClassDecorator.identifier.expression;
|
|
22878
22568
|
return factory.createPropertyAccessExpression(
|
|
22879
22569
|
importManager.addImport({
|
|
22880
22570
|
exportModuleSpecifier: "@angular/core",
|
|
@@ -22884,11 +22574,11 @@ function createSyntheticAngularCoreDecoratorAccess(factory, importManager, ngCla
|
|
|
22884
22574
|
// The synthetic identifier may be checked later by the downlevel decorators
|
|
22885
22575
|
// transform to resolve to an Angular import using `getSymbolAtLocation`. We trick
|
|
22886
22576
|
// the transform to think it's not synthetic and comes from Angular core.
|
|
22887
|
-
|
|
22577
|
+
ts82.setOriginalNode(factory.createIdentifier(decoratorName), classDecoratorIdentifier)
|
|
22888
22578
|
);
|
|
22889
22579
|
}
|
|
22890
22580
|
function castAsAny(factory, expr) {
|
|
22891
|
-
return factory.createAsExpression(expr, factory.createKeywordTypeNode(
|
|
22581
|
+
return factory.createAsExpression(expr, factory.createKeywordTypeNode(ts82.SyntaxKind.AnyKeyword));
|
|
22892
22582
|
}
|
|
22893
22583
|
|
|
22894
22584
|
// packages/compiler-cli/src/ngtsc/transform/jit/src/initializer_api_transforms/input_function.js
|
|
@@ -22919,7 +22609,7 @@ var signalInputsTransform = (member, sourceFile, host, factory, importTracker, i
|
|
|
22919
22609
|
};
|
|
22920
22610
|
|
|
22921
22611
|
// packages/compiler-cli/src/ngtsc/transform/jit/src/initializer_api_transforms/model_function.js
|
|
22922
|
-
import
|
|
22612
|
+
import ts83 from "typescript";
|
|
22923
22613
|
var signalModelTransform = (member, sourceFile, host, factory, importTracker, importManager, classDecorator, isCore) => {
|
|
22924
22614
|
if (host.getDecoratorsOfDeclaration(member.node)?.some((d) => {
|
|
22925
22615
|
return isAngularDecorator2(d, "Input", isCore) || isAngularDecorator2(d, "Output", isCore);
|
|
@@ -22940,7 +22630,7 @@ var signalModelTransform = (member, sourceFile, host, factory, importTracker, im
|
|
|
22940
22630
|
// Config is cast to `any` because `isSignal` will be private, and in case this
|
|
22941
22631
|
// transform is used directly as a pre-compilation step, the decorator should
|
|
22942
22632
|
// not fail. It is already validated now due to us parsing the input metadata.
|
|
22943
|
-
factory.createAsExpression(inputConfig, factory.createKeywordTypeNode(
|
|
22633
|
+
factory.createAsExpression(inputConfig, factory.createKeywordTypeNode(ts83.SyntaxKind.AnyKeyword)),
|
|
22944
22634
|
classDecorator,
|
|
22945
22635
|
factory,
|
|
22946
22636
|
sourceFile,
|
|
@@ -23015,21 +22705,21 @@ function getInitializerApiJitTransform(host, importTracker, isCore, shouldTransf
|
|
|
23015
22705
|
return (ctx) => {
|
|
23016
22706
|
return (sourceFile) => {
|
|
23017
22707
|
const importManager = new ImportManager();
|
|
23018
|
-
sourceFile =
|
|
22708
|
+
sourceFile = ts84.visitNode(sourceFile, createTransformVisitor(ctx, host, importManager, importTracker, isCore, shouldTransformClass), ts84.isSourceFile);
|
|
23019
22709
|
return importManager.transformTsFile(ctx, sourceFile);
|
|
23020
22710
|
};
|
|
23021
22711
|
};
|
|
23022
22712
|
}
|
|
23023
22713
|
function createTransformVisitor(ctx, host, importManager, importTracker, isCore, shouldTransformClass) {
|
|
23024
22714
|
const visitor = (node) => {
|
|
23025
|
-
if (
|
|
23026
|
-
const originalNode =
|
|
22715
|
+
if (ts84.isClassDeclaration(node) && node.name !== void 0) {
|
|
22716
|
+
const originalNode = ts84.getOriginalNode(node, ts84.isClassDeclaration);
|
|
23027
22717
|
const angularDecorator = host.getDecoratorsOfDeclaration(originalNode)?.find((d) => decoratorsWithInputs.some((name) => isAngularDecorator2(d, name, isCore)));
|
|
23028
22718
|
if (angularDecorator !== void 0 && (shouldTransformClass === void 0 || shouldTransformClass(node))) {
|
|
23029
22719
|
let hasChanged = false;
|
|
23030
22720
|
const sourceFile = originalNode.getSourceFile();
|
|
23031
22721
|
const members = node.members.map((memberNode) => {
|
|
23032
|
-
if (!
|
|
22722
|
+
if (!ts84.isPropertyDeclaration(memberNode)) {
|
|
23033
22723
|
return memberNode;
|
|
23034
22724
|
}
|
|
23035
22725
|
const member = reflectClassMember(memberNode);
|
|
@@ -23050,7 +22740,7 @@ function createTransformVisitor(ctx, host, importManager, importTracker, isCore,
|
|
|
23050
22740
|
}
|
|
23051
22741
|
}
|
|
23052
22742
|
}
|
|
23053
|
-
return
|
|
22743
|
+
return ts84.visitEachChild(node, visitor, ctx);
|
|
23054
22744
|
};
|
|
23055
22745
|
return visitor;
|
|
23056
22746
|
}
|