@angular/compiler-cli 21.0.0-rc.0 → 21.0.0-rc.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bundles/{chunk-ZOZ6XVF3.js → chunk-JCBKDAHA.js} +238 -122
- package/bundles/{chunk-ZOLVJRLX.js → chunk-UI6E44E7.js} +2 -2
- package/bundles/{chunk-3CWKYDQ7.js → chunk-Y65S2AOA.js} +274 -25
- package/bundles/{chunk-HSIRUBJU.js → chunk-Z6XYTYZD.js} +1 -1
- package/bundles/{chunk-DT6FD4OE.js → chunk-ZJZNLTWN.js} +1 -2
- package/bundles/index.js +4 -4
- package/bundles/linker/babel/index.js +1 -1
- package/bundles/linker/index.js +1 -1
- package/bundles/private/migrations.js +2 -2
- package/bundles/private/testing.js +1 -1
- package/bundles/private/tooling.js +1 -1
- package/bundles/src/bin/ng_xi18n.js +4 -4
- package/bundles/src/bin/ngc.js +4 -4
- package/linker/src/file_linker/partial_linkers/util.d.ts +1 -1
- package/package.json +2 -2
- package/src/ngtsc/diagnostics/src/error_code.d.ts +2 -0
- package/src/ngtsc/docs/src/entities.d.ts +14 -2
- package/src/ngtsc/docs/src/extractor.d.ts +7 -0
- package/src/ngtsc/docs/src/namespace_extractor.d.ts +15 -0
- package/src/ngtsc/docs/src/type_alias_extractor.d.ts +1 -0
- package/src/ngtsc/docs/src/variable_extractor.d.ts +16 -0
- package/src/ngtsc/translator/src/translator.d.ts +1 -1
- package/src/ngtsc/typecheck/src/oob.d.ts +5 -0
|
@@ -87,7 +87,7 @@ import {
|
|
|
87
87
|
toUnredirectedSourceFile,
|
|
88
88
|
tryParseInitializerApi,
|
|
89
89
|
untagAllTsFiles
|
|
90
|
-
} from "./chunk-
|
|
90
|
+
} from "./chunk-Y65S2AOA.js";
|
|
91
91
|
import {
|
|
92
92
|
LogicalFileSystem,
|
|
93
93
|
absoluteFromSourceFile,
|
|
@@ -114,6 +114,7 @@ var EntryType;
|
|
|
114
114
|
EntryType2["TypeAlias"] = "type_alias";
|
|
115
115
|
EntryType2["UndecoratedClass"] = "undecorated_class";
|
|
116
116
|
EntryType2["InitializerApiFunction"] = "initializer_api_function";
|
|
117
|
+
EntryType2["Namespace"] = "namespace";
|
|
117
118
|
})(EntryType || (EntryType = {}));
|
|
118
119
|
var MemberType;
|
|
119
120
|
(function(MemberType2) {
|
|
@@ -122,6 +123,8 @@ var MemberType;
|
|
|
122
123
|
MemberType2["Getter"] = "getter";
|
|
123
124
|
MemberType2["Setter"] = "setter";
|
|
124
125
|
MemberType2["EnumItem"] = "enum_item";
|
|
126
|
+
MemberType2["Interface"] = "interface";
|
|
127
|
+
MemberType2["TypeAlias"] = "type_alias";
|
|
125
128
|
})(MemberType || (MemberType = {}));
|
|
126
129
|
var DecoratorType;
|
|
127
130
|
(function(DecoratorType2) {
|
|
@@ -145,7 +148,7 @@ function isDocEntryWithSourceInfo(entry) {
|
|
|
145
148
|
}
|
|
146
149
|
|
|
147
150
|
// packages/compiler-cli/src/ngtsc/docs/src/extractor.js
|
|
148
|
-
import
|
|
151
|
+
import ts14 from "typescript";
|
|
149
152
|
|
|
150
153
|
// packages/compiler-cli/src/ngtsc/docs/src/class_extractor.js
|
|
151
154
|
import ts6 from "typescript";
|
|
@@ -979,31 +982,55 @@ function getEnumMemberValue(memberNode) {
|
|
|
979
982
|
return literal?.getText() ?? "";
|
|
980
983
|
}
|
|
981
984
|
|
|
982
|
-
// packages/compiler-cli/src/ngtsc/docs/src/
|
|
985
|
+
// packages/compiler-cli/src/ngtsc/docs/src/import_extractor.js
|
|
983
986
|
import ts11 from "typescript";
|
|
987
|
+
function getImportedSymbols(sourceFile) {
|
|
988
|
+
const importSpecifiers = /* @__PURE__ */ new Map();
|
|
989
|
+
function visit(node) {
|
|
990
|
+
if (ts11.isImportDeclaration(node)) {
|
|
991
|
+
let moduleSpecifier = node.moduleSpecifier.getText(sourceFile).replace(/['"]/g, "");
|
|
992
|
+
if (moduleSpecifier.startsWith("@angular/")) {
|
|
993
|
+
const namedBindings = node.importClause?.namedBindings;
|
|
994
|
+
if (namedBindings && ts11.isNamedImports(namedBindings)) {
|
|
995
|
+
namedBindings.elements.forEach((importSpecifier) => {
|
|
996
|
+
const importName = importSpecifier.name.text;
|
|
997
|
+
const importAlias = importSpecifier.propertyName ? importSpecifier.propertyName.text : void 0;
|
|
998
|
+
importSpecifiers.set(importAlias ?? importName, moduleSpecifier);
|
|
999
|
+
});
|
|
1000
|
+
}
|
|
1001
|
+
}
|
|
1002
|
+
}
|
|
1003
|
+
ts11.forEachChild(node, visit);
|
|
1004
|
+
}
|
|
1005
|
+
visit(sourceFile);
|
|
1006
|
+
return importSpecifiers;
|
|
1007
|
+
}
|
|
1008
|
+
|
|
1009
|
+
// packages/compiler-cli/src/ngtsc/docs/src/initializer_api_function_extractor.js
|
|
1010
|
+
import ts12 from "typescript";
|
|
984
1011
|
var initializerApiTag = "initializerApiFunction";
|
|
985
1012
|
function isInitializerApiFunction(node, typeChecker) {
|
|
986
|
-
if (
|
|
1013
|
+
if (ts12.isFunctionDeclaration(node) && node.name !== void 0 && node.body === void 0) {
|
|
987
1014
|
const implementation = findImplementationOfFunction(node, typeChecker);
|
|
988
1015
|
if (implementation !== void 0) {
|
|
989
1016
|
node = implementation;
|
|
990
1017
|
}
|
|
991
1018
|
}
|
|
992
|
-
if (!
|
|
1019
|
+
if (!ts12.isFunctionDeclaration(node) && !ts12.isVariableDeclaration(node)) {
|
|
993
1020
|
return false;
|
|
994
1021
|
}
|
|
995
|
-
let tagContainer =
|
|
1022
|
+
let tagContainer = ts12.isFunctionDeclaration(node) ? node : getContainerVariableStatement(node);
|
|
996
1023
|
if (tagContainer === null) {
|
|
997
1024
|
return false;
|
|
998
1025
|
}
|
|
999
|
-
const tags =
|
|
1026
|
+
const tags = ts12.getJSDocTags(tagContainer);
|
|
1000
1027
|
return tags.some((t) => t.tagName.text === initializerApiTag);
|
|
1001
1028
|
}
|
|
1002
1029
|
function extractInitializerApiFunction(node, typeChecker) {
|
|
1003
|
-
if (node.name === void 0 || !
|
|
1030
|
+
if (node.name === void 0 || !ts12.isIdentifier(node.name)) {
|
|
1004
1031
|
throw new Error(`Initializer API: Expected literal variable name.`);
|
|
1005
1032
|
}
|
|
1006
|
-
const container =
|
|
1033
|
+
const container = ts12.isFunctionDeclaration(node) ? node : getContainerVariableStatement(node);
|
|
1007
1034
|
if (container === null) {
|
|
1008
1035
|
throw new Error("Initializer API: Could not find container AST node of variable.");
|
|
1009
1036
|
}
|
|
@@ -1014,7 +1041,7 @@ function extractInitializerApiFunction(node, typeChecker) {
|
|
|
1014
1041
|
for (const property of type.getProperties()) {
|
|
1015
1042
|
const subName = property.getName();
|
|
1016
1043
|
const subDecl = property.getDeclarations()?.[0];
|
|
1017
|
-
if (subDecl === void 0 || !
|
|
1044
|
+
if (subDecl === void 0 || !ts12.isPropertySignature(subDecl)) {
|
|
1018
1045
|
throw new Error(`Initializer API: Could not resolve declaration of sub-property: ${name}.${subName}`);
|
|
1019
1046
|
}
|
|
1020
1047
|
const subType = typeChecker.getTypeAtLocation(subDecl);
|
|
@@ -1023,7 +1050,7 @@ function extractInitializerApiFunction(node, typeChecker) {
|
|
|
1023
1050
|
let jsdocTags;
|
|
1024
1051
|
let description;
|
|
1025
1052
|
let rawComment;
|
|
1026
|
-
if (
|
|
1053
|
+
if (ts12.isFunctionDeclaration(node)) {
|
|
1027
1054
|
const implementation = findImplementationOfFunction(node, typeChecker);
|
|
1028
1055
|
if (implementation === void 0) {
|
|
1029
1056
|
throw new Error(`Initializer API: Could not find implementation of function: ${name}`);
|
|
@@ -1071,10 +1098,10 @@ function extractInitializerApiFunction(node, typeChecker) {
|
|
|
1071
1098
|
};
|
|
1072
1099
|
}
|
|
1073
1100
|
function getContainerVariableStatement(node) {
|
|
1074
|
-
if (!
|
|
1101
|
+
if (!ts12.isVariableDeclarationList(node.parent)) {
|
|
1075
1102
|
return null;
|
|
1076
1103
|
}
|
|
1077
|
-
if (!
|
|
1104
|
+
if (!ts12.isVariableStatement(node.parent.parent)) {
|
|
1078
1105
|
return null;
|
|
1079
1106
|
}
|
|
1080
1107
|
return node.parent.parent;
|
|
@@ -1088,6 +1115,9 @@ function extractFunctionWithOverloads(name, type, typeChecker) {
|
|
|
1088
1115
|
};
|
|
1089
1116
|
}
|
|
1090
1117
|
|
|
1118
|
+
// packages/compiler-cli/src/ngtsc/docs/src/namespace_extractor.js
|
|
1119
|
+
import ts13 from "typescript";
|
|
1120
|
+
|
|
1091
1121
|
// packages/compiler-cli/src/ngtsc/docs/src/type_alias_extractor.js
|
|
1092
1122
|
function extractTypeAlias(declaration) {
|
|
1093
1123
|
return {
|
|
@@ -1097,32 +1127,51 @@ function extractTypeAlias(declaration) {
|
|
|
1097
1127
|
generics: extractGenerics(declaration),
|
|
1098
1128
|
rawComment: extractRawJsDoc(declaration),
|
|
1099
1129
|
description: extractJsDocDescription(declaration),
|
|
1100
|
-
jsdocTags: extractJsDocTags(declaration)
|
|
1130
|
+
jsdocTags: extractJsDocTags(declaration),
|
|
1131
|
+
members: []
|
|
1101
1132
|
};
|
|
1102
1133
|
}
|
|
1103
1134
|
|
|
1104
|
-
// packages/compiler-cli/src/ngtsc/docs/src/
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1135
|
+
// packages/compiler-cli/src/ngtsc/docs/src/variable_extractor.js
|
|
1136
|
+
function extractFromVariableStatement(statement, typeChecker) {
|
|
1137
|
+
return statement.declarationList.declarations.map((declaration) => extractConstant(declaration, typeChecker));
|
|
1138
|
+
}
|
|
1139
|
+
|
|
1140
|
+
// packages/compiler-cli/src/ngtsc/docs/src/namespace_extractor.js
|
|
1141
|
+
function extractNamespace(node, typeChecker) {
|
|
1142
|
+
const members = [];
|
|
1143
|
+
if (node.body && ts13.isModuleBlock(node.body)) {
|
|
1144
|
+
for (const statement of node.body.statements) {
|
|
1145
|
+
let entries = [];
|
|
1146
|
+
if (ts13.isInterfaceDeclaration(statement)) {
|
|
1147
|
+
entries.push(extractInterface(statement, typeChecker));
|
|
1148
|
+
} else if (ts13.isTypeAliasDeclaration(statement)) {
|
|
1149
|
+
entries.push(extractTypeAlias(statement));
|
|
1150
|
+
} else if (ts13.isFunctionDeclaration(statement)) {
|
|
1151
|
+
const name = statement.name?.getText();
|
|
1152
|
+
if (name) {
|
|
1153
|
+
entries.push(new FunctionExtractor(name, statement, typeChecker).extract());
|
|
1119
1154
|
}
|
|
1155
|
+
} else if (ts13.isVariableStatement(statement)) {
|
|
1156
|
+
entries.push(...extractFromVariableStatement(statement, typeChecker));
|
|
1157
|
+
}
|
|
1158
|
+
let isExported = false;
|
|
1159
|
+
if (ts13.canHaveModifiers(statement)) {
|
|
1160
|
+
isExported = (ts13.getModifiers(statement) ?? []).some((modifier) => modifier.kind === ts13.SyntaxKind.ExportKeyword);
|
|
1161
|
+
}
|
|
1162
|
+
if (isExported) {
|
|
1163
|
+
members.push(...entries);
|
|
1120
1164
|
}
|
|
1121
1165
|
}
|
|
1122
|
-
ts12.forEachChild(node, visit);
|
|
1123
1166
|
}
|
|
1124
|
-
|
|
1125
|
-
|
|
1167
|
+
return {
|
|
1168
|
+
name: node.name.getText(),
|
|
1169
|
+
entryType: EntryType.Namespace,
|
|
1170
|
+
description: extractJsDocDescription(node),
|
|
1171
|
+
rawComment: extractRawJsDoc(node),
|
|
1172
|
+
jsdocTags: extractJsDocTags(node),
|
|
1173
|
+
members
|
|
1174
|
+
};
|
|
1126
1175
|
}
|
|
1127
1176
|
|
|
1128
1177
|
// packages/compiler-cli/src/ngtsc/docs/src/extractor.js
|
|
@@ -1143,34 +1192,74 @@ var DocsExtractor = class {
|
|
|
1143
1192
|
const entries = [];
|
|
1144
1193
|
const symbols = /* @__PURE__ */ new Map();
|
|
1145
1194
|
const exportedDeclarations = this.getExportedDeclarations(sourceFile);
|
|
1146
|
-
|
|
1195
|
+
const groupedDeclarations = /* @__PURE__ */ new Map();
|
|
1196
|
+
for (const [exportName, declaration] of exportedDeclarations) {
|
|
1197
|
+
if (!groupedDeclarations.has(exportName)) {
|
|
1198
|
+
groupedDeclarations.set(exportName, []);
|
|
1199
|
+
}
|
|
1200
|
+
groupedDeclarations.get(exportName).push(declaration);
|
|
1201
|
+
}
|
|
1202
|
+
for (const [exportName, declarations] of groupedDeclarations.entries()) {
|
|
1147
1203
|
if (isAngularPrivateName(exportName)) {
|
|
1148
1204
|
continue;
|
|
1149
1205
|
}
|
|
1150
|
-
const entry = this.
|
|
1206
|
+
const entry = this.extractDeclarations(exportName, declarations);
|
|
1151
1207
|
if (entry && !isIgnoredDocEntry(entry)) {
|
|
1152
|
-
const realSourceFile =
|
|
1208
|
+
const realSourceFile = declarations[0].getSourceFile();
|
|
1153
1209
|
const importedSymbols = getImportedSymbols(realSourceFile);
|
|
1154
1210
|
importedSymbols.forEach((moduleName, symbolName) => {
|
|
1155
1211
|
if (symbolName.startsWith("\u0275") || privateModules.has(moduleName)) {
|
|
1156
1212
|
return;
|
|
1157
1213
|
}
|
|
1158
1214
|
if (symbols.has(symbolName) && symbols.get(symbolName) !== moduleName) {
|
|
1159
|
-
throw new Error(`
|
|
1215
|
+
throw new Error(`Ambiguous symbol \`${symbolName}\` exported by both ${symbols.get(symbolName)} & ${moduleName}`);
|
|
1160
1216
|
}
|
|
1161
1217
|
symbols.set(symbolName, moduleName);
|
|
1162
1218
|
});
|
|
1163
1219
|
entry.source = {
|
|
1164
1220
|
filePath: getRelativeFilePath(realSourceFile, rootDir),
|
|
1165
1221
|
// Start & End are off by 1
|
|
1166
|
-
startLine:
|
|
1167
|
-
endLine:
|
|
1222
|
+
startLine: ts14.getLineAndCharacterOfPosition(realSourceFile, declarations[0].getStart()).line + 1,
|
|
1223
|
+
endLine: ts14.getLineAndCharacterOfPosition(realSourceFile, declarations[0].getEnd()).line + 1
|
|
1168
1224
|
};
|
|
1169
1225
|
entries.push({ ...entry, name: exportName });
|
|
1170
1226
|
}
|
|
1171
1227
|
}
|
|
1172
1228
|
return { entries, symbols };
|
|
1173
1229
|
}
|
|
1230
|
+
/**
|
|
1231
|
+
* Extracts a documentation entry for a given set of declarations that are all exported under
|
|
1232
|
+
* the same name. This is used to combine entries, e.g. for a type and a namespace that are
|
|
1233
|
+
* exported under the same name.
|
|
1234
|
+
*/
|
|
1235
|
+
extractDeclarations(exportName, nodes) {
|
|
1236
|
+
const entries = nodes.map((node) => this.extractDeclaration(node));
|
|
1237
|
+
const decorator = entries.find((e) => e?.entryType === EntryType.Decorator);
|
|
1238
|
+
if (decorator) {
|
|
1239
|
+
return decorator;
|
|
1240
|
+
}
|
|
1241
|
+
const entry = entries[0];
|
|
1242
|
+
if (entries.length > 1) {
|
|
1243
|
+
const typeAlias = entries.find(isTypeAliasEntry);
|
|
1244
|
+
const namespace = entries.find(isNamespaceEntry);
|
|
1245
|
+
const interfaceEntry = entries.find(isInterfaceEntry);
|
|
1246
|
+
if (typeAlias && namespace) {
|
|
1247
|
+
typeAlias.members.push(...this.getTypeMembersFromNamespace(namespace));
|
|
1248
|
+
return typeAlias;
|
|
1249
|
+
}
|
|
1250
|
+
if (interfaceEntry && namespace) {
|
|
1251
|
+
interfaceEntry.members.push(...this.getTypeMembersFromNamespace(namespace));
|
|
1252
|
+
}
|
|
1253
|
+
}
|
|
1254
|
+
return entry ?? null;
|
|
1255
|
+
}
|
|
1256
|
+
getTypeMembersFromNamespace(namespace) {
|
|
1257
|
+
return namespace.members.filter((e) => isInterfaceEntry(e) || isTypeAliasEntry(e)).map((e) => ({
|
|
1258
|
+
...e,
|
|
1259
|
+
memberType: e.entryType === EntryType.Interface ? MemberType.Interface : MemberType.TypeAlias,
|
|
1260
|
+
memberTags: []
|
|
1261
|
+
}));
|
|
1262
|
+
}
|
|
1174
1263
|
/** Extract the doc entry for a single declaration. */
|
|
1175
1264
|
extractDeclaration(node) {
|
|
1176
1265
|
if (isNamedClassDeclaration(node)) {
|
|
@@ -1179,30 +1268,48 @@ var DocsExtractor = class {
|
|
|
1179
1268
|
if (isInitializerApiFunction(node, this.typeChecker)) {
|
|
1180
1269
|
return extractInitializerApiFunction(node, this.typeChecker);
|
|
1181
1270
|
}
|
|
1182
|
-
if (
|
|
1271
|
+
if (ts14.isInterfaceDeclaration(node) && !isIgnoredInterface(node)) {
|
|
1183
1272
|
return extractInterface(node, this.typeChecker);
|
|
1184
1273
|
}
|
|
1185
|
-
if (
|
|
1274
|
+
if (ts14.isFunctionDeclaration(node)) {
|
|
1186
1275
|
const functionExtractor = new FunctionExtractor(node.name.getText(), node, this.typeChecker);
|
|
1187
1276
|
return functionExtractor.extract();
|
|
1188
1277
|
}
|
|
1189
|
-
if (
|
|
1278
|
+
if (ts14.isVariableDeclaration(node) && !isSyntheticAngularConstant(node)) {
|
|
1190
1279
|
return isDecoratorDeclaration(node) ? extractorDecorator(node, this.typeChecker) : extractConstant(node, this.typeChecker);
|
|
1191
1280
|
}
|
|
1192
|
-
if (
|
|
1281
|
+
if (ts14.isTypeAliasDeclaration(node)) {
|
|
1193
1282
|
return extractTypeAlias(node);
|
|
1194
1283
|
}
|
|
1195
|
-
if (
|
|
1284
|
+
if (ts14.isEnumDeclaration(node)) {
|
|
1196
1285
|
return extractEnum(node, this.typeChecker);
|
|
1197
1286
|
}
|
|
1287
|
+
if (ts14.isModuleDeclaration(node)) {
|
|
1288
|
+
return extractNamespace(node, this.typeChecker);
|
|
1289
|
+
}
|
|
1198
1290
|
return null;
|
|
1199
1291
|
}
|
|
1200
1292
|
/** Gets the list of exported declarations for doc extraction. */
|
|
1201
1293
|
getExportedDeclarations(sourceFile) {
|
|
1202
|
-
const
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1294
|
+
const moduleSymbol = this.typeChecker.getSymbolAtLocation(sourceFile);
|
|
1295
|
+
if (!moduleSymbol) {
|
|
1296
|
+
return [];
|
|
1297
|
+
}
|
|
1298
|
+
const exportedSymbols = this.typeChecker.getExportsOfModule(moduleSymbol);
|
|
1299
|
+
const result = [];
|
|
1300
|
+
for (const symbol of exportedSymbols) {
|
|
1301
|
+
let declarations = symbol.getDeclarations();
|
|
1302
|
+
if (symbol.flags & ts14.SymbolFlags.Alias) {
|
|
1303
|
+
const aliasedSymbol = this.typeChecker.getAliasedSymbol(symbol);
|
|
1304
|
+
declarations = aliasedSymbol.getDeclarations();
|
|
1305
|
+
}
|
|
1306
|
+
if (declarations) {
|
|
1307
|
+
for (const declaration of declarations) {
|
|
1308
|
+
result.push([symbol.name, declaration]);
|
|
1309
|
+
}
|
|
1310
|
+
}
|
|
1311
|
+
}
|
|
1312
|
+
return result.sort(([, declarationA], [, declarationB]) => declarationA.pos - declarationB.pos);
|
|
1206
1313
|
}
|
|
1207
1314
|
};
|
|
1208
1315
|
function isIgnoredInterface(node) {
|
|
@@ -1220,6 +1327,15 @@ function getRelativeFilePath(sourceFile, rootDir) {
|
|
|
1220
1327
|
const relativePath = fullPath.replace(rootDir, "");
|
|
1221
1328
|
return relativePath;
|
|
1222
1329
|
}
|
|
1330
|
+
function isTypeAliasEntry(e) {
|
|
1331
|
+
return e?.entryType === EntryType.TypeAlias;
|
|
1332
|
+
}
|
|
1333
|
+
function isNamespaceEntry(e) {
|
|
1334
|
+
return e?.entryType === EntryType.Namespace;
|
|
1335
|
+
}
|
|
1336
|
+
function isInterfaceEntry(e) {
|
|
1337
|
+
return e?.entryType === EntryType.Interface;
|
|
1338
|
+
}
|
|
1223
1339
|
|
|
1224
1340
|
// packages/compiler-cli/src/ngtsc/core/api/src/public_options.js
|
|
1225
1341
|
var DiagnosticCategoryLabel;
|
|
@@ -1230,7 +1346,7 @@ var DiagnosticCategoryLabel;
|
|
|
1230
1346
|
})(DiagnosticCategoryLabel || (DiagnosticCategoryLabel = {}));
|
|
1231
1347
|
|
|
1232
1348
|
// packages/compiler-cli/src/ngtsc/core/src/compiler.js
|
|
1233
|
-
import
|
|
1349
|
+
import ts27 from "typescript";
|
|
1234
1350
|
|
|
1235
1351
|
// packages/compiler-cli/src/ngtsc/cycles/src/analyzer.js
|
|
1236
1352
|
var CycleAnalyzer = class {
|
|
@@ -1339,7 +1455,7 @@ var Cycle = class {
|
|
|
1339
1455
|
};
|
|
1340
1456
|
|
|
1341
1457
|
// packages/compiler-cli/src/ngtsc/cycles/src/imports.js
|
|
1342
|
-
import
|
|
1458
|
+
import ts15 from "typescript";
|
|
1343
1459
|
var ImportGraph = class {
|
|
1344
1460
|
checker;
|
|
1345
1461
|
perf;
|
|
@@ -1405,10 +1521,10 @@ var ImportGraph = class {
|
|
|
1405
1521
|
return this.perf.inPhase(PerfPhase.CycleDetection, () => {
|
|
1406
1522
|
const imports = /* @__PURE__ */ new Set();
|
|
1407
1523
|
for (const stmt of sf.statements) {
|
|
1408
|
-
if (!
|
|
1524
|
+
if (!ts15.isImportDeclaration(stmt) && !ts15.isExportDeclaration(stmt) || stmt.moduleSpecifier === void 0) {
|
|
1409
1525
|
continue;
|
|
1410
1526
|
}
|
|
1411
|
-
if (
|
|
1527
|
+
if (ts15.isImportDeclaration(stmt) && stmt.importClause !== void 0 && isTypeOnlyImportClause(stmt.importClause)) {
|
|
1412
1528
|
continue;
|
|
1413
1529
|
}
|
|
1414
1530
|
const symbol = this.checker.getSymbolAtLocation(stmt.moduleSpecifier);
|
|
@@ -1416,7 +1532,7 @@ var ImportGraph = class {
|
|
|
1416
1532
|
continue;
|
|
1417
1533
|
}
|
|
1418
1534
|
const moduleFile = symbol.valueDeclaration;
|
|
1419
|
-
if (
|
|
1535
|
+
if (ts15.isSourceFile(moduleFile) && isLocalFile(moduleFile)) {
|
|
1420
1536
|
imports.add(moduleFile);
|
|
1421
1537
|
}
|
|
1422
1538
|
}
|
|
@@ -1431,7 +1547,7 @@ function isTypeOnlyImportClause(node) {
|
|
|
1431
1547
|
if (node.isTypeOnly) {
|
|
1432
1548
|
return true;
|
|
1433
1549
|
}
|
|
1434
|
-
if (node.namedBindings !== void 0 &&
|
|
1550
|
+
if (node.namedBindings !== void 0 && ts15.isNamedImports(node.namedBindings) && node.namedBindings.elements.every((specifier) => specifier.isTypeOnly)) {
|
|
1435
1551
|
return true;
|
|
1436
1552
|
}
|
|
1437
1553
|
return false;
|
|
@@ -1459,7 +1575,7 @@ var Found = class {
|
|
|
1459
1575
|
};
|
|
1460
1576
|
|
|
1461
1577
|
// packages/compiler-cli/src/ngtsc/entry_point/src/generator.js
|
|
1462
|
-
import
|
|
1578
|
+
import ts16 from "typescript";
|
|
1463
1579
|
var FlatIndexGenerator = class {
|
|
1464
1580
|
entryPoint;
|
|
1465
1581
|
moduleName;
|
|
@@ -1478,7 +1594,7 @@ var FlatIndexGenerator = class {
|
|
|
1478
1594
|
|
|
1479
1595
|
export * from '${relativeEntryPoint}';
|
|
1480
1596
|
`;
|
|
1481
|
-
const genFile =
|
|
1597
|
+
const genFile = ts16.createSourceFile(this.flatIndexPath, contents, ts16.ScriptTarget.ES2015, true, ts16.ScriptKind.TS);
|
|
1482
1598
|
if (this.moduleName !== null) {
|
|
1483
1599
|
genFile.moduleName = this.moduleName;
|
|
1484
1600
|
}
|
|
@@ -1503,7 +1619,7 @@ function findFlatIndexEntryPoint(rootFiles) {
|
|
|
1503
1619
|
}
|
|
1504
1620
|
|
|
1505
1621
|
// packages/compiler-cli/src/ngtsc/entry_point/src/private_export_checker.js
|
|
1506
|
-
import
|
|
1622
|
+
import ts17 from "typescript";
|
|
1507
1623
|
function checkForPrivateExports(entryPoint, checker, refGraph) {
|
|
1508
1624
|
const diagnostics = [];
|
|
1509
1625
|
const topLevelExports = /* @__PURE__ */ new Set();
|
|
@@ -1513,7 +1629,7 @@ function checkForPrivateExports(entryPoint, checker, refGraph) {
|
|
|
1513
1629
|
}
|
|
1514
1630
|
const exportedSymbols = checker.getExportsOfModule(moduleSymbol);
|
|
1515
1631
|
exportedSymbols.forEach((symbol) => {
|
|
1516
|
-
if (symbol.flags &
|
|
1632
|
+
if (symbol.flags & ts17.SymbolFlags.Alias) {
|
|
1517
1633
|
symbol = checker.getAliasedSymbol(symbol);
|
|
1518
1634
|
}
|
|
1519
1635
|
const decl = symbol.valueDeclaration;
|
|
@@ -1537,7 +1653,7 @@ function checkForPrivateExports(entryPoint, checker, refGraph) {
|
|
|
1537
1653
|
visibleVia = transitivePath.map((seg) => getNameOfDeclaration(seg)).join(" -> ");
|
|
1538
1654
|
}
|
|
1539
1655
|
const diagnostic = {
|
|
1540
|
-
category:
|
|
1656
|
+
category: ts17.DiagnosticCategory.Error,
|
|
1541
1657
|
code: ngErrorCode(ErrorCode.SYMBOL_NOT_EXPORTED),
|
|
1542
1658
|
file: transitiveReference.getSourceFile(),
|
|
1543
1659
|
...getPosOfDeclaration(transitiveReference),
|
|
@@ -1557,7 +1673,7 @@ function getPosOfDeclaration(decl) {
|
|
|
1557
1673
|
};
|
|
1558
1674
|
}
|
|
1559
1675
|
function getIdentifierOfDeclaration(decl) {
|
|
1560
|
-
if ((
|
|
1676
|
+
if ((ts17.isClassDeclaration(decl) || ts17.isVariableDeclaration(decl) || ts17.isFunctionDeclaration(decl)) && decl.name !== void 0 && ts17.isIdentifier(decl.name)) {
|
|
1561
1677
|
return decl.name;
|
|
1562
1678
|
} else {
|
|
1563
1679
|
return null;
|
|
@@ -1569,13 +1685,13 @@ function getNameOfDeclaration(decl) {
|
|
|
1569
1685
|
}
|
|
1570
1686
|
function getDescriptorOfDeclaration(decl) {
|
|
1571
1687
|
switch (decl.kind) {
|
|
1572
|
-
case
|
|
1688
|
+
case ts17.SyntaxKind.ClassDeclaration:
|
|
1573
1689
|
return "class";
|
|
1574
|
-
case
|
|
1690
|
+
case ts17.SyntaxKind.FunctionDeclaration:
|
|
1575
1691
|
return "function";
|
|
1576
|
-
case
|
|
1692
|
+
case ts17.SyntaxKind.VariableDeclaration:
|
|
1577
1693
|
return "variable";
|
|
1578
|
-
case
|
|
1694
|
+
case ts17.SyntaxKind.EnumDeclaration:
|
|
1579
1695
|
return "enum";
|
|
1580
1696
|
default:
|
|
1581
1697
|
return "declaration";
|
|
@@ -2415,7 +2531,7 @@ var NgModuleIndexImpl = class {
|
|
|
2415
2531
|
};
|
|
2416
2532
|
|
|
2417
2533
|
// packages/compiler-cli/src/ngtsc/resource/src/loader.js
|
|
2418
|
-
import
|
|
2534
|
+
import ts18 from "typescript";
|
|
2419
2535
|
var CSS_PREPROCESSOR_EXT = /(\.scss|\.sass|\.less|\.styl)$/;
|
|
2420
2536
|
var RESOURCE_MARKER = ".$ngresource$";
|
|
2421
2537
|
var RESOURCE_MARKER_TS = RESOURCE_MARKER + ".ts";
|
|
@@ -2591,7 +2707,7 @@ var AdapterResourceLoader = class {
|
|
|
2591
2707
|
* for the file by setting up a module resolution for it that will fail.
|
|
2592
2708
|
*/
|
|
2593
2709
|
getResolvedCandidateLocations(url, fromFile) {
|
|
2594
|
-
const failedLookup =
|
|
2710
|
+
const failedLookup = ts18.resolveModuleName(url + RESOURCE_MARKER, fromFile, this.options, this.lookupResolutionHost);
|
|
2595
2711
|
if (failedLookup.failedLookupLocations === void 0) {
|
|
2596
2712
|
throw new Error(`Internal error: expected to find failedLookupLocations during resolution of resource '${url}' in context of ${fromFile}`);
|
|
2597
2713
|
}
|
|
@@ -2727,7 +2843,7 @@ var StandaloneComponentScopeReader = class {
|
|
|
2727
2843
|
import { ASTWithSource as ASTWithSource2, BindingType, Interpolation, PrefixNot, PropertyRead as PropertyRead2, TmplAstBoundAttribute, TmplAstElement as TmplAstElement2, TmplAstIfBlock, TmplAstSwitchBlock, TmplAstTemplate as TmplAstTemplate2 } from "@angular/compiler";
|
|
2728
2844
|
|
|
2729
2845
|
// packages/compiler-cli/src/ngtsc/typecheck/src/symbol_util.js
|
|
2730
|
-
import
|
|
2846
|
+
import ts19 from "typescript";
|
|
2731
2847
|
var SIGNAL_FNS = /* @__PURE__ */ new Set([
|
|
2732
2848
|
"WritableSignal",
|
|
2733
2849
|
"Signal",
|
|
@@ -2744,7 +2860,7 @@ function isSignalSymbol(symbol) {
|
|
|
2744
2860
|
const declarations = symbol.getDeclarations();
|
|
2745
2861
|
return declarations !== void 0 && declarations.some((decl) => {
|
|
2746
2862
|
const fileName = decl.getSourceFile().fileName;
|
|
2747
|
-
return (
|
|
2863
|
+
return (ts19.isInterfaceDeclaration(decl) || ts19.isTypeAliasDeclaration(decl)) && SIGNAL_FNS.has(decl.name.text) && (fileName.includes("@angular/core") || fileName.includes("angular2/rc/packages/core") || fileName.includes("bin/packages/core"));
|
|
2748
2864
|
});
|
|
2749
2865
|
}
|
|
2750
2866
|
|
|
@@ -3033,7 +3149,7 @@ var factory5 = {
|
|
|
3033
3149
|
|
|
3034
3150
|
// packages/compiler-cli/src/ngtsc/typecheck/extended/checks/nullish_coalescing_not_nullable/index.js
|
|
3035
3151
|
import { Binary } from "@angular/compiler";
|
|
3036
|
-
import
|
|
3152
|
+
import ts20 from "typescript";
|
|
3037
3153
|
var NullishCoalescingNotNullableCheck = class extends TemplateCheckWithVisitor {
|
|
3038
3154
|
code = ErrorCode.NULLISH_COALESCING_NOT_NULLABLE;
|
|
3039
3155
|
visitNode(ctx, component, node) {
|
|
@@ -3044,7 +3160,7 @@ var NullishCoalescingNotNullableCheck = class extends TemplateCheckWithVisitor {
|
|
|
3044
3160
|
return [];
|
|
3045
3161
|
}
|
|
3046
3162
|
const typeLeft = symbolLeft.tsType;
|
|
3047
|
-
if (typeLeft.flags & (
|
|
3163
|
+
if (typeLeft.flags & (ts20.TypeFlags.Any | ts20.TypeFlags.Unknown)) {
|
|
3048
3164
|
return [];
|
|
3049
3165
|
}
|
|
3050
3166
|
if (typeLeft.getNonNullableType() !== typeLeft)
|
|
@@ -3075,7 +3191,7 @@ var factory6 = {
|
|
|
3075
3191
|
|
|
3076
3192
|
// packages/compiler-cli/src/ngtsc/typecheck/extended/checks/optional_chain_not_nullable/index.js
|
|
3077
3193
|
import { KeyedRead, SafeCall, SafeKeyedRead, SafePropertyRead } from "@angular/compiler";
|
|
3078
|
-
import
|
|
3194
|
+
import ts21 from "typescript";
|
|
3079
3195
|
var OptionalChainNotNullableCheck = class extends TemplateCheckWithVisitor {
|
|
3080
3196
|
noUncheckedIndexedAccess;
|
|
3081
3197
|
code = ErrorCode.OPTIONAL_CHAIN_NOT_NULLABLE;
|
|
@@ -3095,7 +3211,7 @@ var OptionalChainNotNullableCheck = class extends TemplateCheckWithVisitor {
|
|
|
3095
3211
|
return [];
|
|
3096
3212
|
}
|
|
3097
3213
|
const typeLeft = symbolLeft.tsType;
|
|
3098
|
-
if (typeLeft.flags & (
|
|
3214
|
+
if (typeLeft.flags & (ts21.TypeFlags.Any | ts21.TypeFlags.Unknown)) {
|
|
3099
3215
|
return [];
|
|
3100
3216
|
}
|
|
3101
3217
|
if (typeLeft.getNonNullableType() !== typeLeft)
|
|
@@ -3465,7 +3581,7 @@ var factory16 = {
|
|
|
3465
3581
|
};
|
|
3466
3582
|
|
|
3467
3583
|
// packages/compiler-cli/src/ngtsc/typecheck/extended/src/extended_template_checker.js
|
|
3468
|
-
import
|
|
3584
|
+
import ts22 from "typescript";
|
|
3469
3585
|
var ExtendedTemplateCheckerImpl = class {
|
|
3470
3586
|
partialCtx;
|
|
3471
3587
|
templateChecks;
|
|
@@ -3507,9 +3623,9 @@ var ExtendedTemplateCheckerImpl = class {
|
|
|
3507
3623
|
function diagnosticLabelToCategory(label) {
|
|
3508
3624
|
switch (label) {
|
|
3509
3625
|
case DiagnosticCategoryLabel.Warning:
|
|
3510
|
-
return
|
|
3626
|
+
return ts22.DiagnosticCategory.Warning;
|
|
3511
3627
|
case DiagnosticCategoryLabel.Error:
|
|
3512
|
-
return
|
|
3628
|
+
return ts22.DiagnosticCategory.Error;
|
|
3513
3629
|
case DiagnosticCategoryLabel.Suppress:
|
|
3514
3630
|
return null;
|
|
3515
3631
|
default:
|
|
@@ -3548,7 +3664,7 @@ var SUPPORTED_DIAGNOSTIC_NAMES = /* @__PURE__ */ new Set([
|
|
|
3548
3664
|
|
|
3549
3665
|
// packages/compiler-cli/src/ngtsc/typecheck/template_semantics/src/template_semantics_checker.js
|
|
3550
3666
|
import { ASTWithSource as ASTWithSource5, ImplicitReceiver as ImplicitReceiver2, ParsedEventType as ParsedEventType2, PropertyRead as PropertyRead6, Binary as Binary3, RecursiveAstVisitor, TmplAstBoundEvent as TmplAstBoundEvent3, TmplAstLetDeclaration as TmplAstLetDeclaration2, TmplAstRecursiveVisitor, TmplAstVariable as TmplAstVariable2 } from "@angular/compiler";
|
|
3551
|
-
import
|
|
3667
|
+
import ts23 from "typescript";
|
|
3552
3668
|
var TemplateSemanticsCheckerImpl = class {
|
|
3553
3669
|
templateTypeChecker;
|
|
3554
3670
|
constructor(templateTypeChecker) {
|
|
@@ -3631,7 +3747,7 @@ var ExpressionsSemanticsVisitor = class extends RecursiveAstVisitor {
|
|
|
3631
3747
|
}
|
|
3632
3748
|
makeIllegalTemplateVarDiagnostic(target, expressionNode, errorMessage) {
|
|
3633
3749
|
const span = target instanceof TmplAstVariable2 ? target.valueSpan || target.sourceSpan : target.sourceSpan;
|
|
3634
|
-
return this.templateTypeChecker.makeTemplateDiagnostic(this.component, expressionNode.handlerSpan,
|
|
3750
|
+
return this.templateTypeChecker.makeTemplateDiagnostic(this.component, expressionNode.handlerSpan, ts23.DiagnosticCategory.Error, ngErrorCode(ErrorCode.WRITE_TO_READ_ONLY_VARIABLE), errorMessage, [
|
|
3635
3751
|
{
|
|
3636
3752
|
text: `'${target.name}' is declared here.`,
|
|
3637
3753
|
start: span.start.offset,
|
|
@@ -3646,7 +3762,7 @@ function unwrapAstWithSource(ast) {
|
|
|
3646
3762
|
}
|
|
3647
3763
|
|
|
3648
3764
|
// packages/compiler-cli/src/ngtsc/validation/src/rules/initializer_api_usage_rule.js
|
|
3649
|
-
import
|
|
3765
|
+
import ts24 from "typescript";
|
|
3650
3766
|
var APIS_TO_CHECK = [
|
|
3651
3767
|
INPUT_INITIALIZER_FN,
|
|
3652
3768
|
MODEL_INITIALIZER_FN,
|
|
@@ -3666,13 +3782,13 @@ var InitializerApiUsageRule = class {
|
|
|
3666
3782
|
});
|
|
3667
3783
|
}
|
|
3668
3784
|
checkNode(node) {
|
|
3669
|
-
if (!
|
|
3785
|
+
if (!ts24.isCallExpression(node)) {
|
|
3670
3786
|
return null;
|
|
3671
3787
|
}
|
|
3672
|
-
while (node.parent && (
|
|
3788
|
+
while (node.parent && (ts24.isParenthesizedExpression(node.parent) || ts24.isAsExpression(node.parent))) {
|
|
3673
3789
|
node = node.parent;
|
|
3674
3790
|
}
|
|
3675
|
-
if (!node.parent || !
|
|
3791
|
+
if (!node.parent || !ts24.isCallExpression(node)) {
|
|
3676
3792
|
return null;
|
|
3677
3793
|
}
|
|
3678
3794
|
const identifiedInitializer = tryParseInitializerApi(APIS_TO_CHECK, node, this.reflector, this.importedSymbolsTracker);
|
|
@@ -3680,12 +3796,12 @@ var InitializerApiUsageRule = class {
|
|
|
3680
3796
|
return null;
|
|
3681
3797
|
}
|
|
3682
3798
|
const functionName = identifiedInitializer.api.functionName + (identifiedInitializer.isRequired ? ".required" : "");
|
|
3683
|
-
if (
|
|
3799
|
+
if (ts24.isPropertyDeclaration(node.parent) && node.parent.initializer === node) {
|
|
3684
3800
|
let closestClass = node.parent;
|
|
3685
|
-
while (closestClass && !
|
|
3801
|
+
while (closestClass && !ts24.isClassDeclaration(closestClass)) {
|
|
3686
3802
|
closestClass = closestClass.parent;
|
|
3687
3803
|
}
|
|
3688
|
-
if (closestClass &&
|
|
3804
|
+
if (closestClass && ts24.isClassDeclaration(closestClass)) {
|
|
3689
3805
|
const decorators = this.reflector.getDecoratorsOfDeclaration(closestClass);
|
|
3690
3806
|
const isComponentOrDirective = decorators !== null && decorators.some((decorator) => {
|
|
3691
3807
|
return decorator.import?.from === "@angular/core" && (decorator.name === "Component" || decorator.name === "Directive");
|
|
@@ -3698,7 +3814,7 @@ var InitializerApiUsageRule = class {
|
|
|
3698
3814
|
};
|
|
3699
3815
|
|
|
3700
3816
|
// packages/compiler-cli/src/ngtsc/validation/src/rules/unused_standalone_imports_rule.js
|
|
3701
|
-
import
|
|
3817
|
+
import ts25 from "typescript";
|
|
3702
3818
|
var UnusedStandaloneImportsRule = class {
|
|
3703
3819
|
templateTypeChecker;
|
|
3704
3820
|
typeCheckingConfig;
|
|
@@ -3712,7 +3828,7 @@ var UnusedStandaloneImportsRule = class {
|
|
|
3712
3828
|
return this.typeCheckingConfig.unusedStandaloneImports !== "suppress" && (this.importedSymbolsTracker.hasNamedImport(sourceFile, "Component", "@angular/core") || this.importedSymbolsTracker.hasNamespaceImport(sourceFile, "@angular/core"));
|
|
3713
3829
|
}
|
|
3714
3830
|
checkNode(node) {
|
|
3715
|
-
if (!
|
|
3831
|
+
if (!ts25.isClassDeclaration(node)) {
|
|
3716
3832
|
return null;
|
|
3717
3833
|
}
|
|
3718
3834
|
const metadata = this.templateTypeChecker.getDirectiveMetadata(node);
|
|
@@ -3728,8 +3844,8 @@ var UnusedStandaloneImportsRule = class {
|
|
|
3728
3844
|
if (unused === null) {
|
|
3729
3845
|
return null;
|
|
3730
3846
|
}
|
|
3731
|
-
const propertyAssignment = closestNode(metadata.rawImports,
|
|
3732
|
-
const category = this.typeCheckingConfig.unusedStandaloneImports === "error" ?
|
|
3847
|
+
const propertyAssignment = closestNode(metadata.rawImports, ts25.isPropertyAssignment);
|
|
3848
|
+
const category = this.typeCheckingConfig.unusedStandaloneImports === "error" ? ts25.DiagnosticCategory.Error : ts25.DiagnosticCategory.Warning;
|
|
3733
3849
|
if (unused.length === metadata.imports.length && propertyAssignment !== null) {
|
|
3734
3850
|
return makeDiagnostic(ErrorCode.UNUSED_STANDALONE_IMPORTS, propertyAssignment.name, "All imports are unused", void 0, category);
|
|
3735
3851
|
}
|
|
@@ -3773,8 +3889,8 @@ var UnusedStandaloneImportsRule = class {
|
|
|
3773
3889
|
}
|
|
3774
3890
|
let current = reference.getIdentityIn(rawImports.getSourceFile());
|
|
3775
3891
|
while (current !== null) {
|
|
3776
|
-
if (
|
|
3777
|
-
return !!current.modifiers?.some((m) => m.kind ===
|
|
3892
|
+
if (ts25.isVariableStatement(current)) {
|
|
3893
|
+
return !!current.modifiers?.some((m) => m.kind === ts25.SyntaxKind.ExportKeyword);
|
|
3778
3894
|
}
|
|
3779
3895
|
current = current.parent ?? null;
|
|
3780
3896
|
}
|
|
@@ -3794,7 +3910,7 @@ function closestNode(start, predicate) {
|
|
|
3794
3910
|
}
|
|
3795
3911
|
|
|
3796
3912
|
// packages/compiler-cli/src/ngtsc/validation/src/rules/forbidden_required_initializer_invocation_rule.js
|
|
3797
|
-
import
|
|
3913
|
+
import ts26 from "typescript";
|
|
3798
3914
|
var APIS_TO_CHECK2 = [
|
|
3799
3915
|
INPUT_INITIALIZER_FN,
|
|
3800
3916
|
MODEL_INITIALIZER_FN,
|
|
@@ -3813,12 +3929,12 @@ var ForbiddenRequiredInitializersInvocationRule = class {
|
|
|
3813
3929
|
});
|
|
3814
3930
|
}
|
|
3815
3931
|
checkNode(node) {
|
|
3816
|
-
if (!
|
|
3932
|
+
if (!ts26.isClassDeclaration(node))
|
|
3817
3933
|
return null;
|
|
3818
|
-
const requiredInitializerDeclarations = node.members.filter((m) =>
|
|
3934
|
+
const requiredInitializerDeclarations = node.members.filter((m) => ts26.isPropertyDeclaration(m) && this.isPropDeclarationARequiredInitializer(m));
|
|
3819
3935
|
const diagnostics = [];
|
|
3820
3936
|
for (let decl of node.members) {
|
|
3821
|
-
if (!
|
|
3937
|
+
if (!ts26.isPropertyDeclaration(decl))
|
|
3822
3938
|
continue;
|
|
3823
3939
|
const initiallizerExpr = decl.initializer;
|
|
3824
3940
|
if (!initiallizerExpr)
|
|
@@ -3826,10 +3942,10 @@ var ForbiddenRequiredInitializersInvocationRule = class {
|
|
|
3826
3942
|
checkForbiddenInvocation(initiallizerExpr);
|
|
3827
3943
|
}
|
|
3828
3944
|
function checkForbiddenInvocation(node2) {
|
|
3829
|
-
if (
|
|
3945
|
+
if (ts26.isArrowFunction(node2) || ts26.isFunctionExpression(node2))
|
|
3830
3946
|
return;
|
|
3831
|
-
if (
|
|
3832
|
-
|
|
3947
|
+
if (ts26.isPropertyAccessExpression(node2) && node2.expression.kind === ts26.SyntaxKind.ThisKeyword && // With the following we make sure we only flag invoked required initializers
|
|
3948
|
+
ts26.isCallExpression(node2.parent) && node2.parent.expression === node2) {
|
|
3833
3949
|
const requiredProp = requiredInitializerDeclarations.find((prop) => prop.name.getText() === node2.name.getText());
|
|
3834
3950
|
if (requiredProp) {
|
|
3835
3951
|
const initializerFn = requiredProp.initializer.expression.expression.getText();
|
|
@@ -3854,7 +3970,7 @@ var ForbiddenRequiredInitializersInvocationRule = class {
|
|
|
3854
3970
|
}
|
|
3855
3971
|
};
|
|
3856
3972
|
function getConstructorFromClass(node) {
|
|
3857
|
-
return node.members.find((m) =>
|
|
3973
|
+
return node.members.find((m) => ts26.isConstructorDeclaration(m) && m.body !== void 0);
|
|
3858
3974
|
}
|
|
3859
3975
|
|
|
3860
3976
|
// packages/compiler-cli/src/ngtsc/validation/src/source_file_validator.js
|
|
@@ -4063,7 +4179,7 @@ var NgCompiler = class _NgCompiler {
|
|
|
4063
4179
|
this.currentProgram = inputProgram;
|
|
4064
4180
|
this.closureCompilerEnabled = !!this.options.annotateForClosureCompiler;
|
|
4065
4181
|
this.entryPoint = adapter.entryPoint !== null ? getSourceFileOrNull(inputProgram, adapter.entryPoint) : null;
|
|
4066
|
-
const moduleResolutionCache =
|
|
4182
|
+
const moduleResolutionCache = ts27.createModuleResolutionCache(
|
|
4067
4183
|
this.adapter.getCurrentDirectory(),
|
|
4068
4184
|
// doen't retain a reference to `this`, if other closures in the constructor here reference
|
|
4069
4185
|
// `this` internally then a closure created here would retain them. This can cause major
|
|
@@ -4111,7 +4227,7 @@ var NgCompiler = class _NgCompiler {
|
|
|
4111
4227
|
}
|
|
4112
4228
|
for (const clazz of classesToUpdate) {
|
|
4113
4229
|
this.compilation.traitCompiler.updateResources(clazz);
|
|
4114
|
-
if (!
|
|
4230
|
+
if (!ts27.isClassDeclaration(clazz)) {
|
|
4115
4231
|
continue;
|
|
4116
4232
|
}
|
|
4117
4233
|
this.compilation.templateTypeChecker.invalidateClass(clazz);
|
|
@@ -4321,12 +4437,12 @@ var NgCompiler = class _NgCompiler {
|
|
|
4321
4437
|
if (compilation.supportJitMode && compilation.jitDeclarationRegistry.jitDeclarations.size > 0) {
|
|
4322
4438
|
const { jitDeclarations } = compilation.jitDeclarationRegistry;
|
|
4323
4439
|
const jitDeclarationsArray = Array.from(jitDeclarations);
|
|
4324
|
-
const jitDeclarationOriginalNodes = new Set(jitDeclarationsArray.map((d) =>
|
|
4440
|
+
const jitDeclarationOriginalNodes = new Set(jitDeclarationsArray.map((d) => ts27.getOriginalNode(d)));
|
|
4325
4441
|
const sourceFilesWithJit = new Set(jitDeclarationsArray.map((d) => d.getSourceFile().fileName));
|
|
4326
4442
|
before.push((ctx) => {
|
|
4327
4443
|
const reflectionHost = new TypeScriptReflectionHost(this.inputProgram.getTypeChecker());
|
|
4328
4444
|
const jitTransform = angularJitApplicationTransform(this.inputProgram, compilation.isCore, (node) => {
|
|
4329
|
-
node =
|
|
4445
|
+
node = ts27.getOriginalNode(node, ts27.isClassDeclaration);
|
|
4330
4446
|
return reflectionHost.isClass(node) && jitDeclarationOriginalNodes.has(node);
|
|
4331
4447
|
})(ctx);
|
|
4332
4448
|
return (sourceFile) => {
|
|
@@ -4405,16 +4521,16 @@ var NgCompiler = class _NgCompiler {
|
|
|
4405
4521
|
return null;
|
|
4406
4522
|
}
|
|
4407
4523
|
const sourceFile = node.getSourceFile();
|
|
4408
|
-
const printer =
|
|
4409
|
-
const nodeText = printer.printNode(
|
|
4410
|
-
return
|
|
4524
|
+
const printer = ts27.createPrinter();
|
|
4525
|
+
const nodeText = printer.printNode(ts27.EmitHint.Unspecified, callback, sourceFile);
|
|
4526
|
+
return ts27.transpileModule(nodeText, {
|
|
4411
4527
|
compilerOptions: {
|
|
4412
4528
|
...this.options,
|
|
4413
4529
|
// Some module types can produce additional code (see #60795) whereas we need the
|
|
4414
4530
|
// HMR update module to use a native `export`. Override the `target` and `module`
|
|
4415
4531
|
// to ensure that it looks as expected.
|
|
4416
|
-
module:
|
|
4417
|
-
target:
|
|
4532
|
+
module: ts27.ModuleKind.ES2022,
|
|
4533
|
+
target: ts27.ScriptTarget.ES2022
|
|
4418
4534
|
},
|
|
4419
4535
|
fileName: sourceFile.fileName,
|
|
4420
4536
|
reportDiagnostics: false
|
|
@@ -4790,18 +4906,18 @@ function isAngularCorePackage(program) {
|
|
|
4790
4906
|
return false;
|
|
4791
4907
|
}
|
|
4792
4908
|
return r3Symbols.statements.some((stmt) => {
|
|
4793
|
-
if (!
|
|
4909
|
+
if (!ts27.isVariableStatement(stmt)) {
|
|
4794
4910
|
return false;
|
|
4795
4911
|
}
|
|
4796
|
-
const modifiers =
|
|
4797
|
-
if (modifiers === void 0 || !modifiers.some((mod) => mod.kind ===
|
|
4912
|
+
const modifiers = ts27.getModifiers(stmt);
|
|
4913
|
+
if (modifiers === void 0 || !modifiers.some((mod) => mod.kind === ts27.SyntaxKind.ExportKeyword)) {
|
|
4798
4914
|
return false;
|
|
4799
4915
|
}
|
|
4800
4916
|
return stmt.declarationList.declarations.some((decl) => {
|
|
4801
|
-
if (!
|
|
4917
|
+
if (!ts27.isIdentifier(decl.name) || decl.name.text !== "ITS_JUST_ANGULAR") {
|
|
4802
4918
|
return false;
|
|
4803
4919
|
}
|
|
4804
|
-
if (decl.initializer === void 0 || decl.initializer.kind !==
|
|
4920
|
+
if (decl.initializer === void 0 || decl.initializer.kind !== ts27.SyntaxKind.TrueKeyword) {
|
|
4805
4921
|
return false;
|
|
4806
4922
|
}
|
|
4807
4923
|
return true;
|
|
@@ -4814,7 +4930,7 @@ function getR3SymbolsFile(program) {
|
|
|
4814
4930
|
function* verifyCompatibleTypeCheckOptions(options) {
|
|
4815
4931
|
if (options.fullTemplateTypeCheck === false && options.strictTemplates === true) {
|
|
4816
4932
|
yield makeConfigDiagnostic({
|
|
4817
|
-
category:
|
|
4933
|
+
category: ts27.DiagnosticCategory.Error,
|
|
4818
4934
|
code: ErrorCode.CONFIG_STRICT_TEMPLATES_IMPLIES_FULL_TEMPLATE_TYPECHECK,
|
|
4819
4935
|
messageText: `
|
|
4820
4936
|
Angular compiler option "strictTemplates" is enabled, however "fullTemplateTypeCheck" is disabled.
|
|
@@ -4833,7 +4949,7 @@ https://angular.dev/tools/cli/template-typecheck
|
|
|
4833
4949
|
}
|
|
4834
4950
|
if (options.extendedDiagnostics && options.strictTemplates === false) {
|
|
4835
4951
|
yield makeConfigDiagnostic({
|
|
4836
|
-
category:
|
|
4952
|
+
category: ts27.DiagnosticCategory.Error,
|
|
4837
4953
|
code: ErrorCode.CONFIG_EXTENDED_DIAGNOSTICS_IMPLIES_STRICT_TEMPLATES,
|
|
4838
4954
|
messageText: `
|
|
4839
4955
|
Angular compiler option "extendedDiagnostics" is configured, however "strictTemplates" is disabled.
|
|
@@ -4850,7 +4966,7 @@ One of the following actions is required:
|
|
|
4850
4966
|
const defaultCategory = options.extendedDiagnostics?.defaultCategory;
|
|
4851
4967
|
if (defaultCategory && !allowedCategoryLabels.includes(defaultCategory)) {
|
|
4852
4968
|
yield makeConfigDiagnostic({
|
|
4853
|
-
category:
|
|
4969
|
+
category: ts27.DiagnosticCategory.Error,
|
|
4854
4970
|
code: ErrorCode.CONFIG_EXTENDED_DIAGNOSTICS_UNKNOWN_CATEGORY_LABEL,
|
|
4855
4971
|
messageText: `
|
|
4856
4972
|
Angular compiler option "extendedDiagnostics.defaultCategory" has an unknown diagnostic category: "${defaultCategory}".
|
|
@@ -4863,7 +4979,7 @@ ${allowedCategoryLabels.join("\n")}
|
|
|
4863
4979
|
for (const [checkName, category] of Object.entries(options.extendedDiagnostics?.checks ?? {})) {
|
|
4864
4980
|
if (!SUPPORTED_DIAGNOSTIC_NAMES.has(checkName)) {
|
|
4865
4981
|
yield makeConfigDiagnostic({
|
|
4866
|
-
category:
|
|
4982
|
+
category: ts27.DiagnosticCategory.Error,
|
|
4867
4983
|
code: ErrorCode.CONFIG_EXTENDED_DIAGNOSTICS_UNKNOWN_CHECK,
|
|
4868
4984
|
messageText: `
|
|
4869
4985
|
Angular compiler option "extendedDiagnostics.checks" has an unknown check: "${checkName}".
|
|
@@ -4875,7 +4991,7 @@ ${Array.from(SUPPORTED_DIAGNOSTIC_NAMES).join("\n")}
|
|
|
4875
4991
|
}
|
|
4876
4992
|
if (!allowedCategoryLabels.includes(category)) {
|
|
4877
4993
|
yield makeConfigDiagnostic({
|
|
4878
|
-
category:
|
|
4994
|
+
category: ts27.DiagnosticCategory.Error,
|
|
4879
4995
|
code: ErrorCode.CONFIG_EXTENDED_DIAGNOSTICS_UNKNOWN_CATEGORY_LABEL,
|
|
4880
4996
|
messageText: `
|
|
4881
4997
|
Angular compiler option "extendedDiagnostics.checks['${checkName}']" has an unknown diagnostic category: "${category}".
|
|
@@ -4893,7 +5009,7 @@ function verifyEmitDeclarationOnly(options) {
|
|
|
4893
5009
|
}
|
|
4894
5010
|
return [
|
|
4895
5011
|
makeConfigDiagnostic({
|
|
4896
|
-
category:
|
|
5012
|
+
category: ts27.DiagnosticCategory.Error,
|
|
4897
5013
|
code: ErrorCode.CONFIG_EMIT_DECLARATION_ONLY_UNSUPPORTED,
|
|
4898
5014
|
messageText: 'TS compiler option "emitDeclarationOnly" is not supported.'
|
|
4899
5015
|
})
|
|
@@ -4918,7 +5034,7 @@ var ReferenceGraphAdapter = class {
|
|
|
4918
5034
|
for (const { node } of references) {
|
|
4919
5035
|
let sourceFile = node.getSourceFile();
|
|
4920
5036
|
if (sourceFile === void 0) {
|
|
4921
|
-
sourceFile =
|
|
5037
|
+
sourceFile = ts27.getOriginalNode(node).getSourceFile();
|
|
4922
5038
|
}
|
|
4923
5039
|
if (sourceFile === void 0 || !isDtsPath(sourceFile.fileName)) {
|
|
4924
5040
|
this.graph.add(source, node);
|
|
@@ -4959,7 +5075,7 @@ function versionMapFromProgram(program, driver) {
|
|
|
4959
5075
|
}
|
|
4960
5076
|
|
|
4961
5077
|
// packages/compiler-cli/src/ngtsc/core/src/host.js
|
|
4962
|
-
import
|
|
5078
|
+
import ts28 from "typescript";
|
|
4963
5079
|
var DelegatingCompilerHost = class {
|
|
4964
5080
|
delegate;
|
|
4965
5081
|
createHash;
|
|
@@ -5098,7 +5214,7 @@ var NgCompilerHost = class _NgCompilerHost extends DelegatingCompilerHost {
|
|
|
5098
5214
|
entryPoint = findFlatIndexEntryPoint(normalizedTsInputFiles);
|
|
5099
5215
|
if (entryPoint === null) {
|
|
5100
5216
|
diagnostics.push({
|
|
5101
|
-
category:
|
|
5217
|
+
category: ts28.DiagnosticCategory.Error,
|
|
5102
5218
|
code: ngErrorCode(ErrorCode.CONFIG_FLAT_MODULE_NO_INDEX),
|
|
5103
5219
|
file: void 0,
|
|
5104
5220
|
start: void 0,
|
|
@@ -5152,10 +5268,10 @@ var NgCompilerHost = class _NgCompilerHost extends DelegatingCompilerHost {
|
|
|
5152
5268
|
return this.fileNameToModuleName !== void 0 ? this : null;
|
|
5153
5269
|
}
|
|
5154
5270
|
createCachedResolveModuleNamesFunction() {
|
|
5155
|
-
const moduleResolutionCache =
|
|
5271
|
+
const moduleResolutionCache = ts28.createModuleResolutionCache(this.getCurrentDirectory(), this.getCanonicalFileName.bind(this));
|
|
5156
5272
|
return (moduleNames, containingFile, reusedNames, redirectedReference, options) => {
|
|
5157
5273
|
return moduleNames.map((moduleName) => {
|
|
5158
|
-
const module =
|
|
5274
|
+
const module = ts28.resolveModuleName(moduleName, containingFile, options, this, moduleResolutionCache, redirectedReference);
|
|
5159
5275
|
return module.resolvedModule;
|
|
5160
5276
|
});
|
|
5161
5277
|
};
|