@angular/compiler-cli 21.2.2 → 21.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bundles/{chunk-RJ3Y43GR.js → chunk-6JHVJEKD.js} +5 -5
- package/bundles/chunk-FLWAEX6T.js +1 -1
- package/bundles/{chunk-SPPRVX7S.js → chunk-KJC7YNMY.js} +2 -2
- package/bundles/{chunk-OECV6WLT.js → chunk-L3PEIUBN.js} +723 -440
- package/bundles/{chunk-32EO3D75.js → chunk-NU2SXS64.js} +1 -1
- package/bundles/index.js +4 -4
- package/bundles/private/migrations.js +2 -2
- package/bundles/private/testing.js +1 -1
- package/bundles/private/tooling.js +1 -1
- package/bundles/src/bin/ng_xi18n.js +4 -4
- package/bundles/src/bin/ngc.js +4 -4
- package/linker/src/file_linker/partial_linkers/util.d.ts +1 -1
- package/package.json +2 -2
- package/src/ngtsc/annotations/common/src/diagnostics.d.ts +7 -7
- package/src/ngtsc/core/api/src/adapter.d.ts +1 -1
- package/src/ngtsc/incremental/src/incremental.d.ts +1 -1
- package/src/ngtsc/typecheck/api/api.d.ts +80 -4
- package/src/ngtsc/typecheck/src/checker.d.ts +1 -1
- package/src/ngtsc/typecheck/src/context.d.ts +1 -1
- package/src/ngtsc/typecheck/src/environment.d.ts +4 -3
- package/src/ngtsc/typecheck/src/oob.d.ts +5 -4
- package/src/ngtsc/typecheck/src/ops/bindings.d.ts +3 -5
- package/src/ngtsc/typecheck/src/ops/context.d.ts +4 -5
- package/src/ngtsc/typecheck/src/ops/directive_constructor.d.ts +3 -3
- package/src/ngtsc/typecheck/src/ops/directive_type.d.ts +3 -3
- package/src/ngtsc/typecheck/src/ops/events.d.ts +2 -2
- package/src/ngtsc/typecheck/src/ops/inputs.d.ts +2 -2
- package/src/ngtsc/typecheck/src/ops/references.d.ts +2 -2
- package/src/ngtsc/typecheck/src/ops/scope.d.ts +2 -2
- package/src/ngtsc/typecheck/src/ops/signal_forms.d.ts +6 -6
- package/src/ngtsc/typecheck/src/reference_emit_environment.d.ts +18 -1
- package/src/ngtsc/typecheck/src/tcb_adapter.d.ts +20 -0
- package/src/ngtsc/typecheck/src/tcb_util.d.ts +2 -1
- package/src/ngtsc/typecheck/src/type_check_block.d.ts +2 -4
- package/src/ngtsc/typecheck/src/type_check_file.d.ts +1 -0
- package/src/ngtsc/typecheck/src/type_constructor.d.ts +2 -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.3";
|
|
233
233
|
const prefix = isPreRelease ? "next" : `v${VERSION.major}`;
|
|
234
234
|
return `https://${prefix}.angular.dev`;
|
|
235
235
|
})();
|
|
@@ -9836,7 +9836,7 @@ function _extractTemplateStyleUrls(template) {
|
|
|
9836
9836
|
}
|
|
9837
9837
|
|
|
9838
9838
|
// packages/compiler-cli/src/ngtsc/annotations/component/src/handler.js
|
|
9839
|
-
import { compileClassDebugInfo, compileHmrInitializer, compileComponentClassMetadata, compileComponentDeclareClassMetadata, compileComponentFromMetadata, compileDeclareComponentFromMetadata, compileDeferResolverFunction, ConstantPool as ConstantPool2, CssSelector as CssSelector5, DomElementSchemaRegistry as DomElementSchemaRegistry3, ExternalExpr as
|
|
9839
|
+
import { compileClassDebugInfo, compileHmrInitializer, compileComponentClassMetadata, compileComponentDeclareClassMetadata, compileComponentFromMetadata, compileDeclareComponentFromMetadata, compileDeferResolverFunction, ConstantPool as ConstantPool2, CssSelector as CssSelector5, DomElementSchemaRegistry as DomElementSchemaRegistry3, ExternalExpr as ExternalExpr11, 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";
|
|
9840
9840
|
import ts79 from "typescript";
|
|
9841
9841
|
|
|
9842
9842
|
// packages/compiler-cli/src/ngtsc/incremental/semantic_graph/src/api.js
|
|
@@ -10955,7 +10955,7 @@ var TypeCheckScopeRegistry = class {
|
|
|
10955
10955
|
};
|
|
10956
10956
|
|
|
10957
10957
|
// packages/compiler-cli/src/ngtsc/annotations/directive/src/handler.js
|
|
10958
|
-
import { compileClassMetadata, compileDeclareClassMetadata, compileDeclareDirectiveFromMetadata, compileDirectiveFromMetadata, FactoryTarget, makeBindingParser as makeBindingParser2, R3TargetBinder, WrappedNodeExpr as
|
|
10958
|
+
import { compileClassMetadata, compileDeclareClassMetadata, compileDeclareDirectiveFromMetadata, compileDirectiveFromMetadata, FactoryTarget, makeBindingParser as makeBindingParser2, R3TargetBinder, WrappedNodeExpr as WrappedNodeExpr9 } from "@angular/compiler";
|
|
10959
10959
|
import ts72 from "typescript";
|
|
10960
10960
|
|
|
10961
10961
|
// packages/compiler-cli/src/ngtsc/annotations/directive/src/symbol.js
|
|
@@ -11045,7 +11045,7 @@ function isBaseClassEqual(current, previous) {
|
|
|
11045
11045
|
}
|
|
11046
11046
|
|
|
11047
11047
|
// packages/compiler-cli/src/ngtsc/typecheck/src/checker.js
|
|
11048
|
-
import { CssSelector as CssSelector4, DomElementSchemaRegistry as DomElementSchemaRegistry2, ExternalExpr as
|
|
11048
|
+
import { CssSelector as CssSelector4, DomElementSchemaRegistry as DomElementSchemaRegistry2, ExternalExpr as ExternalExpr9, WrappedNodeExpr as WrappedNodeExpr8 } from "@angular/compiler";
|
|
11049
11049
|
|
|
11050
11050
|
// packages/compiler-cli/src/ngtsc/typecheck/src/ts_util.js
|
|
11051
11051
|
import ts48 from "typescript";
|
|
@@ -12783,247 +12783,19 @@ var MagicString = class _MagicString {
|
|
|
12783
12783
|
// packages/compiler-cli/src/ngtsc/typecheck/src/context.js
|
|
12784
12784
|
import ts68 from "typescript";
|
|
12785
12785
|
|
|
12786
|
-
// packages/compiler-cli/src/ngtsc/typecheck/src/
|
|
12787
|
-
import {
|
|
12788
|
-
import ts52 from "typescript";
|
|
12789
|
-
var REGISTRY = new DomElementSchemaRegistry();
|
|
12790
|
-
var REMOVE_XHTML_REGEX = /^:xhtml:/;
|
|
12791
|
-
var RegistryDomSchemaChecker = class {
|
|
12792
|
-
resolver;
|
|
12793
|
-
_diagnostics = [];
|
|
12794
|
-
get diagnostics() {
|
|
12795
|
-
return this._diagnostics;
|
|
12796
|
-
}
|
|
12797
|
-
constructor(resolver) {
|
|
12798
|
-
this.resolver = resolver;
|
|
12799
|
-
}
|
|
12800
|
-
checkElement(id, tagName, sourceSpanForDiagnostics, schemas, hostIsStandalone) {
|
|
12801
|
-
const name = tagName.replace(REMOVE_XHTML_REGEX, "");
|
|
12802
|
-
if (!REGISTRY.hasElement(name, schemas)) {
|
|
12803
|
-
const mapping = this.resolver.getTemplateSourceMapping(id);
|
|
12804
|
-
const schemas2 = `'${hostIsStandalone ? "@Component" : "@NgModule"}.schemas'`;
|
|
12805
|
-
let errorMsg = `'${name}' is not a known element:
|
|
12806
|
-
`;
|
|
12807
|
-
errorMsg += `1. If '${name}' is an Angular component, then verify that it is ${hostIsStandalone ? "included in the '@Component.imports' of this component" : "part of this module"}.
|
|
12808
|
-
`;
|
|
12809
|
-
if (name.indexOf("-") > -1) {
|
|
12810
|
-
errorMsg += `2. If '${name}' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the ${schemas2} of this component to suppress this message.`;
|
|
12811
|
-
} else {
|
|
12812
|
-
errorMsg += `2. To allow any element add 'NO_ERRORS_SCHEMA' to the ${schemas2} of this component.`;
|
|
12813
|
-
}
|
|
12814
|
-
const diag = makeTemplateDiagnostic(id, mapping, sourceSpanForDiagnostics, ts52.DiagnosticCategory.Error, ngErrorCode(ErrorCode.SCHEMA_INVALID_ELEMENT), errorMsg);
|
|
12815
|
-
this._diagnostics.push(diag);
|
|
12816
|
-
}
|
|
12817
|
-
}
|
|
12818
|
-
checkTemplateElementProperty(id, tagName, name, span, schemas, hostIsStandalone) {
|
|
12819
|
-
if (!REGISTRY.hasProperty(tagName, name, schemas)) {
|
|
12820
|
-
const mapping = this.resolver.getTemplateSourceMapping(id);
|
|
12821
|
-
const decorator = hostIsStandalone ? "@Component" : "@NgModule";
|
|
12822
|
-
const schemas2 = `'${decorator}.schemas'`;
|
|
12823
|
-
let errorMsg = `Can't bind to '${name}' since it isn't a known property of '${tagName}'.`;
|
|
12824
|
-
if (tagName.startsWith("ng-")) {
|
|
12825
|
-
errorMsg += `
|
|
12826
|
-
1. If '${name}' is an Angular directive, then add 'CommonModule' to the '${decorator}.imports' of this component.
|
|
12827
|
-
2. To allow any property add 'NO_ERRORS_SCHEMA' to the ${schemas2} of this component.`;
|
|
12828
|
-
} else if (tagName.indexOf("-") > -1) {
|
|
12829
|
-
errorMsg += `
|
|
12830
|
-
1. If '${tagName}' is an Angular component and it has '${name}' input, then verify that it is ${hostIsStandalone ? "included in the '@Component.imports' of this component" : "part of this module"}.
|
|
12831
|
-
2. If '${tagName}' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the ${schemas2} of this component to suppress this message.
|
|
12832
|
-
3. To allow any property add 'NO_ERRORS_SCHEMA' to the ${schemas2} of this component.`;
|
|
12833
|
-
}
|
|
12834
|
-
const diag = makeTemplateDiagnostic(id, mapping, span, ts52.DiagnosticCategory.Error, ngErrorCode(ErrorCode.SCHEMA_INVALID_ATTRIBUTE), errorMsg);
|
|
12835
|
-
this._diagnostics.push(diag);
|
|
12836
|
-
}
|
|
12837
|
-
}
|
|
12838
|
-
checkHostElementProperty(id, element, name, span, schemas) {
|
|
12839
|
-
for (const tagName of element.tagNames) {
|
|
12840
|
-
if (REGISTRY.hasProperty(tagName, name, schemas)) {
|
|
12841
|
-
continue;
|
|
12842
|
-
}
|
|
12843
|
-
const errorMessage = `Can't bind to '${name}' since it isn't a known property of '${tagName}'.`;
|
|
12844
|
-
const mapping = this.resolver.getHostBindingsMapping(id);
|
|
12845
|
-
const diag = makeTemplateDiagnostic(id, mapping, span, ts52.DiagnosticCategory.Error, ngErrorCode(ErrorCode.SCHEMA_INVALID_ATTRIBUTE), errorMessage);
|
|
12846
|
-
this._diagnostics.push(diag);
|
|
12847
|
-
break;
|
|
12848
|
-
}
|
|
12849
|
-
}
|
|
12850
|
-
};
|
|
12851
|
-
|
|
12852
|
-
// packages/compiler-cli/src/ngtsc/typecheck/src/environment.js
|
|
12853
|
-
import ts59 from "typescript";
|
|
12854
|
-
|
|
12855
|
-
// packages/compiler-cli/src/ngtsc/typecheck/src/reference_emit_environment.js
|
|
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
|
|
12959
|
-
var ReferenceEmitEnvironment = class {
|
|
12960
|
-
importManager;
|
|
12961
|
-
refEmitter;
|
|
12962
|
-
reflector;
|
|
12963
|
-
contextFile;
|
|
12964
|
-
constructor(importManager, refEmitter, reflector, contextFile) {
|
|
12965
|
-
this.importManager = importManager;
|
|
12966
|
-
this.refEmitter = refEmitter;
|
|
12967
|
-
this.reflector = reflector;
|
|
12968
|
-
this.contextFile = contextFile;
|
|
12969
|
-
}
|
|
12970
|
-
canReferenceType(ref, flags = ImportFlags.NoAliasing | ImportFlags.AllowTypeImports | ImportFlags.AllowRelativeDtsImports) {
|
|
12971
|
-
const result = this.refEmitter.emit(ref, this.contextFile, flags);
|
|
12972
|
-
return result.kind === ReferenceEmitKind.Success;
|
|
12973
|
-
}
|
|
12974
|
-
/**
|
|
12975
|
-
* Generate a `ts.TypeNode` that references the given node as a type.
|
|
12976
|
-
*
|
|
12977
|
-
* This may involve importing the node into the file if it's not declared there already.
|
|
12978
|
-
*/
|
|
12979
|
-
referenceType(ref, flags = ImportFlags.NoAliasing | ImportFlags.AllowTypeImports | ImportFlags.AllowRelativeDtsImports) {
|
|
12980
|
-
const ngExpr = this.refEmitter.emit(ref, this.contextFile, flags);
|
|
12981
|
-
assertSuccessfulReferenceEmit(ngExpr, this.contextFile, "symbol");
|
|
12982
|
-
return translateType(new ExpressionType(ngExpr.expression), this.contextFile, this.reflector, this.refEmitter, this.importManager);
|
|
12983
|
-
}
|
|
12984
|
-
referenceExternalSymbol(moduleName, name) {
|
|
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");
|
|
12996
|
-
}
|
|
12997
|
-
/**
|
|
12998
|
-
* Generate a `ts.TypeNode` that references a given type from the provided module.
|
|
12999
|
-
*
|
|
13000
|
-
* This will involve importing the type into the file, and will also add type parameters if
|
|
13001
|
-
* provided.
|
|
13002
|
-
*/
|
|
13003
|
-
referenceExternalType(moduleName, name, typeParams) {
|
|
13004
|
-
const external = new ExternalExpr7({ moduleName, name });
|
|
13005
|
-
return translateType(new ExpressionType(external, TypeModifier.None, typeParams), this.contextFile, this.reflector, this.refEmitter, this.importManager);
|
|
13006
|
-
}
|
|
13007
|
-
/**
|
|
13008
|
-
* Generates a `ts.TypeNode` representing a type that is being referenced from a different place
|
|
13009
|
-
* in the program. Any type references inside the transplanted type will be rewritten so that
|
|
13010
|
-
* they can be imported in the context file.
|
|
13011
|
-
*/
|
|
13012
|
-
referenceTransplantedType(type) {
|
|
13013
|
-
return translateType(type, this.contextFile, this.reflector, this.refEmitter, this.importManager);
|
|
13014
|
-
}
|
|
13015
|
-
};
|
|
12786
|
+
// packages/compiler-cli/src/ngtsc/typecheck/src/tcb_adapter.js
|
|
12787
|
+
import { AbsoluteSourceSpan as AbsoluteSourceSpan4, ExternalExpr as ExternalExpr7, TransplantedType, WrappedNodeExpr as WrappedNodeExpr7 } from "@angular/compiler";
|
|
13016
12788
|
|
|
13017
12789
|
// packages/compiler-cli/src/ngtsc/typecheck/src/type_constructor.js
|
|
13018
12790
|
import { R3Identifiers as R3Identifiers3 } from "@angular/compiler";
|
|
13019
|
-
import
|
|
12791
|
+
import ts56 from "typescript";
|
|
13020
12792
|
|
|
13021
12793
|
// packages/compiler-cli/src/ngtsc/typecheck/src/tcb_util.js
|
|
13022
12794
|
import { R3Identifiers as R3Identifiers2 } from "@angular/compiler";
|
|
13023
|
-
import
|
|
12795
|
+
import ts55 from "typescript";
|
|
13024
12796
|
|
|
13025
12797
|
// packages/compiler-cli/src/ngtsc/typecheck/src/type_parameter_emitter.js
|
|
13026
|
-
import
|
|
12798
|
+
import ts52 from "typescript";
|
|
13027
12799
|
var TypeParameterEmitter = class {
|
|
13028
12800
|
typeParameters;
|
|
13029
12801
|
reflector;
|
|
@@ -13070,11 +12842,11 @@ var TypeParameterEmitter = class {
|
|
|
13070
12842
|
return this.typeParameters.map((typeParam) => {
|
|
13071
12843
|
const constraint = typeParam.constraint !== void 0 ? emitter.emitType(typeParam.constraint) : void 0;
|
|
13072
12844
|
const defaultType = typeParam.default !== void 0 ? emitter.emitType(typeParam.default) : void 0;
|
|
13073
|
-
return
|
|
12845
|
+
return ts52.factory.updateTypeParameterDeclaration(typeParam, typeParam.modifiers, typeParam.name, constraint, defaultType);
|
|
13074
12846
|
});
|
|
13075
12847
|
}
|
|
13076
12848
|
resolveTypeReference(type) {
|
|
13077
|
-
const target =
|
|
12849
|
+
const target = ts52.isIdentifier(type.typeName) ? type.typeName : type.typeName.right;
|
|
13078
12850
|
const declaration = this.reflector.getDeclarationOfIdentifier(target);
|
|
13079
12851
|
if (declaration === null || declaration.node === null) {
|
|
13080
12852
|
return null;
|
|
@@ -13100,8 +12872,8 @@ var TypeParameterEmitter = class {
|
|
|
13100
12872
|
if (typeNode === null) {
|
|
13101
12873
|
return null;
|
|
13102
12874
|
}
|
|
13103
|
-
if (!
|
|
13104
|
-
throw new Error(`Expected TypeReferenceNode for emitted reference, got ${
|
|
12875
|
+
if (!ts52.isTypeReferenceNode(typeNode)) {
|
|
12876
|
+
throw new Error(`Expected TypeReferenceNode for emitted reference, got ${ts52.SyntaxKind[typeNode.kind]}.`);
|
|
13105
12877
|
}
|
|
13106
12878
|
return typeNode;
|
|
13107
12879
|
}
|
|
@@ -13111,8 +12883,8 @@ var TypeParameterEmitter = class {
|
|
|
13111
12883
|
};
|
|
13112
12884
|
|
|
13113
12885
|
// packages/compiler-cli/src/ngtsc/typecheck/src/host_bindings.js
|
|
13114
|
-
import { BindingType, CssSelector as CssSelector2, makeBindingParser, TmplAstBoundAttribute, TmplAstBoundEvent, TmplAstHostElement, AbsoluteSourceSpan as
|
|
13115
|
-
import
|
|
12886
|
+
import { BindingType, CssSelector as CssSelector2, makeBindingParser, TmplAstBoundAttribute, TmplAstBoundEvent, TmplAstHostElement, AbsoluteSourceSpan as AbsoluteSourceSpan2, ParseSpan, PropertyRead as PropertyRead2, ParsedEventType, Call, ThisReceiver as ThisReceiver2, KeyedRead, LiteralPrimitive, RecursiveAstVisitor, ASTWithName, SafeCall, ImplicitReceiver as ImplicitReceiver2 } from "@angular/compiler";
|
|
12887
|
+
import ts53 from "typescript";
|
|
13116
12888
|
var GUARD_COMMENT_TEXT = "hostBindingsBlockGuard";
|
|
13117
12889
|
function createHostElement(type, selector, sourceNode, literal4, bindingDecorators, listenerDecorators) {
|
|
13118
12890
|
const bindings = [];
|
|
@@ -13120,7 +12892,7 @@ function createHostElement(type, selector, sourceNode, literal4, bindingDecorato
|
|
|
13120
12892
|
let parser = null;
|
|
13121
12893
|
if (literal4 !== null) {
|
|
13122
12894
|
for (const prop of literal4.properties) {
|
|
13123
|
-
if (
|
|
12895
|
+
if (ts53.isPropertyAssignment(prop) && ts53.isStringLiteralLike(prop.initializer) && isStaticName(prop.name)) {
|
|
13124
12896
|
parser ??= makeBindingParser();
|
|
13125
12897
|
createNodeFromHostLiteralProperty(prop, parser, bindings, listeners);
|
|
13126
12898
|
}
|
|
@@ -13154,15 +12926,15 @@ function createHostBindingsBlockGuard() {
|
|
|
13154
12926
|
return `(true /*${GUARD_COMMENT_TEXT}*/)`;
|
|
13155
12927
|
}
|
|
13156
12928
|
function isHostBindingsBlockGuard(node) {
|
|
13157
|
-
if (!
|
|
12929
|
+
if (!ts53.isIfStatement(node)) {
|
|
13158
12930
|
return false;
|
|
13159
12931
|
}
|
|
13160
12932
|
const expr = node.expression;
|
|
13161
|
-
if (!
|
|
12933
|
+
if (!ts53.isParenthesizedExpression(expr) || expr.expression.kind !== ts53.SyntaxKind.TrueKeyword) {
|
|
13162
12934
|
return false;
|
|
13163
12935
|
}
|
|
13164
12936
|
const text = expr.getSourceFile().text;
|
|
13165
|
-
return
|
|
12937
|
+
return ts53.forEachTrailingCommentRange(text, expr.expression.getEnd(), (pos, end, kind) => kind === ts53.SyntaxKind.MultiLineCommentTrivia && text.substring(pos + 2, end - 2) === GUARD_COMMENT_TEXT) || false;
|
|
13166
12938
|
}
|
|
13167
12939
|
function createNodeFromHostLiteralProperty(property, parser, bindings, listeners) {
|
|
13168
12940
|
const { name, initializer } = property;
|
|
@@ -13186,19 +12958,19 @@ function createNodeFromHostLiteralProperty(property, parser, bindings, listeners
|
|
|
13186
12958
|
}
|
|
13187
12959
|
}
|
|
13188
12960
|
function createNodeFromBindingDecorator(decorator, bindings) {
|
|
13189
|
-
if (!
|
|
12961
|
+
if (!ts53.isCallExpression(decorator.expression)) {
|
|
13190
12962
|
return;
|
|
13191
12963
|
}
|
|
13192
12964
|
const args = decorator.expression.arguments;
|
|
13193
12965
|
const property = decorator.parent;
|
|
13194
12966
|
let nameNode = null;
|
|
13195
12967
|
let propertyName = null;
|
|
13196
|
-
if (property &&
|
|
12968
|
+
if (property && ts53.isPropertyDeclaration(property) && isStaticName(property.name)) {
|
|
13197
12969
|
propertyName = property.name;
|
|
13198
12970
|
}
|
|
13199
12971
|
if (args.length === 0) {
|
|
13200
12972
|
nameNode = propertyName;
|
|
13201
|
-
} else if (
|
|
12973
|
+
} else if (ts53.isStringLiteralLike(args[0])) {
|
|
13202
12974
|
nameNode = args[0];
|
|
13203
12975
|
} else {
|
|
13204
12976
|
return;
|
|
@@ -13208,36 +12980,36 @@ function createNodeFromBindingDecorator(decorator, bindings) {
|
|
|
13208
12980
|
}
|
|
13209
12981
|
const span = new ParseSpan(-1, -1);
|
|
13210
12982
|
const propertyStart = property.getStart();
|
|
13211
|
-
const receiver = new ThisReceiver2(span, new
|
|
13212
|
-
const nameSpan = new
|
|
13213
|
-
const read =
|
|
12983
|
+
const receiver = new ThisReceiver2(span, new AbsoluteSourceSpan2(propertyStart, propertyStart));
|
|
12984
|
+
const nameSpan = new AbsoluteSourceSpan2(propertyName.getStart(), propertyName.getEnd());
|
|
12985
|
+
const read = ts53.isIdentifier(propertyName) ? new PropertyRead2(span, nameSpan, nameSpan, receiver, propertyName.text) : new KeyedRead(span, nameSpan, receiver, new LiteralPrimitive(span, nameSpan, propertyName.text));
|
|
13214
12986
|
const { attrName, type } = inferBoundAttribute(nameNode.text);
|
|
13215
12987
|
bindings.push(new TmplAstBoundAttribute(attrName, type, 0, read, null, createSourceSpan(decorator), createStaticExpressionSpan(nameNode), createSourceSpan(decorator), void 0));
|
|
13216
12988
|
}
|
|
13217
12989
|
function createNodeFromListenerDecorator(decorator, parser, listeners) {
|
|
13218
|
-
if (!
|
|
12990
|
+
if (!ts53.isCallExpression(decorator.expression) || decorator.expression.arguments.length === 0) {
|
|
13219
12991
|
return;
|
|
13220
12992
|
}
|
|
13221
12993
|
const args = decorator.expression.arguments;
|
|
13222
12994
|
const method = decorator.parent;
|
|
13223
|
-
if (!method || !
|
|
12995
|
+
if (!method || !ts53.isMethodDeclaration(method) || !isStaticName(method.name) || !ts53.isStringLiteralLike(args[0])) {
|
|
13224
12996
|
return;
|
|
13225
12997
|
}
|
|
13226
12998
|
const span = new ParseSpan(-1, -1);
|
|
13227
12999
|
const argNodes = [];
|
|
13228
13000
|
const methodStart = method.getStart();
|
|
13229
|
-
const methodReceiver = new ThisReceiver2(span, new
|
|
13230
|
-
const nameSpan = new
|
|
13231
|
-
const receiver =
|
|
13232
|
-
if (args.length > 1 &&
|
|
13001
|
+
const methodReceiver = new ThisReceiver2(span, new AbsoluteSourceSpan2(methodStart, methodStart));
|
|
13002
|
+
const nameSpan = new AbsoluteSourceSpan2(method.name.getStart(), method.name.getEnd());
|
|
13003
|
+
const receiver = ts53.isIdentifier(method.name) ? new PropertyRead2(span, nameSpan, nameSpan, methodReceiver, method.name.text) : new KeyedRead(span, nameSpan, methodReceiver, new LiteralPrimitive(span, nameSpan, method.name.text));
|
|
13004
|
+
if (args.length > 1 && ts53.isArrayLiteralExpression(args[1])) {
|
|
13233
13005
|
for (const expr of args[1].elements) {
|
|
13234
|
-
if (
|
|
13006
|
+
if (ts53.isStringLiteralLike(expr)) {
|
|
13235
13007
|
const span2 = createStaticExpressionSpan(expr);
|
|
13236
13008
|
const ast = parser.parseBinding(expr.text, true, span2, span2.start.offset);
|
|
13237
13009
|
fixupSpans(ast, expr);
|
|
13238
13010
|
argNodes.push(ast);
|
|
13239
13011
|
} else {
|
|
13240
|
-
const expressionSpan = new
|
|
13012
|
+
const expressionSpan = new AbsoluteSourceSpan2(expr.getStart(), expr.getEnd());
|
|
13241
13013
|
const anyRead = new PropertyRead2(span, expressionSpan, expressionSpan, new ImplicitReceiver2(span, expressionSpan), "$any");
|
|
13242
13014
|
const anyCall = new Call(span, expressionSpan, anyRead, [new LiteralPrimitive(span, expressionSpan, 0)], expressionSpan);
|
|
13243
13015
|
argNodes.push(anyCall);
|
|
@@ -13295,11 +13067,11 @@ function inferBoundAttribute(name) {
|
|
|
13295
13067
|
return { attrName, type };
|
|
13296
13068
|
}
|
|
13297
13069
|
function isStaticName(node) {
|
|
13298
|
-
return
|
|
13070
|
+
return ts53.isIdentifier(node) || ts53.isStringLiteralLike(node);
|
|
13299
13071
|
}
|
|
13300
13072
|
function createStaticExpressionSpan(node) {
|
|
13301
13073
|
const span = createSourceSpan(node);
|
|
13302
|
-
if (
|
|
13074
|
+
if (ts53.isStringLiteralLike(node)) {
|
|
13303
13075
|
span.fullStart = span.fullStart.moveBy(1);
|
|
13304
13076
|
span.start = span.start.moveBy(1);
|
|
13305
13077
|
span.end = span.end.moveBy(-1);
|
|
@@ -13310,34 +13082,133 @@ function fixupSpans(ast, initializer) {
|
|
|
13310
13082
|
const escapeIndex = initializer.getText().indexOf("\\", 1);
|
|
13311
13083
|
if (escapeIndex > -1) {
|
|
13312
13084
|
const newSpan = new ParseSpan(0, initializer.getWidth());
|
|
13313
|
-
const newSourceSpan = new
|
|
13085
|
+
const newSourceSpan = new AbsoluteSourceSpan2(initializer.getStart(), initializer.getEnd());
|
|
13314
13086
|
ast.visit(new ReplaceSpanVisitor(escapeIndex, newSpan, newSourceSpan));
|
|
13315
13087
|
}
|
|
13316
|
-
}
|
|
13317
|
-
var ReplaceSpanVisitor = class extends RecursiveAstVisitor {
|
|
13318
|
-
afterIndex;
|
|
13319
|
-
overrideSpan;
|
|
13320
|
-
overrideSourceSpan;
|
|
13321
|
-
constructor(afterIndex, overrideSpan, overrideSourceSpan) {
|
|
13322
|
-
super();
|
|
13323
|
-
this.afterIndex = afterIndex;
|
|
13324
|
-
this.overrideSpan = overrideSpan;
|
|
13325
|
-
this.overrideSourceSpan = overrideSourceSpan;
|
|
13088
|
+
}
|
|
13089
|
+
var ReplaceSpanVisitor = class extends RecursiveAstVisitor {
|
|
13090
|
+
afterIndex;
|
|
13091
|
+
overrideSpan;
|
|
13092
|
+
overrideSourceSpan;
|
|
13093
|
+
constructor(afterIndex, overrideSpan, overrideSourceSpan) {
|
|
13094
|
+
super();
|
|
13095
|
+
this.afterIndex = afterIndex;
|
|
13096
|
+
this.overrideSpan = overrideSpan;
|
|
13097
|
+
this.overrideSourceSpan = overrideSourceSpan;
|
|
13098
|
+
}
|
|
13099
|
+
visit(ast) {
|
|
13100
|
+
if (ast.span.start >= this.afterIndex || ast.span.end >= this.afterIndex) {
|
|
13101
|
+
ast.span = this.overrideSpan;
|
|
13102
|
+
ast.sourceSpan = this.overrideSourceSpan;
|
|
13103
|
+
if (ast instanceof ASTWithName) {
|
|
13104
|
+
ast.nameSpan = this.overrideSourceSpan;
|
|
13105
|
+
}
|
|
13106
|
+
if (ast instanceof Call || ast instanceof SafeCall) {
|
|
13107
|
+
ast.argumentSpan = this.overrideSourceSpan;
|
|
13108
|
+
}
|
|
13109
|
+
}
|
|
13110
|
+
super.visit(ast);
|
|
13111
|
+
}
|
|
13112
|
+
};
|
|
13113
|
+
|
|
13114
|
+
// packages/compiler-cli/src/ngtsc/typecheck/src/ops/codegen.js
|
|
13115
|
+
import { AbsoluteSourceSpan as AbsoluteSourceSpan3 } from "@angular/compiler";
|
|
13116
|
+
import ts54 from "typescript";
|
|
13117
|
+
var TcbExpr = class {
|
|
13118
|
+
source;
|
|
13119
|
+
/** Text for the content containing the expression's location information. */
|
|
13120
|
+
spanComment = null;
|
|
13121
|
+
/** Text for the content containing the expression's identifier. */
|
|
13122
|
+
identifierComment = null;
|
|
13123
|
+
/**
|
|
13124
|
+
* Text of the comment instructing the type checker to
|
|
13125
|
+
* ignore diagnostics coming from this expression.
|
|
13126
|
+
*/
|
|
13127
|
+
ignoreComment = null;
|
|
13128
|
+
constructor(source) {
|
|
13129
|
+
this.source = source;
|
|
13130
|
+
}
|
|
13131
|
+
/**
|
|
13132
|
+
* Converts the node's current state to a string.
|
|
13133
|
+
* @param ignoreComments Whether the comments associated with the expression should be skipped.
|
|
13134
|
+
*/
|
|
13135
|
+
print(ignoreComments = false) {
|
|
13136
|
+
if (ignoreComments) {
|
|
13137
|
+
return this.source;
|
|
13138
|
+
}
|
|
13139
|
+
return this.source + this.formatComment(this.identifierComment) + this.formatComment(this.ignoreComment) + this.formatComment(this.spanComment);
|
|
13140
|
+
}
|
|
13141
|
+
/**
|
|
13142
|
+
* Adds a synthetic comment to the expression that represents the parse span of the provided node.
|
|
13143
|
+
* This comment can later be retrieved as trivia of a node to recover original source locations.
|
|
13144
|
+
* @param span Span from the parser containing the location information.
|
|
13145
|
+
*/
|
|
13146
|
+
addParseSpanInfo(span) {
|
|
13147
|
+
let start;
|
|
13148
|
+
let end;
|
|
13149
|
+
if (span instanceof AbsoluteSourceSpan3) {
|
|
13150
|
+
start = span.start;
|
|
13151
|
+
end = span.end;
|
|
13152
|
+
} else {
|
|
13153
|
+
start = span.start.offset;
|
|
13154
|
+
end = span.end.offset;
|
|
13155
|
+
}
|
|
13156
|
+
this.spanComment = `${start},${end}`;
|
|
13157
|
+
return this;
|
|
13158
|
+
}
|
|
13159
|
+
/** Marks the expression to be ignored for diagnostics. */
|
|
13160
|
+
markIgnoreDiagnostics() {
|
|
13161
|
+
this.ignoreComment = `${CommentTriviaType.DIAGNOSTIC}:ignore`;
|
|
13162
|
+
return this;
|
|
13163
|
+
}
|
|
13164
|
+
/**
|
|
13165
|
+
* Wraps the expression in parenthesis such that inserted
|
|
13166
|
+
* span comments become attached to the proper node.
|
|
13167
|
+
*/
|
|
13168
|
+
wrapForTypeChecker() {
|
|
13169
|
+
this.source = `(${this.print()})`;
|
|
13170
|
+
this.spanComment = this.identifierComment = this.ignoreComment = null;
|
|
13171
|
+
return this;
|
|
13172
|
+
}
|
|
13173
|
+
/**
|
|
13174
|
+
* Tags the expression with an identifier.
|
|
13175
|
+
* @param identifier Identifier to apply to the expression.
|
|
13176
|
+
*/
|
|
13177
|
+
addExpressionIdentifier(identifier) {
|
|
13178
|
+
this.identifierComment = `${CommentTriviaType.EXPRESSION_TYPE_IDENTIFIER}:${identifier}`;
|
|
13179
|
+
return this;
|
|
13180
|
+
}
|
|
13181
|
+
/**
|
|
13182
|
+
* `toString` implementation meant to catch errors like accidentally
|
|
13183
|
+
* writing `foo ${expr} bar` instead of `foo ${expr.print()} bar`.
|
|
13184
|
+
*/
|
|
13185
|
+
toString() {
|
|
13186
|
+
throw new Error("Assertion error: TcbExpr should not be converted to a string through concatenation. Use the `print` method instead.");
|
|
13326
13187
|
}
|
|
13327
|
-
|
|
13328
|
-
|
|
13329
|
-
|
|
13330
|
-
ast.sourceSpan = this.overrideSourceSpan;
|
|
13331
|
-
if (ast instanceof ASTWithName) {
|
|
13332
|
-
ast.nameSpan = this.overrideSourceSpan;
|
|
13333
|
-
}
|
|
13334
|
-
if (ast instanceof Call || ast instanceof SafeCall) {
|
|
13335
|
-
ast.argumentSpan = this.overrideSourceSpan;
|
|
13336
|
-
}
|
|
13337
|
-
}
|
|
13338
|
-
super.visit(ast);
|
|
13188
|
+
/** Format a comment string as a TypeScript comment. */
|
|
13189
|
+
formatComment(content) {
|
|
13190
|
+
return content === null || content.length === 0 ? "" : ` /*${content}*/`;
|
|
13339
13191
|
}
|
|
13340
13192
|
};
|
|
13193
|
+
function declareVariable(identifier, type) {
|
|
13194
|
+
type.addExpressionIdentifier(ExpressionIdentifier.VARIABLE_AS_EXPRESSION);
|
|
13195
|
+
return new TcbExpr(`var ${identifier.print()} = null! as ${type.print()}`);
|
|
13196
|
+
}
|
|
13197
|
+
function getStatementsBlock(expressions, singleLine = false) {
|
|
13198
|
+
let result = "";
|
|
13199
|
+
for (const expr of expressions) {
|
|
13200
|
+
result += `${expr.print()};${singleLine ? " " : "\n"}`;
|
|
13201
|
+
}
|
|
13202
|
+
return result;
|
|
13203
|
+
}
|
|
13204
|
+
function quoteAndEscape(value) {
|
|
13205
|
+
return JSON.stringify(value);
|
|
13206
|
+
}
|
|
13207
|
+
var tempPrinter = null;
|
|
13208
|
+
function tempPrint(node, sourceFile) {
|
|
13209
|
+
tempPrinter ??= ts54.createPrinter();
|
|
13210
|
+
return tempPrinter.printNode(ts54.EmitHint.Unspecified, node, sourceFile);
|
|
13211
|
+
}
|
|
13341
13212
|
|
|
13342
13213
|
// packages/compiler-cli/src/ngtsc/typecheck/src/tcb_util.js
|
|
13343
13214
|
var TCB_FILE_IMPORT_GRAPH_PREPARE_IDENTIFIERS = [
|
|
@@ -13389,7 +13260,7 @@ function getSourceMapping(shimSf, position, resolver, isDiagnosticRequest) {
|
|
|
13389
13260
|
}
|
|
13390
13261
|
function isInHostBindingTcb(node) {
|
|
13391
13262
|
let current = node;
|
|
13392
|
-
while (current && !
|
|
13263
|
+
while (current && !ts55.isFunctionDeclaration(current)) {
|
|
13393
13264
|
if (isHostBindingsBlockGuard(current)) {
|
|
13394
13265
|
return true;
|
|
13395
13266
|
}
|
|
@@ -13399,14 +13270,14 @@ function isInHostBindingTcb(node) {
|
|
|
13399
13270
|
}
|
|
13400
13271
|
function findTypeCheckBlock(file, id, isDiagnosticRequest) {
|
|
13401
13272
|
for (const stmt of file.statements) {
|
|
13402
|
-
if (
|
|
13273
|
+
if (ts55.isFunctionDeclaration(stmt) && getTypeCheckId2(stmt, file, isDiagnosticRequest) === id) {
|
|
13403
13274
|
return stmt;
|
|
13404
13275
|
}
|
|
13405
13276
|
}
|
|
13406
|
-
return findNodeInFile(file, (node) =>
|
|
13277
|
+
return findNodeInFile(file, (node) => ts55.isFunctionDeclaration(node) && getTypeCheckId2(node, file, isDiagnosticRequest) === id);
|
|
13407
13278
|
}
|
|
13408
13279
|
function findSourceLocation(node, sourceFile, isDiagnosticsRequest) {
|
|
13409
|
-
while (node !== void 0 && !
|
|
13280
|
+
while (node !== void 0 && !ts55.isFunctionDeclaration(node)) {
|
|
13410
13281
|
if (hasIgnoreForDiagnosticsMarker(node, sourceFile) && isDiagnosticsRequest) {
|
|
13411
13282
|
return null;
|
|
13412
13283
|
}
|
|
@@ -13423,7 +13294,7 @@ function findSourceLocation(node, sourceFile, isDiagnosticsRequest) {
|
|
|
13423
13294
|
return null;
|
|
13424
13295
|
}
|
|
13425
13296
|
function getTypeCheckId2(node, sourceFile, isDiagnosticRequest) {
|
|
13426
|
-
while (!
|
|
13297
|
+
while (!ts55.isFunctionDeclaration(node)) {
|
|
13427
13298
|
if (hasIgnoreForDiagnosticsMarker(node, sourceFile) && isDiagnosticRequest) {
|
|
13428
13299
|
return null;
|
|
13429
13300
|
}
|
|
@@ -13433,8 +13304,8 @@ function getTypeCheckId2(node, sourceFile, isDiagnosticRequest) {
|
|
|
13433
13304
|
}
|
|
13434
13305
|
}
|
|
13435
13306
|
const start = node.getFullStart();
|
|
13436
|
-
return
|
|
13437
|
-
if (kind !==
|
|
13307
|
+
return ts55.forEachLeadingCommentRange(sourceFile.text, start, (pos, end, kind) => {
|
|
13308
|
+
if (kind !== ts55.SyntaxKind.MultiLineCommentTrivia) {
|
|
13438
13309
|
return null;
|
|
13439
13310
|
}
|
|
13440
13311
|
const commentText = sourceFile.text.substring(pos + 2, end - 2);
|
|
@@ -13459,17 +13330,27 @@ function findNodeInFile(file, predicate) {
|
|
|
13459
13330
|
if (predicate(node)) {
|
|
13460
13331
|
return node;
|
|
13461
13332
|
}
|
|
13462
|
-
return
|
|
13333
|
+
return ts55.forEachChild(node, visit2) ?? null;
|
|
13463
13334
|
};
|
|
13464
|
-
return
|
|
13335
|
+
return ts55.forEachChild(file, visit2) ?? null;
|
|
13336
|
+
}
|
|
13337
|
+
function generateTcbTypeParameters(typeParameters, sourceFile) {
|
|
13338
|
+
return typeParameters.map((p) => {
|
|
13339
|
+
const representation = tempPrint(p, sourceFile);
|
|
13340
|
+
return {
|
|
13341
|
+
name: p.name.text,
|
|
13342
|
+
representation,
|
|
13343
|
+
representationWithDefault: p.default ? representation : `${representation} = any`
|
|
13344
|
+
};
|
|
13345
|
+
});
|
|
13465
13346
|
}
|
|
13466
13347
|
|
|
13467
13348
|
// packages/compiler-cli/src/ngtsc/typecheck/src/type_constructor.js
|
|
13468
13349
|
function generateTypeCtorDeclarationFn(env, meta, nodeTypeRef, typeParams) {
|
|
13469
13350
|
const typeArgs = generateGenericArgs(typeParams);
|
|
13470
|
-
const typeRef =
|
|
13351
|
+
const typeRef = ts56.isIdentifier(nodeTypeRef) ? nodeTypeRef.text : tempPrint(nodeTypeRef, nodeTypeRef.getSourceFile());
|
|
13471
13352
|
const typeRefWithGenerics = `${typeRef}${typeArgs}`;
|
|
13472
|
-
const initParam = constructTypeCtorParameter(env, meta,
|
|
13353
|
+
const initParam = constructTypeCtorParameter(env, meta, typeRef, typeRefWithGenerics);
|
|
13473
13354
|
const typeParameters = typeParametersWithDefaultTypes(typeParams);
|
|
13474
13355
|
let source;
|
|
13475
13356
|
if (meta.body) {
|
|
@@ -13482,24 +13363,26 @@ function generateTypeCtorDeclarationFn(env, meta, nodeTypeRef, typeParams) {
|
|
|
13482
13363
|
}
|
|
13483
13364
|
function generateInlineTypeCtor(env, node, meta) {
|
|
13484
13365
|
const typeRef = node.name.text;
|
|
13485
|
-
const
|
|
13486
|
-
const
|
|
13366
|
+
const sourceFile = node.getSourceFile();
|
|
13367
|
+
const tcbTypeParams = node.typeParameters && node.typeParameters.length > 0 ? generateTcbTypeParameters(node.typeParameters, sourceFile) : void 0;
|
|
13368
|
+
const typeRefWithGenerics = `${typeRef}${generateGenericArgs(tcbTypeParams)}`;
|
|
13369
|
+
const initParam = constructTypeCtorParameter(env, meta, typeRef, typeRefWithGenerics);
|
|
13487
13370
|
const body = `{ return null!; }`;
|
|
13488
|
-
const typeParams = typeParametersWithDefaultTypes(
|
|
13371
|
+
const typeParams = typeParametersWithDefaultTypes(tcbTypeParams);
|
|
13489
13372
|
return `static ${meta.fnName}${typeParams}(${initParam}): ${typeRefWithGenerics} ${body}`;
|
|
13490
13373
|
}
|
|
13491
|
-
function constructTypeCtorParameter(env, meta,
|
|
13374
|
+
function constructTypeCtorParameter(env, meta, typeRef, typeRefWithGenerics) {
|
|
13492
13375
|
let initType = null;
|
|
13493
13376
|
const plainKeys = [];
|
|
13494
13377
|
const coercedKeys = [];
|
|
13495
13378
|
const signalInputKeys = [];
|
|
13496
|
-
for (const { classPropertyName,
|
|
13379
|
+
for (const { classPropertyName, transformType, isSignal } of meta.fields.inputs) {
|
|
13497
13380
|
if (isSignal) {
|
|
13498
13381
|
signalInputKeys.push(quoteAndEscape(classPropertyName));
|
|
13499
13382
|
} else if (!meta.coercedInputFields.has(classPropertyName)) {
|
|
13500
13383
|
plainKeys.push(quoteAndEscape(classPropertyName));
|
|
13501
13384
|
} else {
|
|
13502
|
-
const coercionType =
|
|
13385
|
+
const coercionType = transformType !== void 0 ? transformType : `typeof ${typeRef}.ngAcceptInputType_${classPropertyName}`;
|
|
13503
13386
|
coercedKeys.push(`${classPropertyName}: ${coercionType}`);
|
|
13504
13387
|
}
|
|
13505
13388
|
}
|
|
@@ -13530,7 +13413,7 @@ function generateGenericArgs(typeParameters) {
|
|
|
13530
13413
|
if (typeParameters === void 0 || typeParameters.length === 0) {
|
|
13531
13414
|
return "";
|
|
13532
13415
|
}
|
|
13533
|
-
return `<${typeParameters.map((param) => param.name
|
|
13416
|
+
return `<${typeParameters.map((param) => param.name).join(", ")}>`;
|
|
13534
13417
|
}
|
|
13535
13418
|
function requiresInlineTypeCtor(node, host, env) {
|
|
13536
13419
|
return !checkIfGenericTypeBoundsCanBeEmitted(node, host, env);
|
|
@@ -13539,14 +13422,384 @@ function typeParametersWithDefaultTypes(params) {
|
|
|
13539
13422
|
if (params === void 0 || params.length === 0) {
|
|
13540
13423
|
return "";
|
|
13541
13424
|
}
|
|
13542
|
-
|
|
13543
|
-
|
|
13544
|
-
|
|
13545
|
-
|
|
13546
|
-
|
|
13547
|
-
|
|
13425
|
+
return `<${params.map((param) => param.representationWithDefault).join(", ")}>`;
|
|
13426
|
+
}
|
|
13427
|
+
|
|
13428
|
+
// packages/compiler-cli/src/ngtsc/typecheck/src/tcb_adapter.js
|
|
13429
|
+
import ts57 from "typescript";
|
|
13430
|
+
function adaptTypeCheckBlockMetadata(ref, meta, env) {
|
|
13431
|
+
const refCache = /* @__PURE__ */ new Map();
|
|
13432
|
+
const extractRef = (ref2) => {
|
|
13433
|
+
if (refCache.has(ref2)) {
|
|
13434
|
+
return refCache.get(ref2);
|
|
13435
|
+
}
|
|
13436
|
+
const result = extractReferenceMetadata(ref2, env);
|
|
13437
|
+
refCache.set(ref2, result);
|
|
13438
|
+
return result;
|
|
13439
|
+
};
|
|
13440
|
+
const dirCache = /* @__PURE__ */ new Map();
|
|
13441
|
+
const convertDir = (dir) => {
|
|
13442
|
+
if (dirCache.has(dir))
|
|
13443
|
+
return dirCache.get(dir);
|
|
13444
|
+
const tcbDir = {
|
|
13445
|
+
isComponent: dir.isComponent,
|
|
13446
|
+
name: dir.name,
|
|
13447
|
+
selector: dir.selector,
|
|
13448
|
+
exportAs: dir.exportAs,
|
|
13449
|
+
inputs: ClassPropertyMapping.fromMappedObject(dir.inputs.toJointMappedObject((input) => {
|
|
13450
|
+
return {
|
|
13451
|
+
classPropertyName: input.classPropertyName,
|
|
13452
|
+
bindingPropertyName: input.bindingPropertyName,
|
|
13453
|
+
required: input.required,
|
|
13454
|
+
isSignal: input.isSignal,
|
|
13455
|
+
transformType: (() => {
|
|
13456
|
+
if (input.transform != null) {
|
|
13457
|
+
const node = env.referenceTransplantedType(new TransplantedType(input.transform.type));
|
|
13458
|
+
return tempPrint(node, env.contextFile);
|
|
13459
|
+
}
|
|
13460
|
+
return void 0;
|
|
13461
|
+
})()
|
|
13462
|
+
};
|
|
13463
|
+
})),
|
|
13464
|
+
outputs: dir.outputs,
|
|
13465
|
+
isStructural: dir.isStructural,
|
|
13466
|
+
isStandalone: dir.isStandalone,
|
|
13467
|
+
isExplicitlyDeferred: dir.isExplicitlyDeferred,
|
|
13468
|
+
preserveWhitespaces: dir.preserveWhitespaces,
|
|
13469
|
+
ngContentSelectors: dir.ngContentSelectors,
|
|
13470
|
+
animationTriggerNames: dir.animationTriggerNames,
|
|
13471
|
+
ngTemplateGuards: dir.ngTemplateGuards,
|
|
13472
|
+
hasNgTemplateContextGuard: dir.hasNgTemplateContextGuard,
|
|
13473
|
+
hasNgFieldDirective: ts57.isClassDeclaration(dir.ref.node) && dir.ref.node.members.some((member) => ts57.isPropertyDeclaration(member) && ts57.isComputedPropertyName(member.name) && ts57.isIdentifier(member.name.expression) && member.name.expression.text === "\u0275NgFieldDirective"),
|
|
13474
|
+
coercedInputFields: dir.coercedInputFields,
|
|
13475
|
+
restrictedInputFields: dir.restrictedInputFields,
|
|
13476
|
+
stringLiteralInputFields: dir.stringLiteralInputFields,
|
|
13477
|
+
undeclaredInputFields: dir.undeclaredInputFields,
|
|
13478
|
+
publicMethods: dir.publicMethods,
|
|
13479
|
+
ref: extractRef(dir.ref),
|
|
13480
|
+
isGeneric: dir.isGeneric,
|
|
13481
|
+
typeParameters: (() => {
|
|
13482
|
+
const node = dir.ref.node;
|
|
13483
|
+
if (!node.typeParameters) {
|
|
13484
|
+
return null;
|
|
13485
|
+
}
|
|
13486
|
+
const emitter = new TypeParameterEmitter(node.typeParameters, env.reflector);
|
|
13487
|
+
let emitted;
|
|
13488
|
+
if (!emitter.canEmit((ref2) => env.canReferenceType(ref2))) {
|
|
13489
|
+
emitted = [...node.typeParameters];
|
|
13490
|
+
} else {
|
|
13491
|
+
emitted = emitter.emit((ref2) => env.referenceType(ref2));
|
|
13492
|
+
}
|
|
13493
|
+
return generateTcbTypeParameters(emitted || [], env.contextFile);
|
|
13494
|
+
})(),
|
|
13495
|
+
hasRequiresInlineTypeCtor: requiresInlineTypeCtor(dir.ref.node, env.reflector, env)
|
|
13496
|
+
};
|
|
13497
|
+
dirCache.set(dir, tcbDir);
|
|
13498
|
+
return tcbDir;
|
|
13499
|
+
};
|
|
13500
|
+
const adaptedBoundTarget = {
|
|
13501
|
+
target: (() => {
|
|
13502
|
+
const originalTarget = meta.boundTarget.target;
|
|
13503
|
+
return {
|
|
13504
|
+
template: originalTarget.template,
|
|
13505
|
+
host: originalTarget.host ? {
|
|
13506
|
+
node: originalTarget.host.node,
|
|
13507
|
+
directives: originalTarget.host.directives.map(convertDir)
|
|
13508
|
+
} : void 0
|
|
13509
|
+
};
|
|
13510
|
+
})(),
|
|
13511
|
+
getUsedDirectives: () => meta.boundTarget.getUsedDirectives().map(convertDir),
|
|
13512
|
+
getEagerlyUsedDirectives: () => meta.boundTarget.getEagerlyUsedDirectives().map(convertDir),
|
|
13513
|
+
getUsedPipes: () => meta.boundTarget.getUsedPipes(),
|
|
13514
|
+
getDirectivesOfNode: (node) => {
|
|
13515
|
+
const dirs = meta.boundTarget.getDirectivesOfNode(node);
|
|
13516
|
+
return dirs ? dirs.map(convertDir) : null;
|
|
13517
|
+
},
|
|
13518
|
+
getReferenceTarget: (ref2) => {
|
|
13519
|
+
const target = meta.boundTarget.getReferenceTarget(ref2);
|
|
13520
|
+
if (target && "directive" in target) {
|
|
13521
|
+
return {
|
|
13522
|
+
directive: convertDir(target.directive),
|
|
13523
|
+
node: target.node
|
|
13524
|
+
};
|
|
13525
|
+
}
|
|
13526
|
+
return target;
|
|
13527
|
+
},
|
|
13528
|
+
getDeferredTriggerTarget: (b, t) => meta.boundTarget.getDeferredTriggerTarget(b, t),
|
|
13529
|
+
isDeferred: (node) => meta.boundTarget.isDeferred(node),
|
|
13530
|
+
referencedDirectiveExists: (name) => meta.boundTarget.referencedDirectiveExists(name),
|
|
13531
|
+
getConsumerOfBinding: (binding) => {
|
|
13532
|
+
const consumer = meta.boundTarget.getConsumerOfBinding(binding);
|
|
13533
|
+
if (consumer && consumer.isComponent !== void 0) {
|
|
13534
|
+
return convertDir(consumer);
|
|
13535
|
+
}
|
|
13536
|
+
return consumer;
|
|
13537
|
+
},
|
|
13538
|
+
getExpressionTarget: (expr) => meta.boundTarget.getExpressionTarget(expr),
|
|
13539
|
+
getDefinitionNodeOfSymbol: (sym) => meta.boundTarget.getDefinitionNodeOfSymbol(sym),
|
|
13540
|
+
getNestingLevel: (node) => meta.boundTarget.getNestingLevel(node),
|
|
13541
|
+
getEntitiesInScope: (node) => meta.boundTarget.getEntitiesInScope(node),
|
|
13542
|
+
getEagerlyUsedPipes: () => meta.boundTarget.getEagerlyUsedPipes(),
|
|
13543
|
+
getDeferBlocks: () => meta.boundTarget.getDeferBlocks()
|
|
13544
|
+
};
|
|
13545
|
+
const pipes = /* @__PURE__ */ new Map();
|
|
13546
|
+
if (meta.pipes !== null) {
|
|
13547
|
+
for (const pipeName of meta.boundTarget.getUsedPipes()) {
|
|
13548
|
+
if (!meta.pipes.has(pipeName) || pipes.has(pipeName)) {
|
|
13549
|
+
continue;
|
|
13550
|
+
}
|
|
13551
|
+
const pipe = meta.pipes.get(pipeName);
|
|
13552
|
+
pipes.set(pipeName, {
|
|
13553
|
+
name: pipe.name,
|
|
13554
|
+
ref: extractRef(pipe.ref),
|
|
13555
|
+
isExplicitlyDeferred: pipe.isExplicitlyDeferred
|
|
13556
|
+
});
|
|
13557
|
+
}
|
|
13558
|
+
}
|
|
13559
|
+
return {
|
|
13560
|
+
tcbMeta: {
|
|
13561
|
+
id: meta.id,
|
|
13562
|
+
boundTarget: adaptedBoundTarget,
|
|
13563
|
+
pipes,
|
|
13564
|
+
schemas: meta.schemas,
|
|
13565
|
+
isStandalone: meta.isStandalone,
|
|
13566
|
+
preserveWhitespaces: meta.preserveWhitespaces
|
|
13567
|
+
},
|
|
13568
|
+
component: (() => {
|
|
13569
|
+
return {
|
|
13570
|
+
ref: extractRef(ref),
|
|
13571
|
+
typeParameters: (() => {
|
|
13572
|
+
if (!ref.node.typeParameters)
|
|
13573
|
+
return null;
|
|
13574
|
+
const emitter = new TypeParameterEmitter(ref.node.typeParameters, env.reflector);
|
|
13575
|
+
let emitted;
|
|
13576
|
+
if (!emitter.canEmit((r) => env.canReferenceType(r))) {
|
|
13577
|
+
emitted = [...ref.node.typeParameters];
|
|
13578
|
+
} else {
|
|
13579
|
+
emitted = emitter.emit((r) => env.referenceType(r));
|
|
13580
|
+
}
|
|
13581
|
+
return generateTcbTypeParameters(emitted || [], env.contextFile);
|
|
13582
|
+
})()
|
|
13583
|
+
};
|
|
13584
|
+
})()
|
|
13585
|
+
};
|
|
13586
|
+
}
|
|
13587
|
+
function extractReferenceMetadata(ref, env) {
|
|
13588
|
+
let name = ref.debugName || ref.node.name.text;
|
|
13589
|
+
let moduleName = ref.ownedByModuleGuess;
|
|
13590
|
+
let unexportedDiagnostic = null;
|
|
13591
|
+
let isLocal = true;
|
|
13592
|
+
const emitted = env.refEmitter.emit(ref, env.contextFile, ImportFlags.NoAliasing);
|
|
13593
|
+
if (emitted.kind === ReferenceEmitKind.Success) {
|
|
13594
|
+
if (emitted.expression instanceof ExternalExpr7) {
|
|
13595
|
+
name = emitted.expression.value.name;
|
|
13596
|
+
moduleName = emitted.expression.value.moduleName;
|
|
13597
|
+
isLocal = false;
|
|
13598
|
+
} else if (emitted.expression instanceof WrappedNodeExpr7) {
|
|
13599
|
+
const node = emitted.expression.node;
|
|
13600
|
+
const extractedName = extractNameFromExpr(node);
|
|
13601
|
+
if (extractedName !== null) {
|
|
13602
|
+
name = extractedName;
|
|
13603
|
+
}
|
|
13604
|
+
}
|
|
13605
|
+
} else if (emitted.kind === ReferenceEmitKind.Failed) {
|
|
13606
|
+
unexportedDiagnostic = emitted.reason;
|
|
13607
|
+
isLocal = false;
|
|
13608
|
+
}
|
|
13609
|
+
const refMeta = {
|
|
13610
|
+
name,
|
|
13611
|
+
moduleName,
|
|
13612
|
+
isLocal,
|
|
13613
|
+
unexportedDiagnostic
|
|
13614
|
+
};
|
|
13615
|
+
const nodeName = ref.node?.name;
|
|
13616
|
+
if (nodeName) {
|
|
13617
|
+
refMeta.nodeNameSpan = new AbsoluteSourceSpan4(nodeName.getStart(), nodeName.getEnd());
|
|
13618
|
+
refMeta.nodeFilePath = nodeName.getSourceFile().fileName;
|
|
13619
|
+
}
|
|
13620
|
+
return refMeta;
|
|
13621
|
+
}
|
|
13622
|
+
function extractNameFromExpr(node) {
|
|
13623
|
+
if (ts57.isIdentifier(node)) {
|
|
13624
|
+
return node.text;
|
|
13625
|
+
} else if (ts57.isPropertyAccessExpression(node)) {
|
|
13626
|
+
const receiver = extractNameFromExpr(node.expression);
|
|
13627
|
+
return receiver !== null ? `${receiver}.${node.name.text}` : null;
|
|
13628
|
+
}
|
|
13629
|
+
return null;
|
|
13548
13630
|
}
|
|
13549
13631
|
|
|
13632
|
+
// packages/compiler-cli/src/ngtsc/typecheck/src/dom.js
|
|
13633
|
+
import { DomElementSchemaRegistry } from "@angular/compiler";
|
|
13634
|
+
import ts58 from "typescript";
|
|
13635
|
+
var REGISTRY = new DomElementSchemaRegistry();
|
|
13636
|
+
var REMOVE_XHTML_REGEX = /^:xhtml:/;
|
|
13637
|
+
var RegistryDomSchemaChecker = class {
|
|
13638
|
+
resolver;
|
|
13639
|
+
_diagnostics = [];
|
|
13640
|
+
get diagnostics() {
|
|
13641
|
+
return this._diagnostics;
|
|
13642
|
+
}
|
|
13643
|
+
constructor(resolver) {
|
|
13644
|
+
this.resolver = resolver;
|
|
13645
|
+
}
|
|
13646
|
+
checkElement(id, tagName, sourceSpanForDiagnostics, schemas, hostIsStandalone) {
|
|
13647
|
+
const name = tagName.replace(REMOVE_XHTML_REGEX, "");
|
|
13648
|
+
if (!REGISTRY.hasElement(name, schemas)) {
|
|
13649
|
+
const mapping = this.resolver.getTemplateSourceMapping(id);
|
|
13650
|
+
const schemas2 = `'${hostIsStandalone ? "@Component" : "@NgModule"}.schemas'`;
|
|
13651
|
+
let errorMsg = `'${name}' is not a known element:
|
|
13652
|
+
`;
|
|
13653
|
+
errorMsg += `1. If '${name}' is an Angular component, then verify that it is ${hostIsStandalone ? "included in the '@Component.imports' of this component" : "part of this module"}.
|
|
13654
|
+
`;
|
|
13655
|
+
if (name.indexOf("-") > -1) {
|
|
13656
|
+
errorMsg += `2. If '${name}' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the ${schemas2} of this component to suppress this message.`;
|
|
13657
|
+
} else {
|
|
13658
|
+
errorMsg += `2. To allow any element add 'NO_ERRORS_SCHEMA' to the ${schemas2} of this component.`;
|
|
13659
|
+
}
|
|
13660
|
+
const diag = makeTemplateDiagnostic(id, mapping, sourceSpanForDiagnostics, ts58.DiagnosticCategory.Error, ngErrorCode(ErrorCode.SCHEMA_INVALID_ELEMENT), errorMsg);
|
|
13661
|
+
this._diagnostics.push(diag);
|
|
13662
|
+
}
|
|
13663
|
+
}
|
|
13664
|
+
checkTemplateElementProperty(id, tagName, name, span, schemas, hostIsStandalone) {
|
|
13665
|
+
if (!REGISTRY.hasProperty(tagName, name, schemas)) {
|
|
13666
|
+
const mapping = this.resolver.getTemplateSourceMapping(id);
|
|
13667
|
+
const decorator = hostIsStandalone ? "@Component" : "@NgModule";
|
|
13668
|
+
const schemas2 = `'${decorator}.schemas'`;
|
|
13669
|
+
let errorMsg = `Can't bind to '${name}' since it isn't a known property of '${tagName}'.`;
|
|
13670
|
+
if (tagName.startsWith("ng-")) {
|
|
13671
|
+
errorMsg += `
|
|
13672
|
+
1. If '${name}' is an Angular directive, then add 'CommonModule' to the '${decorator}.imports' of this component.
|
|
13673
|
+
2. To allow any property add 'NO_ERRORS_SCHEMA' to the ${schemas2} of this component.`;
|
|
13674
|
+
} else if (tagName.indexOf("-") > -1) {
|
|
13675
|
+
errorMsg += `
|
|
13676
|
+
1. If '${tagName}' is an Angular component and it has '${name}' input, then verify that it is ${hostIsStandalone ? "included in the '@Component.imports' of this component" : "part of this module"}.
|
|
13677
|
+
2. If '${tagName}' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the ${schemas2} of this component to suppress this message.
|
|
13678
|
+
3. To allow any property add 'NO_ERRORS_SCHEMA' to the ${schemas2} of this component.`;
|
|
13679
|
+
}
|
|
13680
|
+
const diag = makeTemplateDiagnostic(id, mapping, span, ts58.DiagnosticCategory.Error, ngErrorCode(ErrorCode.SCHEMA_INVALID_ATTRIBUTE), errorMsg);
|
|
13681
|
+
this._diagnostics.push(diag);
|
|
13682
|
+
}
|
|
13683
|
+
}
|
|
13684
|
+
checkHostElementProperty(id, element, name, span, schemas) {
|
|
13685
|
+
for (const tagName of element.tagNames) {
|
|
13686
|
+
if (REGISTRY.hasProperty(tagName, name, schemas)) {
|
|
13687
|
+
continue;
|
|
13688
|
+
}
|
|
13689
|
+
const errorMessage = `Can't bind to '${name}' since it isn't a known property of '${tagName}'.`;
|
|
13690
|
+
const mapping = this.resolver.getHostBindingsMapping(id);
|
|
13691
|
+
const diag = makeTemplateDiagnostic(id, mapping, span, ts58.DiagnosticCategory.Error, ngErrorCode(ErrorCode.SCHEMA_INVALID_ATTRIBUTE), errorMessage);
|
|
13692
|
+
this._diagnostics.push(diag);
|
|
13693
|
+
break;
|
|
13694
|
+
}
|
|
13695
|
+
}
|
|
13696
|
+
};
|
|
13697
|
+
|
|
13698
|
+
// packages/compiler-cli/src/ngtsc/typecheck/src/environment.js
|
|
13699
|
+
import ts60 from "typescript";
|
|
13700
|
+
|
|
13701
|
+
// packages/compiler-cli/src/ngtsc/typecheck/src/reference_emit_environment.js
|
|
13702
|
+
import { ExpressionType, ExternalExpr as ExternalExpr8, TypeModifier } from "@angular/compiler";
|
|
13703
|
+
import ts59 from "typescript";
|
|
13704
|
+
var ReferenceEmitEnvironment = class {
|
|
13705
|
+
importManager;
|
|
13706
|
+
refEmitter;
|
|
13707
|
+
reflector;
|
|
13708
|
+
contextFile;
|
|
13709
|
+
constructor(importManager, refEmitter, reflector, contextFile) {
|
|
13710
|
+
this.importManager = importManager;
|
|
13711
|
+
this.refEmitter = refEmitter;
|
|
13712
|
+
this.reflector = reflector;
|
|
13713
|
+
this.contextFile = contextFile;
|
|
13714
|
+
}
|
|
13715
|
+
canReferenceType(ref, flags = ImportFlags.NoAliasing | ImportFlags.AllowTypeImports | ImportFlags.AllowRelativeDtsImports) {
|
|
13716
|
+
const result = this.refEmitter.emit(ref, this.contextFile, flags);
|
|
13717
|
+
return result.kind === ReferenceEmitKind.Success;
|
|
13718
|
+
}
|
|
13719
|
+
/**
|
|
13720
|
+
* Generate a `ts.TypeNode` that references the given node as a type.
|
|
13721
|
+
*
|
|
13722
|
+
* This may involve importing the node into the file if it's not declared there already.
|
|
13723
|
+
*/
|
|
13724
|
+
referenceType(ref, flags = ImportFlags.NoAliasing | ImportFlags.AllowTypeImports | ImportFlags.AllowRelativeDtsImports) {
|
|
13725
|
+
const ngExpr = this.refEmitter.emit(ref, this.contextFile, flags);
|
|
13726
|
+
assertSuccessfulReferenceEmit(ngExpr, this.contextFile, "symbol");
|
|
13727
|
+
return translateType(new ExpressionType(ngExpr.expression), this.contextFile, this.reflector, this.refEmitter, this.importManager);
|
|
13728
|
+
}
|
|
13729
|
+
/**
|
|
13730
|
+
* Generates a `ts.TypeNode` from a `TcbReferenceMetadata` object.
|
|
13731
|
+
* This is used by the TCB operations which do not hold on to the original `ts.Declaration`.
|
|
13732
|
+
*
|
|
13733
|
+
* Note: It's important that we do not try to evaluate the `typeParameters` here and pad them
|
|
13734
|
+
* out with `any` type arguments. If we supply `any` to a generic pipe (e.g. `var _pipe1: MyPipe<any>;`),
|
|
13735
|
+
* it destroys the generic constraints and degrades the `transform` signature. When they are omitted
|
|
13736
|
+
* entirely, TypeScript implicitly flags an error, which the Angular compiler filters out, and
|
|
13737
|
+
* crucially recovers by falling back to constraint inference (e.g. `var _pipe1: MyPipe;` infers
|
|
13738
|
+
* bounds safely).
|
|
13739
|
+
*/
|
|
13740
|
+
referenceTcbType(ref) {
|
|
13741
|
+
if (ref.unexportedDiagnostic !== null || ref.isLocal || ref.moduleName === null) {
|
|
13742
|
+
if (ref.unexportedDiagnostic !== null) {
|
|
13743
|
+
throw new FatalDiagnosticError(
|
|
13744
|
+
ErrorCode.IMPORT_GENERATION_FAILURE,
|
|
13745
|
+
this.contextFile,
|
|
13746
|
+
// Using context file as fallback origin for external file since we lack exact node
|
|
13747
|
+
makeDiagnosticChain(`Unable to import symbol ${ref.name}.`, [
|
|
13748
|
+
makeDiagnosticChain(ref.unexportedDiagnostic)
|
|
13749
|
+
])
|
|
13750
|
+
);
|
|
13751
|
+
}
|
|
13752
|
+
return ts59.factory.createTypeReferenceNode(ref.name);
|
|
13753
|
+
}
|
|
13754
|
+
return this.referenceExternalType(ref.moduleName, ref.name);
|
|
13755
|
+
}
|
|
13756
|
+
/**
|
|
13757
|
+
* Generates a `TcbExpr` from a `TcbReferenceMetadata` object.
|
|
13758
|
+
*/
|
|
13759
|
+
referenceTcbValue(ref) {
|
|
13760
|
+
if (ref.unexportedDiagnostic !== null || ref.isLocal || ref.moduleName === null) {
|
|
13761
|
+
if (ref.unexportedDiagnostic !== null) {
|
|
13762
|
+
throw new FatalDiagnosticError(ErrorCode.IMPORT_GENERATION_FAILURE, this.contextFile, makeDiagnosticChain(`Unable to import symbol ${ref.name}.`, [
|
|
13763
|
+
makeDiagnosticChain(ref.unexportedDiagnostic)
|
|
13764
|
+
]));
|
|
13765
|
+
}
|
|
13766
|
+
return new TcbExpr(ref.name);
|
|
13767
|
+
}
|
|
13768
|
+
return this.referenceExternalSymbol(ref.moduleName, ref.name);
|
|
13769
|
+
}
|
|
13770
|
+
referenceExternalSymbol(moduleName, name) {
|
|
13771
|
+
const importResult = this.importManager.addImport({
|
|
13772
|
+
exportModuleSpecifier: moduleName,
|
|
13773
|
+
exportSymbolName: name,
|
|
13774
|
+
requestedFile: this.contextFile
|
|
13775
|
+
});
|
|
13776
|
+
if (ts59.isIdentifier(importResult)) {
|
|
13777
|
+
return new TcbExpr(importResult.text);
|
|
13778
|
+
} else if (ts59.isIdentifier(importResult.expression)) {
|
|
13779
|
+
return new TcbExpr(`${importResult.expression.text}.${importResult.name.text}`);
|
|
13780
|
+
}
|
|
13781
|
+
throw new Error("Unexpected value returned by import manager");
|
|
13782
|
+
}
|
|
13783
|
+
/**
|
|
13784
|
+
* Generate a `ts.TypeNode` that references a given type from the provided module.
|
|
13785
|
+
*
|
|
13786
|
+
* This will involve importing the type into the file, and will also add type parameters if
|
|
13787
|
+
* provided.
|
|
13788
|
+
*/
|
|
13789
|
+
referenceExternalType(moduleName, name, typeParams) {
|
|
13790
|
+
const external = new ExternalExpr8({ moduleName, name });
|
|
13791
|
+
return translateType(new ExpressionType(external, TypeModifier.None, typeParams), this.contextFile, this.reflector, this.refEmitter, this.importManager);
|
|
13792
|
+
}
|
|
13793
|
+
/**
|
|
13794
|
+
* Generates a `ts.TypeNode` representing a type that is being referenced from a different place
|
|
13795
|
+
* in the program. Any type references inside the transplanted type will be rewritten so that
|
|
13796
|
+
* they can be imported in the context file.
|
|
13797
|
+
*/
|
|
13798
|
+
referenceTransplantedType(type) {
|
|
13799
|
+
return translateType(type, this.contextFile, this.reflector, this.refEmitter, this.importManager);
|
|
13800
|
+
}
|
|
13801
|
+
};
|
|
13802
|
+
|
|
13550
13803
|
// packages/compiler-cli/src/ngtsc/typecheck/src/environment.js
|
|
13551
13804
|
var Environment = class extends ReferenceEmitEnvironment {
|
|
13552
13805
|
config;
|
|
@@ -13569,49 +13822,47 @@ var Environment = class extends ReferenceEmitEnvironment {
|
|
|
13569
13822
|
* type constructor, or to an inline type constructor.
|
|
13570
13823
|
*/
|
|
13571
13824
|
typeCtorFor(dir) {
|
|
13572
|
-
const
|
|
13573
|
-
|
|
13574
|
-
|
|
13575
|
-
|
|
13576
|
-
|
|
13577
|
-
|
|
13578
|
-
|
|
13579
|
-
const typeCtorExpr = `${ref.print()}.ngTypeCtor`;
|
|
13580
|
-
this.typeCtors.set(node, typeCtorExpr);
|
|
13825
|
+
const key = getTcbReferenceKey(dir.ref);
|
|
13826
|
+
if (this.typeCtors.has(key)) {
|
|
13827
|
+
return new TcbExpr(this.typeCtors.get(key));
|
|
13828
|
+
}
|
|
13829
|
+
if (dir.hasRequiresInlineTypeCtor) {
|
|
13830
|
+
const typeCtorExpr = `${this.referenceTcbValue(dir.ref).print()}.ngTypeCtor`;
|
|
13831
|
+
this.typeCtors.set(key, typeCtorExpr);
|
|
13581
13832
|
return new TcbExpr(typeCtorExpr);
|
|
13582
13833
|
} else {
|
|
13583
13834
|
const fnName = `_ctor${this.nextIds.typeCtor++}`;
|
|
13584
|
-
const nodeTypeRef = this.
|
|
13585
|
-
if (!
|
|
13586
|
-
throw new Error(`Expected TypeReferenceNode from reference to ${
|
|
13835
|
+
const nodeTypeRef = this.referenceTcbType(dir.ref);
|
|
13836
|
+
if (!ts60.isTypeReferenceNode(nodeTypeRef)) {
|
|
13837
|
+
throw new Error(`Expected TypeReferenceNode from reference to ${dir.ref.name}`);
|
|
13587
13838
|
}
|
|
13588
13839
|
const meta = {
|
|
13589
13840
|
fnName,
|
|
13590
13841
|
body: true,
|
|
13591
13842
|
fields: {
|
|
13592
|
-
inputs: dir.inputs
|
|
13843
|
+
inputs: dir.inputs
|
|
13593
13844
|
// TODO: support queries
|
|
13594
|
-
queries: dir.queries
|
|
13595
13845
|
},
|
|
13596
13846
|
coercedInputFields: dir.coercedInputFields
|
|
13597
13847
|
};
|
|
13598
|
-
const typeParams =
|
|
13848
|
+
const typeParams = dir.typeParameters || void 0;
|
|
13599
13849
|
const typeCtor = generateTypeCtorDeclarationFn(this, meta, nodeTypeRef.typeName, typeParams);
|
|
13600
13850
|
this.typeCtorStatements.push(typeCtor);
|
|
13601
|
-
this.typeCtors.set(
|
|
13851
|
+
this.typeCtors.set(key, fnName);
|
|
13602
13852
|
return new TcbExpr(fnName);
|
|
13603
13853
|
}
|
|
13604
13854
|
}
|
|
13605
13855
|
/*
|
|
13606
13856
|
* Get an expression referring to an instance of the given pipe.
|
|
13607
13857
|
*/
|
|
13608
|
-
pipeInst(
|
|
13609
|
-
|
|
13610
|
-
|
|
13858
|
+
pipeInst(pipe) {
|
|
13859
|
+
const key = getTcbReferenceKey(pipe.ref);
|
|
13860
|
+
if (this.pipeInsts.has(key)) {
|
|
13861
|
+
return new TcbExpr(this.pipeInsts.get(key));
|
|
13611
13862
|
}
|
|
13612
|
-
const pipeType = this.
|
|
13863
|
+
const pipeType = this.referenceTcbType(pipe.ref);
|
|
13613
13864
|
const pipeInstId = `_pipe${this.nextIds.pipeInst++}`;
|
|
13614
|
-
this.pipeInsts.set(
|
|
13865
|
+
this.pipeInsts.set(key, pipeInstId);
|
|
13615
13866
|
this.pipeInstStatements.push(declareVariable(new TcbExpr(pipeInstId), new TcbExpr(tempPrint(pipeType, this.contextFile))));
|
|
13616
13867
|
return new TcbExpr(pipeInstId);
|
|
13617
13868
|
}
|
|
@@ -13634,12 +13885,19 @@ var Environment = class extends ReferenceEmitEnvironment {
|
|
|
13634
13885
|
return [...this.pipeInstStatements, ...this.typeCtorStatements];
|
|
13635
13886
|
}
|
|
13636
13887
|
};
|
|
13888
|
+
function getTcbReferenceKey(ref) {
|
|
13889
|
+
if (ref.nodeFilePath !== void 0 && ref.nodeNameSpan !== void 0) {
|
|
13890
|
+
return `${ref.nodeFilePath}#${ref.nodeNameSpan.start}`;
|
|
13891
|
+
}
|
|
13892
|
+
return ref.moduleName ? `${ref.moduleName}#${ref.name}` : ref.name;
|
|
13893
|
+
}
|
|
13637
13894
|
|
|
13638
13895
|
// packages/compiler-cli/src/ngtsc/typecheck/src/oob.js
|
|
13639
|
-
import { AbsoluteSourceSpan as
|
|
13640
|
-
import
|
|
13896
|
+
import { AbsoluteSourceSpan as AbsoluteSourceSpan5, BindingType as BindingType2, ParseSourceSpan as ParseSourceSpan2, TmplAstBoundAttribute as TmplAstBoundAttribute2, TmplAstBoundEvent as TmplAstBoundEvent2, TmplAstComponent, TmplAstDirective, TmplAstElement } from "@angular/compiler";
|
|
13897
|
+
import ts61 from "typescript";
|
|
13641
13898
|
var OutOfBandDiagnosticRecorderImpl = class {
|
|
13642
13899
|
resolver;
|
|
13900
|
+
getSourceFile;
|
|
13643
13901
|
_diagnostics = [];
|
|
13644
13902
|
/**
|
|
13645
13903
|
* Tracks which `BindingPipe` nodes have already been recorded as invalid, so only one diagnostic
|
|
@@ -13662,8 +13920,9 @@ var OutOfBandDiagnosticRecorderImpl = class {
|
|
|
13662
13920
|
["i18nSelect", "I18nSelectPipe"],
|
|
13663
13921
|
["keyvalue", "KeyValuePipe"]
|
|
13664
13922
|
]);
|
|
13665
|
-
constructor(resolver) {
|
|
13923
|
+
constructor(resolver, getSourceFile2 = (name) => void 0) {
|
|
13666
13924
|
this.resolver = resolver;
|
|
13925
|
+
this.getSourceFile = getSourceFile2;
|
|
13667
13926
|
}
|
|
13668
13927
|
get diagnostics() {
|
|
13669
13928
|
return this._diagnostics;
|
|
@@ -13672,7 +13931,7 @@ var OutOfBandDiagnosticRecorderImpl = class {
|
|
|
13672
13931
|
const mapping = this.resolver.getTemplateSourceMapping(id);
|
|
13673
13932
|
const value = ref.value.trim();
|
|
13674
13933
|
const errorMsg = `No directive found with exportAs '${value}'.`;
|
|
13675
|
-
this._diagnostics.push(makeTemplateDiagnostic(id, mapping, ref.valueSpan || ref.sourceSpan,
|
|
13934
|
+
this._diagnostics.push(makeTemplateDiagnostic(id, mapping, ref.valueSpan || ref.sourceSpan, ts61.DiagnosticCategory.Error, ngErrorCode(ErrorCode.MISSING_REFERENCE_TARGET), errorMsg));
|
|
13676
13935
|
}
|
|
13677
13936
|
missingPipe(id, ast, isStandalone) {
|
|
13678
13937
|
if (this.recordedPipes.has(ast)) {
|
|
@@ -13695,7 +13954,7 @@ To fix this, import the "${suggestedClassName}" class from "${suggestedImport}"
|
|
|
13695
13954
|
To fix this, import the "${suggestedClassName}" class from "${suggestedImport}" and add it to the "imports" array of the module declaring the component.`;
|
|
13696
13955
|
}
|
|
13697
13956
|
}
|
|
13698
|
-
this._diagnostics.push(makeTemplateDiagnostic(id, mapping, sourceSpan,
|
|
13957
|
+
this._diagnostics.push(makeTemplateDiagnostic(id, mapping, sourceSpan, ts61.DiagnosticCategory.Error, ngErrorCode(ErrorCode.MISSING_PIPE), errorMsg));
|
|
13699
13958
|
this.recordedPipes.add(ast);
|
|
13700
13959
|
}
|
|
13701
13960
|
deferredPipeUsedEagerly(id, ast) {
|
|
@@ -13708,24 +13967,24 @@ To fix this, import the "${suggestedClassName}" class from "${suggestedImport}"
|
|
|
13708
13967
|
if (sourceSpan === null) {
|
|
13709
13968
|
throw new Error(`Assertion failure: no SourceLocation found for usage of pipe '${ast.name}'.`);
|
|
13710
13969
|
}
|
|
13711
|
-
this._diagnostics.push(makeTemplateDiagnostic(id, mapping, sourceSpan,
|
|
13970
|
+
this._diagnostics.push(makeTemplateDiagnostic(id, mapping, sourceSpan, ts61.DiagnosticCategory.Error, ngErrorCode(ErrorCode.DEFERRED_PIPE_USED_EAGERLY), errorMsg));
|
|
13712
13971
|
this.recordedPipes.add(ast);
|
|
13713
13972
|
}
|
|
13714
13973
|
deferredComponentUsedEagerly(id, element) {
|
|
13715
13974
|
const mapping = this.resolver.getTemplateSourceMapping(id);
|
|
13716
13975
|
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.`;
|
|
13717
13976
|
const { start, end } = element.startSourceSpan;
|
|
13718
|
-
const absoluteSourceSpan = new
|
|
13977
|
+
const absoluteSourceSpan = new AbsoluteSourceSpan5(start.offset, end.offset);
|
|
13719
13978
|
const sourceSpan = this.resolver.toTemplateParseSourceSpan(id, absoluteSourceSpan);
|
|
13720
13979
|
if (sourceSpan === null) {
|
|
13721
13980
|
throw new Error(`Assertion failure: no SourceLocation found for usage of pipe '${element.name}'.`);
|
|
13722
13981
|
}
|
|
13723
|
-
this._diagnostics.push(makeTemplateDiagnostic(id, mapping, sourceSpan,
|
|
13982
|
+
this._diagnostics.push(makeTemplateDiagnostic(id, mapping, sourceSpan, ts61.DiagnosticCategory.Error, ngErrorCode(ErrorCode.DEFERRED_DIRECTIVE_USED_EAGERLY), errorMsg));
|
|
13724
13983
|
}
|
|
13725
13984
|
duplicateTemplateVar(id, variable, firstDecl) {
|
|
13726
13985
|
const mapping = this.resolver.getTemplateSourceMapping(id);
|
|
13727
13986
|
const errorMsg = `Cannot redeclare variable '${variable.name}' as it was previously declared elsewhere for the same template.`;
|
|
13728
|
-
this._diagnostics.push(makeTemplateDiagnostic(id, mapping, variable.sourceSpan,
|
|
13987
|
+
this._diagnostics.push(makeTemplateDiagnostic(id, mapping, variable.sourceSpan, ts61.DiagnosticCategory.Error, ngErrorCode(ErrorCode.DUPLICATE_VARIABLE_DECLARATION), errorMsg, [
|
|
13729
13988
|
{
|
|
13730
13989
|
text: `The variable '${firstDecl.name}' was first declared here.`,
|
|
13731
13990
|
start: firstDecl.sourceSpan.start.offset,
|
|
@@ -13766,19 +14025,24 @@ To fix this, import the "${suggestedClassName}" class from "${suggestedImport}"
|
|
|
13766
14025
|
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.
|
|
13767
14026
|
|
|
13768
14027
|
Consider enabling the 'strictTemplates' option in your tsconfig.json for better type inference within this template.`;
|
|
13769
|
-
this._diagnostics.push(makeTemplateDiagnostic(id, mapping, diagnosticVar.keySpan,
|
|
14028
|
+
this._diagnostics.push(makeTemplateDiagnostic(id, mapping, diagnosticVar.keySpan, ts61.DiagnosticCategory.Suggestion, ngErrorCode(ErrorCode.SUGGEST_SUBOPTIMAL_TYPE_INFERENCE), message));
|
|
13770
14029
|
}
|
|
13771
14030
|
splitTwoWayBinding(id, input, output, inputConsumer, outputConsumer) {
|
|
13772
14031
|
const mapping = this.resolver.getTemplateSourceMapping(id);
|
|
13773
14032
|
const errorMsg = `The property and event halves of the two-way binding '${input.name}' are not bound to the same target.
|
|
13774
14033
|
Find more at ${DOC_PAGE_BASE_URL}/guide/templates/two-way-binding`;
|
|
13775
14034
|
const relatedMessages = [];
|
|
13776
|
-
|
|
13777
|
-
|
|
13778
|
-
|
|
13779
|
-
|
|
13780
|
-
|
|
13781
|
-
|
|
14035
|
+
if (inputConsumer.ref.nodeNameSpan && inputConsumer.ref.nodeFilePath) {
|
|
14036
|
+
const sf = this.getSourceFile(inputConsumer.ref.nodeFilePath);
|
|
14037
|
+
if (sf) {
|
|
14038
|
+
relatedMessages.push({
|
|
14039
|
+
text: `The property half of the binding is to the '${inputConsumer.name}' ${inputConsumer.isComponent ? "component" : "directive"}.`,
|
|
14040
|
+
start: inputConsumer.ref.nodeNameSpan.start,
|
|
14041
|
+
end: inputConsumer.ref.nodeNameSpan.end,
|
|
14042
|
+
sourceFile: sf
|
|
14043
|
+
});
|
|
14044
|
+
}
|
|
14045
|
+
}
|
|
13782
14046
|
if (outputConsumer instanceof TmplAstElement) {
|
|
13783
14047
|
let message = `The event half of the binding is to a native event called '${input.name}' on the <${outputConsumer.name}> DOM element.`;
|
|
13784
14048
|
if (!mapping.node.getSourceFile().isDeclarationFile) {
|
|
@@ -13793,14 +14057,19 @@ Consider enabling the 'strictTemplates' option in your tsconfig.json for better
|
|
|
13793
14057
|
sourceFile: mapping.node.getSourceFile()
|
|
13794
14058
|
});
|
|
13795
14059
|
} else {
|
|
13796
|
-
|
|
13797
|
-
|
|
13798
|
-
|
|
13799
|
-
|
|
13800
|
-
|
|
13801
|
-
|
|
14060
|
+
if (outputConsumer.ref.nodeNameSpan && outputConsumer.ref.nodeFilePath) {
|
|
14061
|
+
const sf = this.getSourceFile(outputConsumer.ref.nodeFilePath);
|
|
14062
|
+
if (sf) {
|
|
14063
|
+
relatedMessages.push({
|
|
14064
|
+
text: `The event half of the binding is to the '${outputConsumer.name}' ${outputConsumer.isComponent ? "component" : "directive"}.`,
|
|
14065
|
+
start: outputConsumer.ref.nodeNameSpan.start,
|
|
14066
|
+
end: outputConsumer.ref.nodeNameSpan.end,
|
|
14067
|
+
sourceFile: sf
|
|
14068
|
+
});
|
|
14069
|
+
}
|
|
14070
|
+
}
|
|
13802
14071
|
}
|
|
13803
|
-
this._diagnostics.push(makeTemplateDiagnostic(id, mapping, input.keySpan,
|
|
14072
|
+
this._diagnostics.push(makeTemplateDiagnostic(id, mapping, input.keySpan, ts61.DiagnosticCategory.Error, ngErrorCode(ErrorCode.SPLIT_TWO_WAY_BINDING), errorMsg, relatedMessages));
|
|
13804
14073
|
}
|
|
13805
14074
|
missingRequiredInputs(id, element, directiveName, isComponent, inputAliases) {
|
|
13806
14075
|
const message = `Required input${inputAliases.length === 1 ? "" : "s"} ${inputAliases.map((n2) => `'${n2}'`).join(", ")} from ${isComponent ? "component" : "directive"} ${directiveName} must be specified.`;
|
|
@@ -13820,7 +14089,7 @@ Consider enabling the 'strictTemplates' option in your tsconfig.json for better
|
|
|
13820
14089
|
const end = element.startSourceSpan.end.moveBy(start.offset + name.length - element.startSourceSpan.end.offset);
|
|
13821
14090
|
span = new ParseSourceSpan2(start, end);
|
|
13822
14091
|
}
|
|
13823
|
-
this._diagnostics.push(makeTemplateDiagnostic(id, this.resolver.getTemplateSourceMapping(id), span,
|
|
14092
|
+
this._diagnostics.push(makeTemplateDiagnostic(id, this.resolver.getTemplateSourceMapping(id), span, ts61.DiagnosticCategory.Error, ngErrorCode(ErrorCode.MISSING_REQUIRED_INPUTS), message));
|
|
13824
14093
|
}
|
|
13825
14094
|
illegalForLoopTrackAccess(id, block, access) {
|
|
13826
14095
|
const sourceSpan = this.resolver.toTemplateParseSourceSpan(id, access.sourceSpan);
|
|
@@ -13829,7 +14098,7 @@ Consider enabling the 'strictTemplates' option in your tsconfig.json for better
|
|
|
13829
14098
|
}
|
|
13830
14099
|
const messageVars = [block.item, ...block.contextVariables.filter((v) => v.value === "$index")].map((v) => `'${v.name}'`).join(", ");
|
|
13831
14100
|
const message = `Cannot access '${access.name}' inside of a track expression. Only ${messageVars} and properties on the containing component are available to this expression.`;
|
|
13832
|
-
this._diagnostics.push(makeTemplateDiagnostic(id, this.resolver.getTemplateSourceMapping(id), sourceSpan,
|
|
14101
|
+
this._diagnostics.push(makeTemplateDiagnostic(id, this.resolver.getTemplateSourceMapping(id), sourceSpan, ts61.DiagnosticCategory.Error, ngErrorCode(ErrorCode.ILLEGAL_FOR_LOOP_TRACK_ACCESS), message));
|
|
13833
14102
|
}
|
|
13834
14103
|
inaccessibleDeferredTriggerElement(id, trigger) {
|
|
13835
14104
|
let message;
|
|
@@ -13840,7 +14109,7 @@ Consider enabling the 'strictTemplates' option in your tsconfig.json for better
|
|
|
13840
14109
|
Check that an element with #${trigger.reference} exists in the same template and it's accessible from the @defer block.
|
|
13841
14110
|
Deferred blocks can only access triggers in same view, a parent embedded view or the root view of the @placeholder block.`;
|
|
13842
14111
|
}
|
|
13843
|
-
this._diagnostics.push(makeTemplateDiagnostic(id, this.resolver.getTemplateSourceMapping(id), trigger.sourceSpan,
|
|
14112
|
+
this._diagnostics.push(makeTemplateDiagnostic(id, this.resolver.getTemplateSourceMapping(id), trigger.sourceSpan, ts61.DiagnosticCategory.Error, ngErrorCode(ErrorCode.INACCESSIBLE_DEFERRED_TRIGGER_ELEMENT), message));
|
|
13844
14113
|
}
|
|
13845
14114
|
controlFlowPreventingContentProjection(id, category, projectionNode, componentName, slotSelector, controlFlowNode, preservesWhitespaces) {
|
|
13846
14115
|
const blockName = controlFlowNode.nameSpan.toString().trim();
|
|
@@ -13862,43 +14131,43 @@ Deferred blocks can only access triggers in same view, a parent embedded view or
|
|
|
13862
14131
|
if (sourceSpan === null) {
|
|
13863
14132
|
throw new Error(`Assertion failure: no SourceLocation found for property write.`);
|
|
13864
14133
|
}
|
|
13865
|
-
this._diagnostics.push(makeTemplateDiagnostic(id, this.resolver.getTemplateSourceMapping(id), sourceSpan,
|
|
14134
|
+
this._diagnostics.push(makeTemplateDiagnostic(id, this.resolver.getTemplateSourceMapping(id), sourceSpan, ts61.DiagnosticCategory.Error, ngErrorCode(ErrorCode.ILLEGAL_LET_WRITE), `Cannot assign to @let declaration '${target.name}'.`));
|
|
13866
14135
|
}
|
|
13867
14136
|
letUsedBeforeDefinition(id, node, target) {
|
|
13868
14137
|
const sourceSpan = this.resolver.toTemplateParseSourceSpan(id, node.sourceSpan);
|
|
13869
14138
|
if (sourceSpan === null) {
|
|
13870
14139
|
throw new Error(`Assertion failure: no SourceLocation found for property read.`);
|
|
13871
14140
|
}
|
|
13872
|
-
this._diagnostics.push(makeTemplateDiagnostic(id, this.resolver.getTemplateSourceMapping(id), sourceSpan,
|
|
14141
|
+
this._diagnostics.push(makeTemplateDiagnostic(id, this.resolver.getTemplateSourceMapping(id), sourceSpan, ts61.DiagnosticCategory.Error, ngErrorCode(ErrorCode.LET_USED_BEFORE_DEFINITION), `Cannot read @let declaration '${target.name}' before it has been defined.`));
|
|
13873
14142
|
}
|
|
13874
14143
|
conflictingDeclaration(id, decl) {
|
|
13875
14144
|
const mapping = this.resolver.getTemplateSourceMapping(id);
|
|
13876
14145
|
const errorMsg = `Cannot declare @let called '${decl.name}' as there is another symbol in the template with the same name.`;
|
|
13877
|
-
this._diagnostics.push(makeTemplateDiagnostic(id, mapping, decl.sourceSpan,
|
|
14146
|
+
this._diagnostics.push(makeTemplateDiagnostic(id, mapping, decl.sourceSpan, ts61.DiagnosticCategory.Error, ngErrorCode(ErrorCode.CONFLICTING_LET_DECLARATION), errorMsg));
|
|
13878
14147
|
}
|
|
13879
14148
|
missingNamedTemplateDependency(id, node) {
|
|
13880
14149
|
this._diagnostics.push(makeTemplateDiagnostic(
|
|
13881
14150
|
id,
|
|
13882
14151
|
this.resolver.getTemplateSourceMapping(id),
|
|
13883
14152
|
node.startSourceSpan,
|
|
13884
|
-
|
|
14153
|
+
ts61.DiagnosticCategory.Error,
|
|
13885
14154
|
ngErrorCode(ErrorCode.MISSING_NAMED_TEMPLATE_DEPENDENCY),
|
|
13886
14155
|
// Wording is meant to mimic the wording TS uses in their diagnostic for missing symbols.
|
|
13887
14156
|
`Cannot find name "${node instanceof TmplAstDirective ? node.name : node.componentName}". Selectorless references are only supported to classes or non-type import statements.`
|
|
13888
14157
|
));
|
|
13889
14158
|
}
|
|
13890
14159
|
incorrectTemplateDependencyType(id, node) {
|
|
13891
|
-
this._diagnostics.push(makeTemplateDiagnostic(id, this.resolver.getTemplateSourceMapping(id), node.startSourceSpan,
|
|
14160
|
+
this._diagnostics.push(makeTemplateDiagnostic(id, this.resolver.getTemplateSourceMapping(id), node.startSourceSpan, ts61.DiagnosticCategory.Error, ngErrorCode(ErrorCode.INCORRECT_NAMED_TEMPLATE_DEPENDENCY_TYPE), `Incorrect reference type. Type must be a standalone ${node instanceof TmplAstComponent ? "@Component" : "@Directive"}.`));
|
|
13892
14161
|
}
|
|
13893
14162
|
unclaimedDirectiveBinding(id, directive, node) {
|
|
13894
14163
|
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.`;
|
|
13895
|
-
this._diagnostics.push(makeTemplateDiagnostic(id, this.resolver.getTemplateSourceMapping(id), node.keySpan || node.sourceSpan,
|
|
14164
|
+
this._diagnostics.push(makeTemplateDiagnostic(id, this.resolver.getTemplateSourceMapping(id), node.keySpan || node.sourceSpan, ts61.DiagnosticCategory.Error, ngErrorCode(ErrorCode.UNCLAIMED_DIRECTIVE_BINDING), errorMsg));
|
|
13896
14165
|
}
|
|
13897
14166
|
deferImplicitTriggerMissingPlaceholder(id, trigger) {
|
|
13898
|
-
this._diagnostics.push(makeTemplateDiagnostic(id, this.resolver.getTemplateSourceMapping(id), trigger.sourceSpan,
|
|
14167
|
+
this._diagnostics.push(makeTemplateDiagnostic(id, this.resolver.getTemplateSourceMapping(id), trigger.sourceSpan, ts61.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"));
|
|
13899
14168
|
}
|
|
13900
14169
|
deferImplicitTriggerInvalidPlaceholder(id, trigger) {
|
|
13901
|
-
this._diagnostics.push(makeTemplateDiagnostic(id, this.resolver.getTemplateSourceMapping(id), trigger.sourceSpan,
|
|
14170
|
+
this._diagnostics.push(makeTemplateDiagnostic(id, this.resolver.getTemplateSourceMapping(id), trigger.sourceSpan, ts61.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"));
|
|
13902
14171
|
}
|
|
13903
14172
|
formFieldUnsupportedBinding(id, node) {
|
|
13904
14173
|
let message;
|
|
@@ -13915,7 +14184,7 @@ Deferred blocks can only access triggers in same view, a parent embedded view or
|
|
|
13915
14184
|
} else {
|
|
13916
14185
|
message = `Setting the '${node.name}' attribute is not allowed on nodes using the '[formField]' directive`;
|
|
13917
14186
|
}
|
|
13918
|
-
this._diagnostics.push(makeTemplateDiagnostic(id, this.resolver.getTemplateSourceMapping(id), node.sourceSpan,
|
|
14187
|
+
this._diagnostics.push(makeTemplateDiagnostic(id, this.resolver.getTemplateSourceMapping(id), node.sourceSpan, ts61.DiagnosticCategory.Error, ngErrorCode(ErrorCode.FORM_FIELD_UNSUPPORTED_BINDING), message));
|
|
13919
14188
|
}
|
|
13920
14189
|
};
|
|
13921
14190
|
function makeInlineDiagnostic(id, code, node, messageText, relatedInformation) {
|
|
@@ -13927,7 +14196,7 @@ function makeInlineDiagnostic(id, code, node, messageText, relatedInformation) {
|
|
|
13927
14196
|
}
|
|
13928
14197
|
|
|
13929
14198
|
// packages/compiler-cli/src/ngtsc/typecheck/src/shim.js
|
|
13930
|
-
import
|
|
14199
|
+
import ts62 from "typescript";
|
|
13931
14200
|
var TypeCheckShimGenerator = class {
|
|
13932
14201
|
extensionPrefix = "ngtypecheck";
|
|
13933
14202
|
shouldEmit = false;
|
|
@@ -13935,7 +14204,7 @@ var TypeCheckShimGenerator = class {
|
|
|
13935
14204
|
if (priorShimSf !== null) {
|
|
13936
14205
|
return priorShimSf;
|
|
13937
14206
|
}
|
|
13938
|
-
return
|
|
14207
|
+
return ts62.createSourceFile(genFilePath, "export const USED_FOR_NG_TYPE_CHECKING = true;", ts62.ScriptTarget.Latest, true, ts62.ScriptKind.TS);
|
|
13939
14208
|
}
|
|
13940
14209
|
static shimFor(fileName) {
|
|
13941
14210
|
return absoluteFrom(fileName.replace(/\.tsx?$/, ".ngtypecheck.ts"));
|
|
@@ -14486,7 +14755,7 @@ var TcbExpressionTranslator = class {
|
|
|
14486
14755
|
this.tcb.oobRecorder.deferredPipeUsedEagerly(this.tcb.id, ast);
|
|
14487
14756
|
pipe = new TcbExpr("(0 as any)");
|
|
14488
14757
|
} else {
|
|
14489
|
-
pipe = this.tcb.env.pipeInst(pipeMeta
|
|
14758
|
+
pipe = this.tcb.env.pipeInst(pipeMeta);
|
|
14490
14759
|
}
|
|
14491
14760
|
const args = ast.args.map((arg) => this.translate(arg).print());
|
|
14492
14761
|
let methodAccess = new TcbExpr(`${pipe.print()}.transform`).addParseSpanInfo(ast.nameSpan);
|
|
@@ -14589,7 +14858,7 @@ ${getStatementsBlock(statements)}}`;
|
|
|
14589
14858
|
const isTemplate = hostNode instanceof TmplAstTemplate;
|
|
14590
14859
|
for (const dir of directives) {
|
|
14591
14860
|
const dirInstId = this.scope.resolve(hostNode, dir);
|
|
14592
|
-
const dirId = this.tcb.env.
|
|
14861
|
+
const dirId = this.tcb.env.referenceTcbValue(dir.ref);
|
|
14593
14862
|
dir.ngTemplateGuards.forEach((guard) => {
|
|
14594
14863
|
const boundInput = hostNode.inputs.find((i) => i.name === guard.inputName) || (isTemplate ? hostNode.templateAttrs.find((input) => {
|
|
14595
14864
|
return input instanceof TmplAstBoundAttribute3 && input.name === guard.inputName;
|
|
@@ -15025,12 +15294,11 @@ var TcbLetDeclarationOp = class extends TcbOp {
|
|
|
15025
15294
|
};
|
|
15026
15295
|
|
|
15027
15296
|
// packages/compiler-cli/src/ngtsc/typecheck/src/ops/inputs.js
|
|
15028
|
-
import { BindingType as BindingType5, R3Identifiers as R3Identifiers5
|
|
15297
|
+
import { BindingType as BindingType5, R3Identifiers as R3Identifiers5 } from "@angular/compiler";
|
|
15029
15298
|
import ts63 from "typescript";
|
|
15030
15299
|
|
|
15031
15300
|
// packages/compiler-cli/src/ngtsc/typecheck/src/ops/signal_forms.js
|
|
15032
15301
|
import { BindingType as BindingType3, Call as Call4, PropertyRead as PropertyRead6, SafeCall as SafeCall3, TmplAstElement as TmplAstElement3, TmplAstHostElement as TmplAstHostElement2 } from "@angular/compiler";
|
|
15033
|
-
import ts62 from "typescript";
|
|
15034
15302
|
var formControlInputFields = [
|
|
15035
15303
|
// Should be kept in sync with the `FormUiControl` bindings,
|
|
15036
15304
|
// defined in `packages/forms/signals/src/api/control.ts`.
|
|
@@ -15185,10 +15453,10 @@ function isFieldDirective(meta) {
|
|
|
15185
15453
|
if (meta.name !== "FormField") {
|
|
15186
15454
|
return false;
|
|
15187
15455
|
}
|
|
15188
|
-
if (meta.ref.
|
|
15456
|
+
if (meta.ref.moduleName === "@angular/forms/signals") {
|
|
15189
15457
|
return true;
|
|
15190
15458
|
}
|
|
15191
|
-
return
|
|
15459
|
+
return meta.hasNgFieldDirective;
|
|
15192
15460
|
}
|
|
15193
15461
|
function getSyntheticFieldBoundInput(dir, inputName, fieldPropertyName, fieldBinding, customFieldType) {
|
|
15194
15462
|
const inputs = dir.inputs.getByBindingPropertyName(inputName);
|
|
@@ -15214,7 +15482,7 @@ function getSyntheticFieldBoundInput(dir, inputName, fieldPropertyName, fieldBin
|
|
|
15214
15482
|
inputs: inputs.map((input) => ({
|
|
15215
15483
|
fieldName: input.classPropertyName,
|
|
15216
15484
|
required: input.required,
|
|
15217
|
-
transformType: input.
|
|
15485
|
+
transformType: input.transformType,
|
|
15218
15486
|
isSignal: input.isSignal,
|
|
15219
15487
|
isTwoWayBinding
|
|
15220
15488
|
}))
|
|
@@ -15298,7 +15566,7 @@ function getBoundAttributes(directive, node) {
|
|
|
15298
15566
|
return {
|
|
15299
15567
|
fieldName: input.classPropertyName,
|
|
15300
15568
|
required: input.required,
|
|
15301
|
-
transformType: input.
|
|
15569
|
+
transformType: input.transformType,
|
|
15302
15570
|
isSignal: input.isSignal,
|
|
15303
15571
|
isTwoWayBinding: attr instanceof TmplAstBoundAttribute4 && attr.type === BindingType4.TwoWay
|
|
15304
15572
|
};
|
|
@@ -15329,10 +15597,10 @@ function checkSplitTwoWayBinding(inputName, output, inputs, tcb) {
|
|
|
15329
15597
|
return false;
|
|
15330
15598
|
}
|
|
15331
15599
|
if (outputConsumer instanceof TmplAstElement4) {
|
|
15332
|
-
tcb.oobRecorder.splitTwoWayBinding(tcb.id, input, output, inputConsumer
|
|
15600
|
+
tcb.oobRecorder.splitTwoWayBinding(tcb.id, input, output, inputConsumer, outputConsumer);
|
|
15333
15601
|
return true;
|
|
15334
15602
|
} else if (outputConsumer.ref !== inputConsumer.ref) {
|
|
15335
|
-
tcb.oobRecorder.splitTwoWayBinding(tcb.id, input, output, inputConsumer
|
|
15603
|
+
tcb.oobRecorder.splitTwoWayBinding(tcb.id, input, output, inputConsumer, outputConsumer);
|
|
15336
15604
|
return true;
|
|
15337
15605
|
}
|
|
15338
15606
|
return false;
|
|
@@ -15401,13 +15669,12 @@ var TcbDirectiveInputsOp = class extends TcbOp {
|
|
|
15401
15669
|
}
|
|
15402
15670
|
if (this.dir.coercedInputFields.has(fieldName)) {
|
|
15403
15671
|
let type;
|
|
15404
|
-
if (transformType !==
|
|
15405
|
-
|
|
15406
|
-
type = new TcbExpr(tempPrint(tsType, transformType.node.getSourceFile()));
|
|
15672
|
+
if (transformType !== void 0) {
|
|
15673
|
+
type = new TcbExpr(transformType);
|
|
15407
15674
|
} else {
|
|
15408
|
-
const dirTypeRef = this.tcb.env.
|
|
15675
|
+
const dirTypeRef = this.tcb.env.referenceTcbType(this.dir.ref);
|
|
15409
15676
|
if (!ts63.isTypeReferenceNode(dirTypeRef)) {
|
|
15410
|
-
throw new Error(`Expected TypeReferenceNode from reference to ${this.dir.ref.
|
|
15677
|
+
throw new Error(`Expected TypeReferenceNode from reference to ${this.dir.ref.name}`);
|
|
15411
15678
|
}
|
|
15412
15679
|
const typeName = ts63.isIdentifier(dirTypeRef.typeName) ? dirTypeRef.typeName.text : tempPrint(dirTypeRef.typeName, dirTypeRef.typeName.getSourceFile());
|
|
15413
15680
|
type = new TcbExpr(`typeof ${typeName}.ngAcceptInputType_${fieldName}`);
|
|
@@ -15422,9 +15689,9 @@ var TcbDirectiveInputsOp = class extends TcbOp {
|
|
|
15422
15689
|
dirId = this.scope.resolve(this.node, this.dir);
|
|
15423
15690
|
}
|
|
15424
15691
|
const id = new TcbExpr(this.tcb.allocateId());
|
|
15425
|
-
const dirTypeRef = this.tcb.env.
|
|
15692
|
+
const dirTypeRef = this.tcb.env.referenceTcbType(this.dir.ref);
|
|
15426
15693
|
if (!ts63.isTypeReferenceNode(dirTypeRef)) {
|
|
15427
|
-
throw new Error(`Expected TypeReferenceNode from reference to ${this.dir.ref.
|
|
15694
|
+
throw new Error(`Expected TypeReferenceNode from reference to ${this.dir.ref.name}`);
|
|
15428
15695
|
}
|
|
15429
15696
|
const type = new TcbExpr(`(typeof ${dirId.print()})[${quoteAndEscape(fieldName)}]`);
|
|
15430
15697
|
const temp = declareVariable(id, type);
|
|
@@ -15787,18 +16054,18 @@ var TcbDirectiveTypeOpBase = class extends TcbOp {
|
|
|
15787
16054
|
return true;
|
|
15788
16055
|
}
|
|
15789
16056
|
execute() {
|
|
15790
|
-
const
|
|
15791
|
-
const rawType = this.tcb.env.referenceType(this.dir.ref);
|
|
16057
|
+
const rawType = this.tcb.env.referenceTcbType(this.dir.ref);
|
|
15792
16058
|
let type;
|
|
15793
16059
|
let span;
|
|
15794
|
-
if (this.dir.isGeneric === false ||
|
|
15795
|
-
type = new TcbExpr(tempPrint(rawType,
|
|
16060
|
+
if (this.dir.isGeneric === false || this.dir.typeParameters === null || this.dir.typeParameters.length === 0) {
|
|
16061
|
+
type = new TcbExpr(tempPrint(rawType, this.tcb.env.contextFile));
|
|
15796
16062
|
} else {
|
|
15797
16063
|
if (!ts64.isTypeReferenceNode(rawType)) {
|
|
15798
|
-
throw new Error(`Expected TypeReferenceNode when referencing the type for ${this.dir.ref.
|
|
16064
|
+
throw new Error(`Expected TypeReferenceNode when referencing the type for ${this.dir.ref.name}`);
|
|
15799
16065
|
}
|
|
15800
|
-
const
|
|
15801
|
-
|
|
16066
|
+
const typeName = ts64.isIdentifier(rawType.typeName) ? rawType.typeName.text : tempPrint(rawType.typeName, this.tcb.env.contextFile);
|
|
16067
|
+
const typeArguments = Array(this.dir.typeParameters?.length ?? 0).fill("any").join(", ");
|
|
16068
|
+
type = new TcbExpr(`${typeName}<${typeArguments}>`);
|
|
15802
16069
|
}
|
|
15803
16070
|
if (this.node instanceof TmplAstHostElement3) {
|
|
15804
16071
|
span = this.node.sourceSpan;
|
|
@@ -15816,18 +16083,16 @@ var TcbNonGenericDirectiveTypeOp = class extends TcbDirectiveTypeOpBase {
|
|
|
15816
16083
|
* the newly created variable.
|
|
15817
16084
|
*/
|
|
15818
16085
|
execute() {
|
|
15819
|
-
const dirRef = this.dir.ref;
|
|
15820
16086
|
if (this.dir.isGeneric) {
|
|
15821
|
-
throw new Error(`Assertion Error: expected ${
|
|
16087
|
+
throw new Error(`Assertion Error: expected ${this.dir.ref.name} not to be generic.`);
|
|
15822
16088
|
}
|
|
15823
16089
|
return super.execute();
|
|
15824
16090
|
}
|
|
15825
16091
|
};
|
|
15826
16092
|
var TcbGenericDirectiveTypeWithAnyParamsOp = class extends TcbDirectiveTypeOpBase {
|
|
15827
16093
|
execute() {
|
|
15828
|
-
|
|
15829
|
-
|
|
15830
|
-
throw new Error(`Assertion Error: expected typeParameters when creating a declaration for ${dirRef.debugName}`);
|
|
16094
|
+
if (this.dir.typeParameters === null || this.dir.typeParameters.length === 0) {
|
|
16095
|
+
throw new Error(`Assertion Error: expected typeParameters when creating a declaration for ${this.dir.ref.name}`);
|
|
15831
16096
|
}
|
|
15832
16097
|
return super.execute();
|
|
15833
16098
|
}
|
|
@@ -16571,10 +16836,9 @@ var Scope = class _Scope {
|
|
|
16571
16836
|
this.opQueue.push(new TcbDirectiveInputsOp(this.tcb, this, node, dir, nodeIsFormControl, customFormControlType));
|
|
16572
16837
|
}
|
|
16573
16838
|
getDirectiveOp(dir, node, customFieldType) {
|
|
16574
|
-
const dirRef = dir.ref;
|
|
16575
16839
|
if (!dir.isGeneric) {
|
|
16576
16840
|
return new TcbNonGenericDirectiveTypeOp(this.tcb, this, node, dir);
|
|
16577
|
-
} else if (!
|
|
16841
|
+
} else if (!dir.hasRequiresInlineTypeCtor || this.tcb.env.config.useInlineTypeConstructors) {
|
|
16578
16842
|
return new TcbDirectiveCtorOp(this.tcb, this, node, dir, customFieldType);
|
|
16579
16843
|
}
|
|
16580
16844
|
return new TcbGenericDirectiveTypeWithAnyParamsOp(this.tcb, this, node, dir);
|
|
@@ -16751,35 +17015,37 @@ var Scope = class _Scope {
|
|
|
16751
17015
|
};
|
|
16752
17016
|
|
|
16753
17017
|
// packages/compiler-cli/src/ngtsc/typecheck/src/type_check_block.js
|
|
16754
|
-
function generateTypeCheckBlock(env,
|
|
17018
|
+
function generateTypeCheckBlock(env, component, name, meta, domSchemaChecker, oobRecorder, genericContextBehavior) {
|
|
16755
17019
|
const tcb = new Context2(env, domSchemaChecker, oobRecorder, meta.id, meta.boundTarget, meta.pipes, meta.schemas, meta.isStandalone, meta.preserveWhitespaces);
|
|
16756
|
-
const ctxRawType = env.
|
|
17020
|
+
const ctxRawType = env.referenceTcbType(component.ref);
|
|
16757
17021
|
if (!ts66.isTypeReferenceNode(ctxRawType)) {
|
|
16758
|
-
throw new Error(`Expected TypeReferenceNode when referencing the ctx param for ${ref.
|
|
17022
|
+
throw new Error(`Expected TypeReferenceNode when referencing the ctx param for ${component.ref.name}`);
|
|
16759
17023
|
}
|
|
16760
17024
|
let typeParameters = void 0;
|
|
16761
17025
|
let typeArguments = void 0;
|
|
16762
|
-
if (
|
|
17026
|
+
if (component.typeParameters !== void 0) {
|
|
16763
17027
|
if (!env.config.useContextGenericType) {
|
|
16764
17028
|
genericContextBehavior = TcbGenericContextBehavior.FallbackToAny;
|
|
16765
17029
|
}
|
|
16766
17030
|
switch (genericContextBehavior) {
|
|
16767
17031
|
case TcbGenericContextBehavior.UseEmitter:
|
|
16768
|
-
|
|
16769
|
-
|
|
17032
|
+
const emittedParams = component.typeParameters || [];
|
|
17033
|
+
typeParameters = emittedParams;
|
|
17034
|
+
typeArguments = typeParameters.map((param) => param.name);
|
|
16770
17035
|
break;
|
|
16771
17036
|
case TcbGenericContextBehavior.CopyClassNodes:
|
|
16772
|
-
|
|
16773
|
-
|
|
17037
|
+
const copiedParams = component.typeParameters ? [...component.typeParameters] : [];
|
|
17038
|
+
typeParameters = copiedParams;
|
|
17039
|
+
typeArguments = typeParameters.map((param) => param.name);
|
|
16774
17040
|
break;
|
|
16775
17041
|
case TcbGenericContextBehavior.FallbackToAny:
|
|
16776
|
-
typeArguments =
|
|
17042
|
+
typeArguments = Array.from({ length: component.typeParameters?.length ?? 0 }).map(() => "any");
|
|
16777
17043
|
break;
|
|
16778
17044
|
}
|
|
16779
17045
|
}
|
|
16780
17046
|
const sourceFile = env.contextFile;
|
|
16781
|
-
const typeParamsStr = typeParameters === void 0 || typeParameters.length === 0 ? "" : `<${typeParameters.map((p) =>
|
|
16782
|
-
const typeArgsStr = typeArguments === void 0 || typeArguments.length === 0 ? "" : `<${typeArguments.
|
|
17047
|
+
const typeParamsStr = typeParameters === void 0 || typeParameters.length === 0 ? "" : `<${typeParameters.map((p) => p.representation).join(", ")}>`;
|
|
17048
|
+
const typeArgsStr = typeArguments === void 0 || typeArguments.length === 0 ? "" : `<${typeArguments.join(", ")}>`;
|
|
16783
17049
|
const typeRef = ts66.isIdentifier(ctxRawType.typeName) ? ctxRawType.typeName.text : tempPrint(ctxRawType.typeName, sourceFile);
|
|
16784
17050
|
const thisParamStr = `this: ${typeRef}${typeArgsStr}`;
|
|
16785
17051
|
const statements = [];
|
|
@@ -16817,6 +17083,7 @@ ${statements}
|
|
|
16817
17083
|
import ts67 from "typescript";
|
|
16818
17084
|
var TypeCheckFile = class extends Environment {
|
|
16819
17085
|
fileName;
|
|
17086
|
+
isTypeCheckFile = true;
|
|
16820
17087
|
nextTcbId = 1;
|
|
16821
17088
|
tcbStatements = [];
|
|
16822
17089
|
constructor(fileName, config, refEmitter, reflector, compilerHost) {
|
|
@@ -16831,7 +17098,8 @@ var TypeCheckFile = class extends Environment {
|
|
|
16831
17098
|
}
|
|
16832
17099
|
addTypeCheckBlock(ref, meta, domSchemaChecker, oobRecorder, genericContextBehavior) {
|
|
16833
17100
|
const fnId = ts67.factory.createIdentifier(`_tcb${this.nextTcbId++}`);
|
|
16834
|
-
const
|
|
17101
|
+
const { tcbMeta, component } = adaptTypeCheckBlockMetadata(ref, meta, this);
|
|
17102
|
+
const fn = generateTypeCheckBlock(this, component, fnId, tcbMeta, domSchemaChecker, oobRecorder, genericContextBehavior);
|
|
16835
17103
|
this.tcbStatements.push(fn);
|
|
16836
17104
|
}
|
|
16837
17105
|
render() {
|
|
@@ -16935,9 +17203,8 @@ var TypeCheckContextImpl = class {
|
|
|
16935
17203
|
// it comes from a .d.ts file. .d.ts declarations don't have bodies.
|
|
16936
17204
|
body: !dirNode.getSourceFile().isDeclarationFile,
|
|
16937
17205
|
fields: {
|
|
16938
|
-
inputs: dir.inputs
|
|
17206
|
+
inputs: dir.inputs
|
|
16939
17207
|
// TODO(alxhub): support queries
|
|
16940
|
-
queries: dir.queries
|
|
16941
17208
|
},
|
|
16942
17209
|
coercedInputFields: dir.coercedInputFields
|
|
16943
17210
|
});
|
|
@@ -17106,7 +17373,7 @@ var TypeCheckContextImpl = class {
|
|
|
17106
17373
|
if (!fileData.shimData.has(shimPath)) {
|
|
17107
17374
|
fileData.shimData.set(shimPath, {
|
|
17108
17375
|
domSchemaChecker: new RegistryDomSchemaChecker(fileData.sourceManager),
|
|
17109
|
-
oobRecorder: new OutOfBandDiagnosticRecorderImpl(fileData.sourceManager),
|
|
17376
|
+
oobRecorder: new OutOfBandDiagnosticRecorderImpl(fileData.sourceManager, (name) => this.compilerHost.getSourceFile(name, ts68.ScriptTarget.Latest)),
|
|
17110
17377
|
file: new TypeCheckFile(shimPath, this.config, this.refEmitter, this.reflector, this.compilerHost),
|
|
17111
17378
|
data: /* @__PURE__ */ new Map()
|
|
17112
17379
|
});
|
|
@@ -17159,7 +17426,8 @@ var InlineTcbOp = class {
|
|
|
17159
17426
|
execute(im, sf, refEmitter) {
|
|
17160
17427
|
const env = new Environment(this.config, im, refEmitter, this.reflector, sf);
|
|
17161
17428
|
const fnName = ts68.factory.createIdentifier(`_tcb_${this.ref.node.pos}`);
|
|
17162
|
-
const
|
|
17429
|
+
const { tcbMeta, component } = adaptTypeCheckBlockMetadata(this.ref, this.meta, env);
|
|
17430
|
+
const fn = generateTypeCheckBlock(env, component, fnName, tcbMeta, this.domSchemaChecker, this.oobRecorder, TcbGenericContextBehavior.CopyClassNodes);
|
|
17163
17431
|
return fn;
|
|
17164
17432
|
}
|
|
17165
17433
|
};
|
|
@@ -17185,7 +17453,7 @@ var TypeCtorOp = class {
|
|
|
17185
17453
|
};
|
|
17186
17454
|
|
|
17187
17455
|
// packages/compiler-cli/src/ngtsc/typecheck/src/diagnostics.js
|
|
17188
|
-
import { AbsoluteSourceSpan as
|
|
17456
|
+
import { AbsoluteSourceSpan as AbsoluteSourceSpan6 } from "@angular/compiler";
|
|
17189
17457
|
import ts69 from "typescript";
|
|
17190
17458
|
function shouldReportDiagnostic(diagnostic) {
|
|
17191
17459
|
const { code } = diagnostic;
|
|
@@ -17536,7 +17804,7 @@ var SymbolBuilder = class {
|
|
|
17536
17804
|
if (directives === null) {
|
|
17537
17805
|
return null;
|
|
17538
17806
|
}
|
|
17539
|
-
const directive = directives.find((m) => m.ref.node
|
|
17807
|
+
const directive = directives.find((m) => isSameDirectiveDeclaration(m.ref.node, directiveDeclaration));
|
|
17540
17808
|
if (directive) {
|
|
17541
17809
|
return directive;
|
|
17542
17810
|
}
|
|
@@ -17546,7 +17814,7 @@ var SymbolBuilder = class {
|
|
|
17546
17814
|
if (hasPotentialCandidate) {
|
|
17547
17815
|
const classWithSameName = findMatchingDirective(originalFile, directiveDeclaration);
|
|
17548
17816
|
if (classWithSameName !== null) {
|
|
17549
|
-
return directives.find((m) => m.ref.node
|
|
17817
|
+
return directives.find((m) => isSameDirectiveDeclaration(m.ref.node, classWithSameName)) ?? null;
|
|
17550
17818
|
}
|
|
17551
17819
|
}
|
|
17552
17820
|
}
|
|
@@ -17979,6 +18247,14 @@ function unwrapSignalInputWriteTAccessor(expr) {
|
|
|
17979
18247
|
typeExpr: expr
|
|
17980
18248
|
};
|
|
17981
18249
|
}
|
|
18250
|
+
function isSameDirectiveDeclaration(a, b) {
|
|
18251
|
+
if (a === b) {
|
|
18252
|
+
return true;
|
|
18253
|
+
}
|
|
18254
|
+
const aName = a.name?.text;
|
|
18255
|
+
const bName = b.name?.text;
|
|
18256
|
+
return aName !== void 0 && bName !== void 0 && aName === bName && a.getSourceFile().fileName === b.getSourceFile().fileName;
|
|
18257
|
+
}
|
|
17982
18258
|
function findMatchingDirective(originalSourceFile, directiveDeclarationInTypeCheckSourceFile) {
|
|
17983
18259
|
const className = directiveDeclarationInTypeCheckSourceFile.name?.text ?? "";
|
|
17984
18260
|
const ogClasses = collectClassesWithName(originalSourceFile, className);
|
|
@@ -18791,7 +19067,7 @@ var TemplateTypeCheckerImpl = class {
|
|
|
18791
19067
|
return null;
|
|
18792
19068
|
}
|
|
18793
19069
|
const emitted = emittedRef.expression;
|
|
18794
|
-
if (emitted instanceof
|
|
19070
|
+
if (emitted instanceof WrappedNodeExpr8) {
|
|
18795
19071
|
if (refTo.node === inContext) {
|
|
18796
19072
|
return null;
|
|
18797
19073
|
}
|
|
@@ -18803,7 +19079,7 @@ var TemplateTypeCheckerImpl = class {
|
|
|
18803
19079
|
}
|
|
18804
19080
|
}
|
|
18805
19081
|
return { kind, symbolName: emitted.node.text, isForwardReference };
|
|
18806
|
-
} else if (emitted instanceof
|
|
19082
|
+
} else if (emitted instanceof ExternalExpr9 && emitted.value.moduleName !== null && emitted.value.name !== null) {
|
|
18807
19083
|
return {
|
|
18808
19084
|
kind,
|
|
18809
19085
|
moduleSpecifier: emitted.value.moduleName,
|
|
@@ -19383,7 +19659,7 @@ var DirectiveDecoratorHandler = class {
|
|
|
19383
19659
|
symbol.baseClass = this.semanticDepGraphUpdater.getSymbol(analysis.baseClass.node);
|
|
19384
19660
|
}
|
|
19385
19661
|
const diagnostics = [];
|
|
19386
|
-
if (analysis.providersRequiringFactory !== null && analysis.meta.providers instanceof
|
|
19662
|
+
if (analysis.providersRequiringFactory !== null && analysis.meta.providers instanceof WrappedNodeExpr9) {
|
|
19387
19663
|
const providerDiagnostics = getProviderDiagnostics(analysis.providersRequiringFactory, analysis.meta.providers.node, this.injectableRegistry);
|
|
19388
19664
|
diagnostics.push(...providerDiagnostics);
|
|
19389
19665
|
}
|
|
@@ -19465,7 +19741,7 @@ var DirectiveDecoratorHandler = class {
|
|
|
19465
19741
|
};
|
|
19466
19742
|
|
|
19467
19743
|
// packages/compiler-cli/src/ngtsc/annotations/ng_module/src/handler.js
|
|
19468
|
-
import { compileClassMetadata as compileClassMetadata2, compileDeclareClassMetadata as compileDeclareClassMetadata2, compileDeclareInjectorFromMetadata, compileDeclareNgModuleFromMetadata, compileInjector, compileNgModule, ExternalExpr as
|
|
19744
|
+
import { compileClassMetadata as compileClassMetadata2, compileDeclareClassMetadata as compileDeclareClassMetadata2, compileDeclareInjectorFromMetadata, compileDeclareNgModuleFromMetadata, compileInjector, compileNgModule, ExternalExpr as ExternalExpr10, FactoryTarget as FactoryTarget2, FunctionExpr, InvokeFunctionExpr, LiteralArrayExpr as LiteralArrayExpr3, R3Identifiers as R3Identifiers7, R3NgModuleMetadataKind, R3SelectorScopeMode, ReturnStatement, WrappedNodeExpr as WrappedNodeExpr10 } from "@angular/compiler";
|
|
19469
19745
|
import ts74 from "typescript";
|
|
19470
19746
|
|
|
19471
19747
|
// packages/compiler-cli/src/ngtsc/annotations/ng_module/src/module_with_providers.js
|
|
@@ -19766,7 +20042,7 @@ var NgModuleDecoratorHandler = class {
|
|
|
19766
20042
|
if (ngModule.has("id")) {
|
|
19767
20043
|
const idExpr = ngModule.get("id");
|
|
19768
20044
|
if (!isModuleIdExpression(idExpr)) {
|
|
19769
|
-
id = new
|
|
20045
|
+
id = new WrappedNodeExpr10(idExpr);
|
|
19770
20046
|
} else {
|
|
19771
20047
|
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.`);
|
|
19772
20048
|
diag.category = ts74.DiagnosticCategory.Warning;
|
|
@@ -19795,10 +20071,10 @@ var NgModuleDecoratorHandler = class {
|
|
|
19795
20071
|
ngModuleMetadata = {
|
|
19796
20072
|
kind: R3NgModuleMetadataKind.Local,
|
|
19797
20073
|
type,
|
|
19798
|
-
bootstrapExpression: rawBootstrap ? new
|
|
19799
|
-
declarationsExpression: rawDeclarations ? new
|
|
19800
|
-
exportsExpression: rawExports ? new
|
|
19801
|
-
importsExpression: rawImports ? new
|
|
20074
|
+
bootstrapExpression: rawBootstrap ? new WrappedNodeExpr10(rawBootstrap) : null,
|
|
20075
|
+
declarationsExpression: rawDeclarations ? new WrappedNodeExpr10(rawDeclarations) : null,
|
|
20076
|
+
exportsExpression: rawExports ? new WrappedNodeExpr10(rawExports) : null,
|
|
20077
|
+
importsExpression: rawImports ? new WrappedNodeExpr10(rawImports) : null,
|
|
19802
20078
|
id,
|
|
19803
20079
|
// Use `ɵɵsetNgModuleScope` to patch selector scopes onto the generated definition in a
|
|
19804
20080
|
// tree-shakeable way.
|
|
@@ -19830,7 +20106,7 @@ var NgModuleDecoratorHandler = class {
|
|
|
19830
20106
|
const rawProviders = ngModule.has("providers") ? ngModule.get("providers") : null;
|
|
19831
20107
|
let wrappedProviders = null;
|
|
19832
20108
|
if (rawProviders !== null && (!ts74.isArrayLiteralExpression(rawProviders) || rawProviders.elements.length > 0)) {
|
|
19833
|
-
wrappedProviders = new
|
|
20109
|
+
wrappedProviders = new WrappedNodeExpr10(this.annotateForClosureCompiler ? wrapFunctionExpressionsInParens(rawProviders) : rawProviders);
|
|
19834
20110
|
}
|
|
19835
20111
|
const topLevelImports = [];
|
|
19836
20112
|
if (!allowUnresolvedReferences && ngModule.has("imports")) {
|
|
@@ -19880,10 +20156,10 @@ var NgModuleDecoratorHandler = class {
|
|
|
19880
20156
|
}
|
|
19881
20157
|
if (ts74.isArrayLiteralExpression(exp)) {
|
|
19882
20158
|
if (exp.elements) {
|
|
19883
|
-
injectorMetadata.imports.push(...exp.elements.map((n2) => new
|
|
20159
|
+
injectorMetadata.imports.push(...exp.elements.map((n2) => new WrappedNodeExpr10(n2)));
|
|
19884
20160
|
}
|
|
19885
20161
|
} else {
|
|
19886
|
-
injectorMetadata.imports.push(new
|
|
20162
|
+
injectorMetadata.imports.push(new WrappedNodeExpr10(exp));
|
|
19887
20163
|
}
|
|
19888
20164
|
}
|
|
19889
20165
|
}
|
|
@@ -19960,7 +20236,7 @@ var NgModuleDecoratorHandler = class {
|
|
|
19960
20236
|
};
|
|
19961
20237
|
for (const topLevelImport of analysis.imports) {
|
|
19962
20238
|
if (topLevelImport.hasModuleWithProviders) {
|
|
19963
|
-
data.injectorImports.push(new
|
|
20239
|
+
data.injectorImports.push(new WrappedNodeExpr10(topLevelImport.expression));
|
|
19964
20240
|
continue;
|
|
19965
20241
|
}
|
|
19966
20242
|
const refsToEmit = [];
|
|
@@ -19994,7 +20270,7 @@ var NgModuleDecoratorHandler = class {
|
|
|
19994
20270
|
refsToEmit.push(ref);
|
|
19995
20271
|
}
|
|
19996
20272
|
if (refsToEmit.length === topLevelImport.resolvedReferences.length) {
|
|
19997
|
-
data.injectorImports.push(new
|
|
20273
|
+
data.injectorImports.push(new WrappedNodeExpr10(topLevelImport.expression));
|
|
19998
20274
|
} else {
|
|
19999
20275
|
const context = node.getSourceFile();
|
|
20000
20276
|
for (const ref of refsToEmit) {
|
|
@@ -20108,7 +20384,7 @@ var NgModuleDecoratorHandler = class {
|
|
|
20108
20384
|
const componentType = this.refEmitter.emit(decl, context);
|
|
20109
20385
|
assertSuccessfulReferenceEmit(componentType, node, "component");
|
|
20110
20386
|
const declExpr = componentType.expression;
|
|
20111
|
-
const setComponentScope = new
|
|
20387
|
+
const setComponentScope = new ExternalExpr10(R3Identifiers7.setComponentScope);
|
|
20112
20388
|
const callExpr = new InvokeFunctionExpr(setComponentScope, [
|
|
20113
20389
|
declExpr,
|
|
20114
20390
|
directiveExpr,
|
|
@@ -21748,7 +22024,7 @@ var ComponentDecoratorHandler = class {
|
|
|
21748
22024
|
data.declarations = eagerDeclarations;
|
|
21749
22025
|
if (this.compilationMode === CompilationMode.LOCAL && this.localCompilationExtraImportsTracker !== null) {
|
|
21750
22026
|
for (const { type } of eagerDeclarations) {
|
|
21751
|
-
if (type instanceof
|
|
22027
|
+
if (type instanceof ExternalExpr11 && type.value.moduleName) {
|
|
21752
22028
|
this.localCompilationExtraImportsTracker.addImportForFile(context, type.value.moduleName);
|
|
21753
22029
|
}
|
|
21754
22030
|
}
|
|
@@ -22101,7 +22377,7 @@ function isDefaultImport(node) {
|
|
|
22101
22377
|
}
|
|
22102
22378
|
|
|
22103
22379
|
// packages/compiler-cli/src/ngtsc/annotations/src/injectable.js
|
|
22104
|
-
import { compileClassMetadata as compileClassMetadata3, compileDeclareClassMetadata as compileDeclareClassMetadata3, compileDeclareInjectableFromMetadata, compileInjectable, createMayBeForwardRefExpression as createMayBeForwardRefExpression3, FactoryTarget as FactoryTarget4, LiteralExpr as LiteralExpr3, WrappedNodeExpr as
|
|
22380
|
+
import { compileClassMetadata as compileClassMetadata3, compileDeclareClassMetadata as compileDeclareClassMetadata3, compileDeclareInjectableFromMetadata, compileInjectable, createMayBeForwardRefExpression as createMayBeForwardRefExpression3, FactoryTarget as FactoryTarget4, LiteralExpr as LiteralExpr3, WrappedNodeExpr as WrappedNodeExpr11 } from "@angular/compiler";
|
|
22105
22381
|
import ts80 from "typescript";
|
|
22106
22382
|
var InjectableDecoratorHandler = class {
|
|
22107
22383
|
reflector;
|
|
@@ -22263,7 +22539,7 @@ function extractInjectableMetadata(clazz, decorator, reflector) {
|
|
|
22263
22539
|
result.useClass = getProviderExpression(meta.get("useClass"), reflector);
|
|
22264
22540
|
result.deps = deps;
|
|
22265
22541
|
} else if (meta.has("useFactory")) {
|
|
22266
|
-
result.useFactory = new
|
|
22542
|
+
result.useFactory = new WrappedNodeExpr11(meta.get("useFactory"));
|
|
22267
22543
|
result.deps = deps;
|
|
22268
22544
|
}
|
|
22269
22545
|
return result;
|
|
@@ -22274,7 +22550,7 @@ function extractInjectableMetadata(clazz, decorator, reflector) {
|
|
|
22274
22550
|
function getProviderExpression(expression, reflector) {
|
|
22275
22551
|
const forwardRefValue = tryUnwrapForwardRef(expression, reflector);
|
|
22276
22552
|
return createMayBeForwardRefExpression3(
|
|
22277
|
-
new
|
|
22553
|
+
new WrappedNodeExpr11(forwardRefValue ?? expression),
|
|
22278
22554
|
forwardRefValue !== null ? 2 : 0
|
|
22279
22555
|
/* ForwardRefHandling.None */
|
|
22280
22556
|
);
|
|
@@ -22306,7 +22582,7 @@ function requiresValidCtor(meta) {
|
|
|
22306
22582
|
}
|
|
22307
22583
|
function getDep(dep, reflector) {
|
|
22308
22584
|
const meta = {
|
|
22309
|
-
token: new
|
|
22585
|
+
token: new WrappedNodeExpr11(dep),
|
|
22310
22586
|
attributeNameType: null,
|
|
22311
22587
|
host: false,
|
|
22312
22588
|
optional: false,
|
|
@@ -22321,7 +22597,7 @@ function getDep(dep, reflector) {
|
|
|
22321
22597
|
switch (source.name) {
|
|
22322
22598
|
case "Inject":
|
|
22323
22599
|
if (token !== void 0) {
|
|
22324
|
-
meta.token = new
|
|
22600
|
+
meta.token = new WrappedNodeExpr11(token);
|
|
22325
22601
|
}
|
|
22326
22602
|
break;
|
|
22327
22603
|
case "Optional":
|
|
@@ -22348,7 +22624,7 @@ function getDep(dep, reflector) {
|
|
|
22348
22624
|
isDecorator = maybeUpdateDecorator(el.expression, reflector, token);
|
|
22349
22625
|
}
|
|
22350
22626
|
if (!isDecorator) {
|
|
22351
|
-
meta.token = new
|
|
22627
|
+
meta.token = new WrappedNodeExpr11(el);
|
|
22352
22628
|
}
|
|
22353
22629
|
});
|
|
22354
22630
|
}
|
|
@@ -22892,3 +23168,10 @@ export {
|
|
|
22892
23168
|
* Use of this source code is governed by an MIT-style license that can be
|
|
22893
23169
|
* found in the LICENSE file at https://angular.dev/license
|
|
22894
23170
|
*/
|
|
23171
|
+
/**
|
|
23172
|
+
* @license
|
|
23173
|
+
* Copyright Google LLC All Rights Reserved.
|
|
23174
|
+
*
|
|
23175
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
23176
|
+
* found in the LICENSE file at https://angular.dev/license
|
|
23177
|
+
*/
|