@angular/compiler-cli 21.0.0-next.0 → 21.0.0-next.10
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-5Y5LZ46S.js → chunk-3CWKYDQ7.js} +16979 -16238
- package/bundles/{chunk-BPDNYZBC.js → chunk-DT6FD4OE.js} +3 -17
- package/bundles/{chunk-L4DVGWMZ.js → chunk-HSIRUBJU.js} +1 -1
- package/bundles/{chunk-I2BHWRAU.js → chunk-LS5RJ5CS.js} +3 -0
- package/bundles/chunk-ZOLVJRLX.js +644 -0
- package/bundles/{chunk-UGSARQ4S.js → chunk-ZOZ6XVF3.js} +436 -839
- package/bundles/index.js +19 -19
- package/bundles/linker/babel/index.js +5 -2
- package/bundles/linker/index.js +2 -2
- package/bundles/private/migrations.js +50 -6
- package/bundles/private/testing.js +526 -0
- package/bundles/private/tooling.js +2 -3
- package/bundles/src/bin/ng_xi18n.js +5 -5
- package/bundles/src/bin/ngc.js +5 -5
- package/index.d.ts +1 -1
- package/linker/babel/src/ast/babel_ast_factory.d.ts +1 -0
- package/linker/src/file_linker/partial_linkers/util.d.ts +1 -1
- package/package.json +7 -15
- package/private/migrations.d.ts +11 -5
- package/private/testing.d.ts +11 -0
- package/src/ngtsc/annotations/common/src/metadata.d.ts +5 -3
- package/src/ngtsc/annotations/component/src/handler.d.ts +1 -0
- package/src/ngtsc/annotations/component/src/metadata.d.ts +5 -4
- package/src/ngtsc/annotations/component/src/resources.d.ts +1 -2
- package/src/ngtsc/annotations/directive/src/handler.d.ts +1 -0
- package/src/ngtsc/annotations/directive/src/shared.d.ts +6 -1
- package/src/ngtsc/annotations/index.d.ts +3 -2
- package/src/ngtsc/core/index.d.ts +1 -0
- package/src/ngtsc/diagnostics/src/error_code.d.ts +26 -0
- package/src/ngtsc/diagnostics/src/error_details_base_url.d.ts +1 -1
- package/src/ngtsc/diagnostics/src/extended_template_diagnostic_name.d.ts +2 -1
- package/src/ngtsc/docs/src/class_extractor.d.ts +4 -5
- package/src/ngtsc/docs/src/entities.d.ts +7 -2
- package/src/ngtsc/docs/src/interface_extractor.d.ts +11 -0
- package/src/ngtsc/docs/src/properties_extractor.d.ts +96 -0
- package/src/ngtsc/file_system/testing/index.d.ts +12 -0
- package/src/ngtsc/file_system/testing/src/mock_file_system.d.ts +71 -0
- package/src/ngtsc/file_system/testing/src/mock_file_system_native.d.ts +15 -0
- package/src/ngtsc/file_system/testing/src/mock_file_system_posix.d.ts +12 -0
- package/src/ngtsc/file_system/testing/src/mock_file_system_windows.d.ts +12 -0
- package/src/ngtsc/file_system/testing/src/test_helper.d.ts +16 -0
- package/src/ngtsc/translator/src/api/ast_factory.d.ts +7 -0
- package/src/ngtsc/translator/src/translator.d.ts +1 -0
- package/src/ngtsc/translator/src/typescript_ast_factory.d.ts +1 -0
- package/src/ngtsc/typecheck/api/checker.d.ts +4 -0
- package/src/ngtsc/typecheck/extended/api/api.d.ts +0 -10
- package/src/ngtsc/typecheck/extended/checks/defer_trigger_misconfiguration/index.d.ts +10 -0
- package/src/ngtsc/typecheck/src/checker.d.ts +1 -0
- package/src/ngtsc/validation/src/rules/forbidden_required_initializer_invocation_rule.d.ts +22 -0
- package/src/ngtsc/xi18n/src/context.d.ts +1 -2
- package/bundles/chunk-N3VWF7MH.js +0 -548
|
@@ -2,9 +2,6 @@
|
|
|
2
2
|
import {createRequire as __cjsCompatRequire} from 'module';
|
|
3
3
|
const require = __cjsCompatRequire(import.meta.url);
|
|
4
4
|
|
|
5
|
-
import {
|
|
6
|
-
angularJitApplicationTransform
|
|
7
|
-
} from "./chunk-N3VWF7MH.js";
|
|
8
5
|
import {
|
|
9
6
|
AbsoluteModuleStrategy,
|
|
10
7
|
ActivePerfRecorder,
|
|
@@ -66,13 +63,13 @@ import {
|
|
|
66
63
|
SymbolKind,
|
|
67
64
|
TemplateTypeCheckerImpl,
|
|
68
65
|
TraitCompiler,
|
|
69
|
-
TsCreateProgramDriver,
|
|
70
66
|
TypeCheckScopeRegistry,
|
|
71
67
|
TypeCheckShimGenerator,
|
|
72
68
|
TypeScriptReflectionHost,
|
|
73
69
|
UnifiedModulesAliasingHost,
|
|
74
70
|
UnifiedModulesStrategy,
|
|
75
71
|
aliasTransformFactory,
|
|
72
|
+
angularJitApplicationTransform,
|
|
76
73
|
declarationTransformFactory,
|
|
77
74
|
getRootDirs,
|
|
78
75
|
getSourceFileOrNull,
|
|
@@ -86,52 +83,20 @@ import {
|
|
|
86
83
|
ngErrorCode,
|
|
87
84
|
normalizeSeparators,
|
|
88
85
|
relativePathBetween,
|
|
89
|
-
replaceTsWithNgInErrors,
|
|
90
|
-
retagAllTsFiles,
|
|
91
86
|
signalMetadataTransform,
|
|
92
87
|
toUnredirectedSourceFile,
|
|
93
88
|
tryParseInitializerApi,
|
|
94
89
|
untagAllTsFiles
|
|
95
|
-
} from "./chunk-
|
|
90
|
+
} from "./chunk-3CWKYDQ7.js";
|
|
96
91
|
import {
|
|
97
92
|
LogicalFileSystem,
|
|
98
|
-
absoluteFrom,
|
|
99
93
|
absoluteFromSourceFile,
|
|
100
|
-
createFileSystemTsReadDirectoryFn,
|
|
101
94
|
dirname,
|
|
102
95
|
getFileSystem,
|
|
103
96
|
join,
|
|
104
97
|
resolve
|
|
105
98
|
} from "./chunk-GWZQLAGK.js";
|
|
106
99
|
|
|
107
|
-
// packages/compiler-cli/src/transformers/api.js
|
|
108
|
-
var DEFAULT_ERROR_CODE = 100;
|
|
109
|
-
var UNKNOWN_ERROR_CODE = 500;
|
|
110
|
-
var SOURCE = "angular";
|
|
111
|
-
function isTsDiagnostic(diagnostic) {
|
|
112
|
-
return diagnostic != null && diagnostic.source !== "angular";
|
|
113
|
-
}
|
|
114
|
-
var EmitFlags;
|
|
115
|
-
(function(EmitFlags2) {
|
|
116
|
-
EmitFlags2[EmitFlags2["DTS"] = 1] = "DTS";
|
|
117
|
-
EmitFlags2[EmitFlags2["JS"] = 2] = "JS";
|
|
118
|
-
EmitFlags2[EmitFlags2["Metadata"] = 4] = "Metadata";
|
|
119
|
-
EmitFlags2[EmitFlags2["I18nBundle"] = 8] = "I18nBundle";
|
|
120
|
-
EmitFlags2[EmitFlags2["Codegen"] = 16] = "Codegen";
|
|
121
|
-
EmitFlags2[EmitFlags2["Default"] = 19] = "Default";
|
|
122
|
-
EmitFlags2[EmitFlags2["All"] = 31] = "All";
|
|
123
|
-
})(EmitFlags || (EmitFlags = {}));
|
|
124
|
-
|
|
125
|
-
// packages/compiler-cli/src/transformers/compiler_host.js
|
|
126
|
-
import ts from "typescript";
|
|
127
|
-
var wrapHostForTest = null;
|
|
128
|
-
function createCompilerHost({ options, tsHost = ts.createCompilerHost(options, true) }) {
|
|
129
|
-
if (wrapHostForTest !== null) {
|
|
130
|
-
tsHost = wrapHostForTest(tsHost);
|
|
131
|
-
}
|
|
132
|
-
return tsHost;
|
|
133
|
-
}
|
|
134
|
-
|
|
135
100
|
// packages/compiler-cli/src/ngtsc/docs/src/entities.js
|
|
136
101
|
var EntryType;
|
|
137
102
|
(function(EntryType2) {
|
|
@@ -180,62 +145,44 @@ function isDocEntryWithSourceInfo(entry) {
|
|
|
180
145
|
}
|
|
181
146
|
|
|
182
147
|
// packages/compiler-cli/src/ngtsc/docs/src/extractor.js
|
|
183
|
-
import
|
|
148
|
+
import ts13 from "typescript";
|
|
184
149
|
|
|
185
150
|
// packages/compiler-cli/src/ngtsc/docs/src/class_extractor.js
|
|
186
151
|
import ts6 from "typescript";
|
|
187
152
|
|
|
188
|
-
// packages/compiler-cli/src/ngtsc/docs/src/filters.js
|
|
189
|
-
function isAngularPrivateName(name) {
|
|
190
|
-
const firstChar = name[0] ?? "";
|
|
191
|
-
return firstChar === "\u0275" || firstChar === "_";
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
// packages/compiler-cli/src/ngtsc/docs/src/function_extractor.js
|
|
195
|
-
import ts4 from "typescript";
|
|
196
|
-
|
|
197
|
-
// packages/compiler-cli/src/ngtsc/docs/src/generics_extractor.js
|
|
198
|
-
function extractGenerics(declaration) {
|
|
199
|
-
return declaration.typeParameters?.map((typeParam) => ({
|
|
200
|
-
name: typeParam.name.getText(),
|
|
201
|
-
constraint: typeParam.constraint?.getText(),
|
|
202
|
-
default: typeParam.default?.getText()
|
|
203
|
-
})) ?? [];
|
|
204
|
-
}
|
|
205
|
-
|
|
206
153
|
// packages/compiler-cli/src/ngtsc/docs/src/jsdoc_extractor.js
|
|
207
|
-
import
|
|
154
|
+
import ts from "typescript";
|
|
208
155
|
var decoratorExpression = /@(?=(Injectable|Component|Directive|Pipe|NgModule|Input|Output|HostBinding|HostListener|Inject|Optional|Self|Host|SkipSelf|ViewChild|ViewChildren|ContentChild|ContentChildren))/g;
|
|
209
156
|
function extractJsDocTags(node) {
|
|
210
157
|
const escapedNode = getEscapedNode(node);
|
|
211
|
-
return
|
|
158
|
+
return ts.getJSDocTags(escapedNode).map((t) => {
|
|
212
159
|
return {
|
|
213
160
|
name: t.tagName.getText(),
|
|
214
|
-
comment: unescapeAngularDecorators(
|
|
161
|
+
comment: unescapeAngularDecorators(ts.getTextOfJSDocComment(t.comment) ?? "")
|
|
215
162
|
};
|
|
216
163
|
});
|
|
217
164
|
}
|
|
218
165
|
function extractJsDocDescription(node) {
|
|
219
166
|
const escapedNode = getEscapedNode(node);
|
|
220
|
-
const commentOrTag =
|
|
221
|
-
return
|
|
167
|
+
const commentOrTag = ts.getJSDocCommentsAndTags(escapedNode).find((d) => {
|
|
168
|
+
return ts.isJSDoc(d) || ts.isJSDocParameterTag(d);
|
|
222
169
|
});
|
|
223
170
|
const comment = commentOrTag?.comment ?? "";
|
|
224
|
-
const description = typeof comment === "string" ? comment :
|
|
171
|
+
const description = typeof comment === "string" ? comment : ts.getTextOfJSDocComment(comment) ?? "";
|
|
225
172
|
return unescapeAngularDecorators(description);
|
|
226
173
|
}
|
|
227
174
|
function extractRawJsDoc(node) {
|
|
228
|
-
const comment =
|
|
175
|
+
const comment = ts.getJSDocCommentsAndTags(node).find(ts.isJSDoc)?.getFullText() ?? "";
|
|
229
176
|
return unescapeAngularDecorators(comment);
|
|
230
177
|
}
|
|
231
178
|
function getEscapedNode(node) {
|
|
232
|
-
if (
|
|
179
|
+
if (ts.isParameter(node)) {
|
|
233
180
|
return node;
|
|
234
181
|
}
|
|
235
182
|
const rawComment = extractRawJsDoc(node);
|
|
236
183
|
const escaped = escapeAngularDecorators(rawComment);
|
|
237
|
-
const file =
|
|
238
|
-
return file.statements.find((s) =>
|
|
184
|
+
const file = ts.createSourceFile("x.ts", `${escaped}class X {}`, ts.ScriptTarget.ES2020, true);
|
|
185
|
+
return file.statements.find((s) => ts.isClassDeclaration(s));
|
|
239
186
|
}
|
|
240
187
|
function escapeAngularDecorators(comment) {
|
|
241
188
|
return comment.replace(decoratorExpression, "_NG_AT_");
|
|
@@ -244,10 +191,31 @@ function unescapeAngularDecorators(comment) {
|
|
|
244
191
|
return comment.replace(/_NG_AT_/g, "@");
|
|
245
192
|
}
|
|
246
193
|
|
|
247
|
-
// packages/compiler-cli/src/ngtsc/docs/src/
|
|
194
|
+
// packages/compiler-cli/src/ngtsc/docs/src/properties_extractor.js
|
|
195
|
+
import ts5 from "typescript";
|
|
196
|
+
|
|
197
|
+
// packages/compiler-cli/src/ngtsc/docs/src/filters.js
|
|
198
|
+
function isAngularPrivateName(name) {
|
|
199
|
+
const firstChar = name[0] ?? "";
|
|
200
|
+
return firstChar === "\u0275" || firstChar === "_";
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
// packages/compiler-cli/src/ngtsc/docs/src/function_extractor.js
|
|
248
204
|
import ts3 from "typescript";
|
|
205
|
+
|
|
206
|
+
// packages/compiler-cli/src/ngtsc/docs/src/generics_extractor.js
|
|
207
|
+
function extractGenerics(declaration) {
|
|
208
|
+
return declaration.typeParameters?.map((typeParam) => ({
|
|
209
|
+
name: typeParam.name.getText(),
|
|
210
|
+
constraint: typeParam.constraint?.getText(),
|
|
211
|
+
default: typeParam.default?.getText()
|
|
212
|
+
})) ?? [];
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
// packages/compiler-cli/src/ngtsc/docs/src/type_extractor.js
|
|
216
|
+
import ts2 from "typescript";
|
|
249
217
|
function extractResolvedTypeString(node, checker) {
|
|
250
|
-
return checker.typeToString(checker.getTypeAtLocation(node), void 0,
|
|
218
|
+
return checker.typeToString(checker.getTypeAtLocation(node), void 0, ts2.TypeFormatFlags.NoTruncation);
|
|
251
219
|
}
|
|
252
220
|
|
|
253
221
|
// packages/compiler-cli/src/ngtsc/docs/src/function_extractor.js
|
|
@@ -265,7 +233,7 @@ var FunctionExtractor = class {
|
|
|
265
233
|
const returnType = signature ? extractReturnType(signature, this.typeChecker) : "unknown";
|
|
266
234
|
const implementation = findImplementationOfFunction(this.exportDeclaration, this.typeChecker) ?? this.exportDeclaration;
|
|
267
235
|
const type = this.typeChecker.getTypeAtLocation(this.exportDeclaration);
|
|
268
|
-
const overloads =
|
|
236
|
+
const overloads = ts3.isConstructorDeclaration(this.exportDeclaration) ? constructorOverloads(this.exportDeclaration, this.typeChecker) : extractCallSignatures(this.name, this.typeChecker, type);
|
|
269
237
|
const jsdocsTags = extractJsDocTags(implementation);
|
|
270
238
|
const description = extractJsDocDescription(implementation);
|
|
271
239
|
return {
|
|
@@ -273,7 +241,7 @@ var FunctionExtractor = class {
|
|
|
273
241
|
signatures: overloads,
|
|
274
242
|
implementation: {
|
|
275
243
|
params: extractAllParams(implementation.parameters, this.typeChecker),
|
|
276
|
-
isNewType:
|
|
244
|
+
isNewType: ts3.isConstructSignatureDeclaration(implementation),
|
|
277
245
|
returnType,
|
|
278
246
|
returnDescription: jsdocsTags.find((tag) => tag.name === "returns")?.comment,
|
|
279
247
|
generics: extractGenerics(implementation),
|
|
@@ -293,7 +261,7 @@ var FunctionExtractor = class {
|
|
|
293
261
|
function constructorOverloads(constructorDeclaration, typeChecker) {
|
|
294
262
|
const classDeclaration = constructorDeclaration.parent;
|
|
295
263
|
const constructorNode = classDeclaration.members.filter((member) => {
|
|
296
|
-
return
|
|
264
|
+
return ts3.isConstructorDeclaration(member) && !member.body;
|
|
297
265
|
});
|
|
298
266
|
return constructorNode.map((n) => {
|
|
299
267
|
return {
|
|
@@ -322,7 +290,7 @@ function filterSignatureDeclarations(signatures) {
|
|
|
322
290
|
const result = [];
|
|
323
291
|
for (const signature of signatures) {
|
|
324
292
|
const decl = signature.getDeclaration();
|
|
325
|
-
if (
|
|
293
|
+
if (ts3.isFunctionDeclaration(decl) || ts3.isCallSignatureDeclaration(decl) || ts3.isMethodDeclaration(decl) || ts3.isConstructSignatureDeclaration(decl)) {
|
|
326
294
|
result.push({ signature, decl });
|
|
327
295
|
}
|
|
328
296
|
}
|
|
@@ -342,14 +310,14 @@ function extractCallSignatures(name, typeChecker, type) {
|
|
|
342
310
|
}));
|
|
343
311
|
}
|
|
344
312
|
function extractReturnType(signature, typeChecker) {
|
|
345
|
-
if (signature?.declaration?.type &&
|
|
313
|
+
if (signature?.declaration?.type && ts3.isTypePredicateNode(signature.declaration.type)) {
|
|
346
314
|
return signature.declaration.type.getText();
|
|
347
315
|
}
|
|
348
316
|
return typeChecker.typeToString(
|
|
349
317
|
typeChecker.getReturnTypeOfSignature(signature),
|
|
350
318
|
void 0,
|
|
351
319
|
// This ensures that e.g. `T | undefined` is not reduced to `T`.
|
|
352
|
-
|
|
320
|
+
ts3.TypeFormatFlags.NoTypeReduction | ts3.TypeFormatFlags.NoTruncation
|
|
353
321
|
);
|
|
354
322
|
}
|
|
355
323
|
function findImplementationOfFunction(node, typeChecker) {
|
|
@@ -357,18 +325,18 @@ function findImplementationOfFunction(node, typeChecker) {
|
|
|
357
325
|
return node;
|
|
358
326
|
}
|
|
359
327
|
const symbol = typeChecker.getSymbolAtLocation(node.name);
|
|
360
|
-
const implementation = symbol?.declarations?.find((s) =>
|
|
328
|
+
const implementation = symbol?.declarations?.find((s) => ts3.isFunctionDeclaration(s) && s.body !== void 0);
|
|
361
329
|
return implementation;
|
|
362
330
|
}
|
|
363
331
|
|
|
364
332
|
// packages/compiler-cli/src/ngtsc/docs/src/internal.js
|
|
365
|
-
import
|
|
333
|
+
import ts4 from "typescript";
|
|
366
334
|
function isInternal(member) {
|
|
367
335
|
return extractJsDocTags(member).some((tag) => tag.name === "internal") || hasLeadingInternalComment(member);
|
|
368
336
|
}
|
|
369
337
|
function hasLeadingInternalComment(member) {
|
|
370
338
|
const memberText = member.getSourceFile().text;
|
|
371
|
-
return
|
|
339
|
+
return ts4.reduceEachLeadingCommentRange(
|
|
372
340
|
memberText,
|
|
373
341
|
member.getFullStart(),
|
|
374
342
|
(pos, end, kind, hasTrailingNewLine, containsInternal) => {
|
|
@@ -381,8 +349,8 @@ function hasLeadingInternalComment(member) {
|
|
|
381
349
|
) ?? false;
|
|
382
350
|
}
|
|
383
351
|
|
|
384
|
-
// packages/compiler-cli/src/ngtsc/docs/src/
|
|
385
|
-
var
|
|
352
|
+
// packages/compiler-cli/src/ngtsc/docs/src/properties_extractor.js
|
|
353
|
+
var PropertiesExtractor = class {
|
|
386
354
|
declaration;
|
|
387
355
|
typeChecker;
|
|
388
356
|
constructor(declaration, typeChecker) {
|
|
@@ -392,16 +360,8 @@ var ClassExtractor = class {
|
|
|
392
360
|
/** Extract docs info specific to classes. */
|
|
393
361
|
extract() {
|
|
394
362
|
return {
|
|
395
|
-
name: this.declaration.name.text,
|
|
396
|
-
isAbstract: this.isAbstract(),
|
|
397
|
-
entryType: ts6.isInterfaceDeclaration(this.declaration) ? EntryType.Interface : EntryType.UndecoratedClass,
|
|
398
363
|
members: this.extractSignatures().concat(this.extractAllClassMembers()),
|
|
399
|
-
generics: extractGenerics(this.declaration)
|
|
400
|
-
description: extractJsDocDescription(this.declaration),
|
|
401
|
-
jsdocTags: extractJsDocTags(this.declaration),
|
|
402
|
-
rawComment: extractRawJsDoc(this.declaration),
|
|
403
|
-
extends: this.extractInheritance(this.declaration),
|
|
404
|
-
implements: this.extractInterfaceConformance(this.declaration)
|
|
364
|
+
generics: extractGenerics(this.declaration)
|
|
405
365
|
};
|
|
406
366
|
}
|
|
407
367
|
/** Extracts doc info for a class's members. */
|
|
@@ -423,9 +383,9 @@ var ClassExtractor = class {
|
|
|
423
383
|
return this.extractMethod(memberDeclaration);
|
|
424
384
|
} else if (this.isProperty(memberDeclaration) && !this.hasPrivateComputedProperty(memberDeclaration)) {
|
|
425
385
|
return this.extractClassProperty(memberDeclaration);
|
|
426
|
-
} else if (
|
|
386
|
+
} else if (ts5.isAccessor(memberDeclaration)) {
|
|
427
387
|
return this.extractGetterSetter(memberDeclaration);
|
|
428
|
-
} else if (
|
|
388
|
+
} else if (ts5.isConstructorDeclaration(memberDeclaration) && memberDeclaration.parameters.length > 0) {
|
|
429
389
|
return this.extractConstructor(memberDeclaration);
|
|
430
390
|
}
|
|
431
391
|
return void 0;
|
|
@@ -445,7 +405,7 @@ var ClassExtractor = class {
|
|
|
445
405
|
}
|
|
446
406
|
/** Extracts docs for a signature element (usually inside an interface). */
|
|
447
407
|
extractSignature(signature) {
|
|
448
|
-
const functionExtractor = new FunctionExtractor(
|
|
408
|
+
const functionExtractor = new FunctionExtractor(ts5.isConstructSignatureDeclaration(signature) ? "new" : "", signature, this.typeChecker);
|
|
449
409
|
return {
|
|
450
410
|
...functionExtractor.extract(),
|
|
451
411
|
memberType: MemberType.Method,
|
|
@@ -467,7 +427,7 @@ var ClassExtractor = class {
|
|
|
467
427
|
extractGetterSetter(accessor) {
|
|
468
428
|
return {
|
|
469
429
|
...this.extractClassProperty(accessor),
|
|
470
|
-
memberType:
|
|
430
|
+
memberType: ts5.isGetAccessor(accessor) ? MemberType.Getter : MemberType.Setter
|
|
471
431
|
};
|
|
472
432
|
}
|
|
473
433
|
extractConstructor(constructorDeclaration) {
|
|
@@ -478,23 +438,8 @@ var ClassExtractor = class {
|
|
|
478
438
|
memberTags: this.getMemberTags(constructorDeclaration)
|
|
479
439
|
};
|
|
480
440
|
}
|
|
481
|
-
extractInheritance(declaration) {
|
|
482
|
-
if (!declaration.heritageClauses) {
|
|
483
|
-
return void 0;
|
|
484
|
-
}
|
|
485
|
-
for (const clause of declaration.heritageClauses) {
|
|
486
|
-
if (clause.token === ts6.SyntaxKind.ExtendsKeyword) {
|
|
487
|
-
const types = clause.types;
|
|
488
|
-
if (types.length > 0) {
|
|
489
|
-
const baseClass = types[0];
|
|
490
|
-
return baseClass.getText();
|
|
491
|
-
}
|
|
492
|
-
}
|
|
493
|
-
}
|
|
494
|
-
return void 0;
|
|
495
|
-
}
|
|
496
441
|
extractInterfaceConformance(declaration) {
|
|
497
|
-
const implementClause = declaration.heritageClauses?.find((clause) => clause.token ===
|
|
442
|
+
const implementClause = declaration.heritageClauses?.find((clause) => clause.token === ts5.SyntaxKind.ImplementsKeyword);
|
|
498
443
|
return implementClause?.types.map((m) => m.getText()) ?? [];
|
|
499
444
|
}
|
|
500
445
|
/** Gets the tags for a member (protected, readonly, static, etc.) */
|
|
@@ -525,7 +470,7 @@ var ClassExtractor = class {
|
|
|
525
470
|
getMemberDeclarations() {
|
|
526
471
|
const type = this.typeChecker.getTypeAtLocation(this.declaration);
|
|
527
472
|
const members = type.getProperties();
|
|
528
|
-
const constructor = type.getSymbol()?.members?.get(
|
|
473
|
+
const constructor = type.getSymbol()?.members?.get(ts5.InternalSymbolName.Constructor);
|
|
529
474
|
const typeOfConstructor = this.typeChecker.getTypeOfSymbol(type.symbol);
|
|
530
475
|
const staticMembers = typeOfConstructor.getProperties();
|
|
531
476
|
const result = [];
|
|
@@ -542,9 +487,9 @@ var ClassExtractor = class {
|
|
|
542
487
|
/** The result only contains properties, method implementations and abstracts */
|
|
543
488
|
filterMethodOverloads(declarations) {
|
|
544
489
|
return declarations.filter((declaration, index) => {
|
|
545
|
-
if (
|
|
490
|
+
if (ts5.isFunctionDeclaration(declaration) || ts5.isMethodDeclaration(declaration) || ts5.isConstructorDeclaration(declaration)) {
|
|
546
491
|
const nextDeclaration = declarations[index + 1];
|
|
547
|
-
const isNextMethodWithSameName = nextDeclaration && (
|
|
492
|
+
const isNextMethodWithSameName = nextDeclaration && (ts5.isMethodDeclaration(nextDeclaration) && nextDeclaration.name.getText() === declaration.name?.getText() || ts5.isConstructorDeclaration(nextDeclaration) && ts5.isConstructorDeclaration(declaration));
|
|
548
493
|
return !isNextMethodWithSameName;
|
|
549
494
|
}
|
|
550
495
|
return true;
|
|
@@ -563,13 +508,13 @@ var ClassExtractor = class {
|
|
|
563
508
|
/** Gets the doc tag corresponding to a class member modifier (readonly, protected, etc.). */
|
|
564
509
|
getTagForMemberModifier(mod) {
|
|
565
510
|
switch (mod.kind) {
|
|
566
|
-
case
|
|
511
|
+
case ts5.SyntaxKind.StaticKeyword:
|
|
567
512
|
return MemberTags.Static;
|
|
568
|
-
case
|
|
513
|
+
case ts5.SyntaxKind.ReadonlyKeyword:
|
|
569
514
|
return MemberTags.Readonly;
|
|
570
|
-
case
|
|
515
|
+
case ts5.SyntaxKind.ProtectedKeyword:
|
|
571
516
|
return MemberTags.Protected;
|
|
572
|
-
case
|
|
517
|
+
case ts5.SyntaxKind.AbstractKeyword:
|
|
573
518
|
return MemberTags.Abstract;
|
|
574
519
|
default:
|
|
575
520
|
return void 0;
|
|
@@ -585,39 +530,34 @@ var ClassExtractor = class {
|
|
|
585
530
|
* - The member is marked as internal via JSDoc.
|
|
586
531
|
*/
|
|
587
532
|
isMemberExcluded(member) {
|
|
588
|
-
if (
|
|
533
|
+
if (ts5.isConstructorDeclaration(member)) {
|
|
589
534
|
return false;
|
|
590
535
|
}
|
|
591
|
-
return !member.name || !this.isDocumentableMember(member) || !
|
|
536
|
+
return !member.name || !this.isDocumentableMember(member) || !ts5.isCallSignatureDeclaration(member) && member.modifiers?.some((mod) => mod.kind === ts5.SyntaxKind.PrivateKeyword) || member.name.getText() === "prototype" || isAngularPrivateName(member.name.getText()) || isInternal(member);
|
|
592
537
|
}
|
|
593
538
|
/** Gets whether a class member is a method, property, or accessor. */
|
|
594
539
|
isDocumentableMember(member) {
|
|
595
|
-
return this.isMethod(member) || this.isProperty(member) ||
|
|
596
|
-
|
|
540
|
+
return this.isMethod(member) || this.isProperty(member) || ts5.isAccessor(member) || ts5.isConstructorDeclaration(member) || // Signatures are documentable if they are part of an interface.
|
|
541
|
+
ts5.isCallSignatureDeclaration(member);
|
|
597
542
|
}
|
|
598
543
|
/** Check if the parameter is a constructor parameter with a public modifier */
|
|
599
544
|
isPublicConstructorParameterProperty(node) {
|
|
600
|
-
if (
|
|
601
|
-
return node.modifiers.some((modifier) => modifier.kind ===
|
|
545
|
+
if (ts5.isParameterPropertyDeclaration(node, node.parent) && node.modifiers) {
|
|
546
|
+
return node.modifiers.some((modifier) => modifier.kind === ts5.SyntaxKind.PublicKeyword);
|
|
602
547
|
}
|
|
603
548
|
return false;
|
|
604
549
|
}
|
|
605
550
|
/** Gets whether a member is a property. */
|
|
606
551
|
isProperty(member) {
|
|
607
|
-
return
|
|
552
|
+
return ts5.isPropertyDeclaration(member) || ts5.isPropertySignature(member) || this.isPublicConstructorParameterProperty(member);
|
|
608
553
|
}
|
|
609
554
|
/** Gets whether a member is a method. */
|
|
610
555
|
isMethod(member) {
|
|
611
|
-
return
|
|
556
|
+
return ts5.isMethodDeclaration(member) || ts5.isMethodSignature(member);
|
|
612
557
|
}
|
|
613
558
|
/** Gets whether the given signature declaration is documentable. */
|
|
614
559
|
isDocumentableSignature(signature) {
|
|
615
|
-
return
|
|
616
|
-
}
|
|
617
|
-
/** Gets whether the declaration for this extractor is abstract. */
|
|
618
|
-
isAbstract() {
|
|
619
|
-
const modifiers = this.declaration.modifiers ?? [];
|
|
620
|
-
return modifiers.some((mod) => mod.kind === ts6.SyntaxKind.AbstractKeyword);
|
|
560
|
+
return ts5.isConstructSignatureDeclaration(signature) || ts5.isCallSignatureDeclaration(signature);
|
|
621
561
|
}
|
|
622
562
|
/**
|
|
623
563
|
* Check wether a member has a private computed property name like [ɵWRITABLE_SIGNAL]
|
|
@@ -625,7 +565,48 @@ var ClassExtractor = class {
|
|
|
625
565
|
* This will prevent exposing private computed properties in the docs.
|
|
626
566
|
*/
|
|
627
567
|
hasPrivateComputedProperty(property) {
|
|
628
|
-
return
|
|
568
|
+
return ts5.isComputedPropertyName(property.name) && property.name.expression.getText().startsWith("\u0275");
|
|
569
|
+
}
|
|
570
|
+
};
|
|
571
|
+
|
|
572
|
+
// packages/compiler-cli/src/ngtsc/docs/src/class_extractor.js
|
|
573
|
+
var ClassExtractor = class extends PropertiesExtractor {
|
|
574
|
+
constructor(declaration, typeChecker) {
|
|
575
|
+
super(declaration, typeChecker);
|
|
576
|
+
}
|
|
577
|
+
/** Extract docs info specific to classes. */
|
|
578
|
+
extract() {
|
|
579
|
+
return {
|
|
580
|
+
name: this.declaration.name.text,
|
|
581
|
+
isAbstract: this.isAbstract(),
|
|
582
|
+
entryType: EntryType.UndecoratedClass,
|
|
583
|
+
...super.extract(),
|
|
584
|
+
description: extractJsDocDescription(this.declaration),
|
|
585
|
+
jsdocTags: extractJsDocTags(this.declaration),
|
|
586
|
+
rawComment: extractRawJsDoc(this.declaration),
|
|
587
|
+
extends: this.extractInheritance(this.declaration),
|
|
588
|
+
implements: this.extractInterfaceConformance(this.declaration)
|
|
589
|
+
};
|
|
590
|
+
}
|
|
591
|
+
/** Gets whether the declaration for this extractor is abstract. */
|
|
592
|
+
isAbstract() {
|
|
593
|
+
const modifiers = this.declaration.modifiers ?? [];
|
|
594
|
+
return modifiers.some((mod) => mod.kind === ts6.SyntaxKind.AbstractKeyword);
|
|
595
|
+
}
|
|
596
|
+
extractInheritance(declaration) {
|
|
597
|
+
if (!declaration.heritageClauses) {
|
|
598
|
+
return void 0;
|
|
599
|
+
}
|
|
600
|
+
for (const clause of declaration.heritageClauses) {
|
|
601
|
+
if (clause.token === ts6.SyntaxKind.ExtendsKeyword) {
|
|
602
|
+
const types = clause.types;
|
|
603
|
+
if (types.length > 0) {
|
|
604
|
+
const baseClass = types[0];
|
|
605
|
+
return baseClass.getText();
|
|
606
|
+
}
|
|
607
|
+
}
|
|
608
|
+
}
|
|
609
|
+
return void 0;
|
|
629
610
|
}
|
|
630
611
|
};
|
|
631
612
|
var DirectiveExtractor = class extends ClassExtractor {
|
|
@@ -724,10 +705,6 @@ function extractClass(classDeclaration, metadataReader, typeChecker) {
|
|
|
724
705
|
}
|
|
725
706
|
return extractor.extract();
|
|
726
707
|
}
|
|
727
|
-
function extractInterface(declaration, typeChecker) {
|
|
728
|
-
const extractor = new ClassExtractor(declaration, typeChecker);
|
|
729
|
-
return extractor.extract();
|
|
730
|
-
}
|
|
731
708
|
function extractPipeSyntax(metadata, classDeclaration) {
|
|
732
709
|
const transformParams = classDeclaration.members.find((member) => {
|
|
733
710
|
return ts6.isMethodDeclaration(member) && member.name && ts6.isIdentifier(member.name) && member.name.getText() === "transform";
|
|
@@ -797,7 +774,48 @@ function extractLiteralPropertiesAsEnumMembers(declaration) {
|
|
|
797
774
|
}
|
|
798
775
|
|
|
799
776
|
// packages/compiler-cli/src/ngtsc/docs/src/decorator_extractor.js
|
|
777
|
+
import ts9 from "typescript";
|
|
778
|
+
|
|
779
|
+
// packages/compiler-cli/src/ngtsc/docs/src/interface_extractor.js
|
|
800
780
|
import ts8 from "typescript";
|
|
781
|
+
var InterfaceExtractor = class extends PropertiesExtractor {
|
|
782
|
+
constructor(declaration, typeChecker) {
|
|
783
|
+
super(declaration, typeChecker);
|
|
784
|
+
}
|
|
785
|
+
/** Extract docs info specific to classes. */
|
|
786
|
+
extract() {
|
|
787
|
+
return {
|
|
788
|
+
name: this.declaration.name.text,
|
|
789
|
+
entryType: EntryType.Interface,
|
|
790
|
+
...super.extract(),
|
|
791
|
+
description: extractJsDocDescription(this.declaration),
|
|
792
|
+
jsdocTags: extractJsDocTags(this.declaration),
|
|
793
|
+
rawComment: extractRawJsDoc(this.declaration),
|
|
794
|
+
extends: this.extractInheritance(this.declaration),
|
|
795
|
+
implements: this.extractInterfaceConformance(this.declaration)
|
|
796
|
+
};
|
|
797
|
+
}
|
|
798
|
+
extractInheritance(declaration) {
|
|
799
|
+
if (!declaration.heritageClauses) {
|
|
800
|
+
return [];
|
|
801
|
+
}
|
|
802
|
+
for (const clause of declaration.heritageClauses) {
|
|
803
|
+
if (clause.token === ts8.SyntaxKind.ExtendsKeyword) {
|
|
804
|
+
const types = clause.types;
|
|
805
|
+
if (types.length > 0) {
|
|
806
|
+
return types.map((t) => t.getText());
|
|
807
|
+
}
|
|
808
|
+
}
|
|
809
|
+
}
|
|
810
|
+
return [];
|
|
811
|
+
}
|
|
812
|
+
};
|
|
813
|
+
function extractInterface(declaration, typeChecker) {
|
|
814
|
+
const extractor = new InterfaceExtractor(declaration, typeChecker);
|
|
815
|
+
return extractor.extract();
|
|
816
|
+
}
|
|
817
|
+
|
|
818
|
+
// packages/compiler-cli/src/ngtsc/docs/src/decorator_extractor.js
|
|
801
819
|
function extractorDecorator(declaration, typeChecker) {
|
|
802
820
|
const documentedNode = getDecoratorJsDocNode(declaration, typeChecker);
|
|
803
821
|
const decoratorType = getDecoratorType(declaration);
|
|
@@ -808,7 +826,7 @@ function extractorDecorator(declaration, typeChecker) {
|
|
|
808
826
|
let signatures = [];
|
|
809
827
|
if (!members) {
|
|
810
828
|
const decoratorInterface = getDecoratorDeclaration(declaration, typeChecker);
|
|
811
|
-
const callSignatures = decoratorInterface.members.filter(
|
|
829
|
+
const callSignatures = decoratorInterface.members.filter(ts9.isCallSignatureDeclaration);
|
|
812
830
|
signatures = getDecoratorSignatures(callSignatures, typeChecker);
|
|
813
831
|
}
|
|
814
832
|
return {
|
|
@@ -826,7 +844,7 @@ function isDecoratorDeclaration(declaration) {
|
|
|
826
844
|
return !!getDecoratorType(declaration);
|
|
827
845
|
}
|
|
828
846
|
function isDecoratorOptionsInterface(declaration) {
|
|
829
|
-
return declaration.getSourceFile().statements.some((s) =>
|
|
847
|
+
return declaration.getSourceFile().statements.some((s) => ts9.isVariableStatement(s) && s.declarationList.declarations.some((d) => isDecoratorDeclaration(d) && d.name.getText() === declaration.name.getText()));
|
|
830
848
|
}
|
|
831
849
|
function getDecoratorType(declaration) {
|
|
832
850
|
const initializer = declaration.initializer?.getFullText() ?? "";
|
|
@@ -844,7 +862,7 @@ function getDecoratorDeclaration(declaration, typeChecker) {
|
|
|
844
862
|
const decoratorType = typeChecker.getTypeAtLocation(decoratorDeclaration);
|
|
845
863
|
const aliasDeclaration = decoratorType.getSymbol().getDeclarations()[0];
|
|
846
864
|
const decoratorInterface = aliasDeclaration;
|
|
847
|
-
if (!decoratorInterface || !
|
|
865
|
+
if (!decoratorInterface || !ts9.isInterfaceDeclaration(decoratorInterface)) {
|
|
848
866
|
throw new Error(`No decorator interface found for "${decoratorName}".`);
|
|
849
867
|
}
|
|
850
868
|
return decoratorInterface;
|
|
@@ -855,12 +873,12 @@ function getDecoratorProperties(declaration, typeChecker) {
|
|
|
855
873
|
const firstParamType = typeChecker.getTypeAtLocation(decoratorFirstParam);
|
|
856
874
|
let firstParamTypeDecl;
|
|
857
875
|
if (firstParamType.isUnion()) {
|
|
858
|
-
const firstParamTypeUnion = firstParamType.types.find((t) => (t.flags &
|
|
876
|
+
const firstParamTypeUnion = firstParamType.types.find((t) => (t.flags & ts9.TypeFlags.Undefined) === 0);
|
|
859
877
|
firstParamTypeDecl = firstParamTypeUnion?.getSymbol()?.getDeclarations()[0];
|
|
860
878
|
} else {
|
|
861
879
|
firstParamTypeDecl = firstParamType.getSymbol()?.getDeclarations()[0];
|
|
862
880
|
}
|
|
863
|
-
if (!firstParamTypeDecl || !
|
|
881
|
+
if (!firstParamTypeDecl || !ts9.isInterfaceDeclaration(firstParamTypeDecl)) {
|
|
864
882
|
return null;
|
|
865
883
|
}
|
|
866
884
|
const interfaceDeclaration = firstParamTypeDecl;
|
|
@@ -888,7 +906,7 @@ function getDecoratorInterface(declaration, typeChecker) {
|
|
|
888
906
|
const symbol = typeChecker.getSymbolAtLocation(declaration.name);
|
|
889
907
|
const decoratorType = typeChecker.getTypeOfSymbolAtLocation(symbol, symbol.valueDeclaration);
|
|
890
908
|
const decoratorInterface = decoratorType.getSymbol()?.getDeclarations()[0];
|
|
891
|
-
if (!decoratorInterface || !
|
|
909
|
+
if (!decoratorInterface || !ts9.isInterfaceDeclaration(decoratorInterface)) {
|
|
892
910
|
throw new Error(`No decorator interface found for "${name}".`);
|
|
893
911
|
}
|
|
894
912
|
return decoratorInterface;
|
|
@@ -897,22 +915,22 @@ function getDecoratorJsDocNode(declaration, typeChecker) {
|
|
|
897
915
|
const name = declaration.name.getText();
|
|
898
916
|
const decoratorInterface = getDecoratorInterface(declaration, typeChecker);
|
|
899
917
|
const callSignature = decoratorInterface.members.filter((node) => {
|
|
900
|
-
return
|
|
918
|
+
return ts9.isCallSignatureDeclaration(node) && extractRawJsDoc(node);
|
|
901
919
|
}).at(-1);
|
|
902
|
-
if (!callSignature || !
|
|
920
|
+
if (!callSignature || !ts9.isCallSignatureDeclaration(callSignature)) {
|
|
903
921
|
throw new Error(`No call signature with JsDoc on "${name}Decorator"`);
|
|
904
922
|
}
|
|
905
923
|
return callSignature;
|
|
906
924
|
}
|
|
907
925
|
function getParamTypeString(paramNode, typeChecker) {
|
|
908
926
|
const type = typeChecker.getTypeAtLocation(paramNode);
|
|
909
|
-
const printer =
|
|
927
|
+
const printer = ts9.createPrinter({ removeComments: true });
|
|
910
928
|
const sourceFile = paramNode.getSourceFile();
|
|
911
929
|
const replace = [];
|
|
912
930
|
if (type.isUnion()) {
|
|
913
931
|
for (const subType of type.types) {
|
|
914
932
|
const decl = subType.getSymbol()?.getDeclarations()?.[0];
|
|
915
|
-
if (decl &&
|
|
933
|
+
if (decl && ts9.isInterfaceDeclaration(decl) && decl.name.text !== "Function") {
|
|
916
934
|
replace.push({
|
|
917
935
|
initial: subType.symbol.name,
|
|
918
936
|
replacedWith: expandType(decl, sourceFile, printer)
|
|
@@ -920,19 +938,19 @@ function getParamTypeString(paramNode, typeChecker) {
|
|
|
920
938
|
}
|
|
921
939
|
}
|
|
922
940
|
}
|
|
923
|
-
let result = printer.printNode(
|
|
941
|
+
let result = printer.printNode(ts9.EmitHint.Unspecified, paramNode, sourceFile).replace(new RegExp(`${paramNode.name.getText()}\\??: `), "").replaceAll(/\s+/g, " ");
|
|
924
942
|
for (const { initial, replacedWith } of replace) {
|
|
925
943
|
result = result.replace(initial, replacedWith);
|
|
926
944
|
}
|
|
927
945
|
return result;
|
|
928
946
|
}
|
|
929
947
|
function expandType(decl, sourceFile, printer) {
|
|
930
|
-
const props = decl.members.map((member) => printer.printNode(
|
|
948
|
+
const props = decl.members.map((member) => printer.printNode(ts9.EmitHint.Unspecified, member, sourceFile)).join(" ").replaceAll(/\s+/g, " ");
|
|
931
949
|
return `{${props}}`;
|
|
932
950
|
}
|
|
933
951
|
|
|
934
952
|
// packages/compiler-cli/src/ngtsc/docs/src/enum_extractor.js
|
|
935
|
-
import
|
|
953
|
+
import ts10 from "typescript";
|
|
936
954
|
function extractEnum(declaration, typeChecker) {
|
|
937
955
|
return {
|
|
938
956
|
name: declaration.name.getText(),
|
|
@@ -956,36 +974,36 @@ function extractEnumMembers(declaration, checker) {
|
|
|
956
974
|
}
|
|
957
975
|
function getEnumMemberValue(memberNode) {
|
|
958
976
|
const literal = memberNode.getChildren().find((n) => {
|
|
959
|
-
return
|
|
977
|
+
return ts10.isNumericLiteral(n) || ts10.isStringLiteral(n) || ts10.isPrefixUnaryExpression(n) && n.operator === ts10.SyntaxKind.MinusToken && ts10.isNumericLiteral(n.operand);
|
|
960
978
|
});
|
|
961
979
|
return literal?.getText() ?? "";
|
|
962
980
|
}
|
|
963
981
|
|
|
964
982
|
// packages/compiler-cli/src/ngtsc/docs/src/initializer_api_function_extractor.js
|
|
965
|
-
import
|
|
983
|
+
import ts11 from "typescript";
|
|
966
984
|
var initializerApiTag = "initializerApiFunction";
|
|
967
985
|
function isInitializerApiFunction(node, typeChecker) {
|
|
968
|
-
if (
|
|
986
|
+
if (ts11.isFunctionDeclaration(node) && node.name !== void 0 && node.body === void 0) {
|
|
969
987
|
const implementation = findImplementationOfFunction(node, typeChecker);
|
|
970
988
|
if (implementation !== void 0) {
|
|
971
989
|
node = implementation;
|
|
972
990
|
}
|
|
973
991
|
}
|
|
974
|
-
if (!
|
|
992
|
+
if (!ts11.isFunctionDeclaration(node) && !ts11.isVariableDeclaration(node)) {
|
|
975
993
|
return false;
|
|
976
994
|
}
|
|
977
|
-
let tagContainer =
|
|
995
|
+
let tagContainer = ts11.isFunctionDeclaration(node) ? node : getContainerVariableStatement(node);
|
|
978
996
|
if (tagContainer === null) {
|
|
979
997
|
return false;
|
|
980
998
|
}
|
|
981
|
-
const tags =
|
|
999
|
+
const tags = ts11.getJSDocTags(tagContainer);
|
|
982
1000
|
return tags.some((t) => t.tagName.text === initializerApiTag);
|
|
983
1001
|
}
|
|
984
1002
|
function extractInitializerApiFunction(node, typeChecker) {
|
|
985
|
-
if (node.name === void 0 || !
|
|
1003
|
+
if (node.name === void 0 || !ts11.isIdentifier(node.name)) {
|
|
986
1004
|
throw new Error(`Initializer API: Expected literal variable name.`);
|
|
987
1005
|
}
|
|
988
|
-
const container =
|
|
1006
|
+
const container = ts11.isFunctionDeclaration(node) ? node : getContainerVariableStatement(node);
|
|
989
1007
|
if (container === null) {
|
|
990
1008
|
throw new Error("Initializer API: Could not find container AST node of variable.");
|
|
991
1009
|
}
|
|
@@ -996,7 +1014,7 @@ function extractInitializerApiFunction(node, typeChecker) {
|
|
|
996
1014
|
for (const property of type.getProperties()) {
|
|
997
1015
|
const subName = property.getName();
|
|
998
1016
|
const subDecl = property.getDeclarations()?.[0];
|
|
999
|
-
if (subDecl === void 0 || !
|
|
1017
|
+
if (subDecl === void 0 || !ts11.isPropertySignature(subDecl)) {
|
|
1000
1018
|
throw new Error(`Initializer API: Could not resolve declaration of sub-property: ${name}.${subName}`);
|
|
1001
1019
|
}
|
|
1002
1020
|
const subType = typeChecker.getTypeAtLocation(subDecl);
|
|
@@ -1005,7 +1023,7 @@ function extractInitializerApiFunction(node, typeChecker) {
|
|
|
1005
1023
|
let jsdocTags;
|
|
1006
1024
|
let description;
|
|
1007
1025
|
let rawComment;
|
|
1008
|
-
if (
|
|
1026
|
+
if (ts11.isFunctionDeclaration(node)) {
|
|
1009
1027
|
const implementation = findImplementationOfFunction(node, typeChecker);
|
|
1010
1028
|
if (implementation === void 0) {
|
|
1011
1029
|
throw new Error(`Initializer API: Could not find implementation of function: ${name}`);
|
|
@@ -1053,10 +1071,10 @@ function extractInitializerApiFunction(node, typeChecker) {
|
|
|
1053
1071
|
};
|
|
1054
1072
|
}
|
|
1055
1073
|
function getContainerVariableStatement(node) {
|
|
1056
|
-
if (!
|
|
1074
|
+
if (!ts11.isVariableDeclarationList(node.parent)) {
|
|
1057
1075
|
return null;
|
|
1058
1076
|
}
|
|
1059
|
-
if (!
|
|
1077
|
+
if (!ts11.isVariableStatement(node.parent.parent)) {
|
|
1060
1078
|
return null;
|
|
1061
1079
|
}
|
|
1062
1080
|
return node.parent.parent;
|
|
@@ -1084,15 +1102,15 @@ function extractTypeAlias(declaration) {
|
|
|
1084
1102
|
}
|
|
1085
1103
|
|
|
1086
1104
|
// packages/compiler-cli/src/ngtsc/docs/src/import_extractor.js
|
|
1087
|
-
import
|
|
1105
|
+
import ts12 from "typescript";
|
|
1088
1106
|
function getImportedSymbols(sourceFile) {
|
|
1089
1107
|
const importSpecifiers = /* @__PURE__ */ new Map();
|
|
1090
1108
|
function visit(node) {
|
|
1091
|
-
if (
|
|
1109
|
+
if (ts12.isImportDeclaration(node)) {
|
|
1092
1110
|
let moduleSpecifier = node.moduleSpecifier.getText(sourceFile).replace(/['"]/g, "");
|
|
1093
1111
|
if (moduleSpecifier.startsWith("@angular/")) {
|
|
1094
1112
|
const namedBindings = node.importClause?.namedBindings;
|
|
1095
|
-
if (namedBindings &&
|
|
1113
|
+
if (namedBindings && ts12.isNamedImports(namedBindings)) {
|
|
1096
1114
|
namedBindings.elements.forEach((importSpecifier) => {
|
|
1097
1115
|
const importName = importSpecifier.name.text;
|
|
1098
1116
|
const importAlias = importSpecifier.propertyName ? importSpecifier.propertyName.text : void 0;
|
|
@@ -1101,7 +1119,7 @@ function getImportedSymbols(sourceFile) {
|
|
|
1101
1119
|
}
|
|
1102
1120
|
}
|
|
1103
1121
|
}
|
|
1104
|
-
|
|
1122
|
+
ts12.forEachChild(node, visit);
|
|
1105
1123
|
}
|
|
1106
1124
|
visit(sourceFile);
|
|
1107
1125
|
return importSpecifiers;
|
|
@@ -1145,8 +1163,8 @@ var DocsExtractor = class {
|
|
|
1145
1163
|
entry.source = {
|
|
1146
1164
|
filePath: getRelativeFilePath(realSourceFile, rootDir),
|
|
1147
1165
|
// Start & End are off by 1
|
|
1148
|
-
startLine:
|
|
1149
|
-
endLine:
|
|
1166
|
+
startLine: ts13.getLineAndCharacterOfPosition(realSourceFile, node.getStart()).line + 1,
|
|
1167
|
+
endLine: ts13.getLineAndCharacterOfPosition(realSourceFile, node.getEnd()).line + 1
|
|
1150
1168
|
};
|
|
1151
1169
|
entries.push({ ...entry, name: exportName });
|
|
1152
1170
|
}
|
|
@@ -1161,20 +1179,20 @@ var DocsExtractor = class {
|
|
|
1161
1179
|
if (isInitializerApiFunction(node, this.typeChecker)) {
|
|
1162
1180
|
return extractInitializerApiFunction(node, this.typeChecker);
|
|
1163
1181
|
}
|
|
1164
|
-
if (
|
|
1182
|
+
if (ts13.isInterfaceDeclaration(node) && !isIgnoredInterface(node)) {
|
|
1165
1183
|
return extractInterface(node, this.typeChecker);
|
|
1166
1184
|
}
|
|
1167
|
-
if (
|
|
1185
|
+
if (ts13.isFunctionDeclaration(node)) {
|
|
1168
1186
|
const functionExtractor = new FunctionExtractor(node.name.getText(), node, this.typeChecker);
|
|
1169
1187
|
return functionExtractor.extract();
|
|
1170
1188
|
}
|
|
1171
|
-
if (
|
|
1189
|
+
if (ts13.isVariableDeclaration(node) && !isSyntheticAngularConstant(node)) {
|
|
1172
1190
|
return isDecoratorDeclaration(node) ? extractorDecorator(node, this.typeChecker) : extractConstant(node, this.typeChecker);
|
|
1173
1191
|
}
|
|
1174
|
-
if (
|
|
1192
|
+
if (ts13.isTypeAliasDeclaration(node)) {
|
|
1175
1193
|
return extractTypeAlias(node);
|
|
1176
1194
|
}
|
|
1177
|
-
if (
|
|
1195
|
+
if (ts13.isEnumDeclaration(node)) {
|
|
1178
1196
|
return extractEnum(node, this.typeChecker);
|
|
1179
1197
|
}
|
|
1180
1198
|
return null;
|
|
@@ -1203,114 +1221,16 @@ function getRelativeFilePath(sourceFile, rootDir) {
|
|
|
1203
1221
|
return relativePath;
|
|
1204
1222
|
}
|
|
1205
1223
|
|
|
1206
|
-
// packages/compiler-cli/src/ngtsc/
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
function i18nGetExtension(formatName) {
|
|
1214
|
-
const format = formatName.toLowerCase();
|
|
1215
|
-
switch (format) {
|
|
1216
|
-
case "xmb":
|
|
1217
|
-
return "xmb";
|
|
1218
|
-
case "xlf":
|
|
1219
|
-
case "xlif":
|
|
1220
|
-
case "xliff":
|
|
1221
|
-
case "xlf2":
|
|
1222
|
-
case "xliff2":
|
|
1223
|
-
return "xlf";
|
|
1224
|
-
}
|
|
1225
|
-
throw new Error(`Unsupported format "${formatName}"`);
|
|
1226
|
-
}
|
|
1227
|
-
function i18nExtract(formatName, outFile, host, options, bundle, pathResolve = path.resolve) {
|
|
1228
|
-
formatName = formatName || "xlf";
|
|
1229
|
-
const ext = i18nGetExtension(formatName);
|
|
1230
|
-
const content = i18nSerialize(bundle, formatName, options);
|
|
1231
|
-
const dstFile = outFile || `messages.${ext}`;
|
|
1232
|
-
const dstPath = pathResolve(options.outDir || options.basePath, dstFile);
|
|
1233
|
-
host.writeFile(dstPath, content, false, void 0, []);
|
|
1234
|
-
return [dstPath];
|
|
1235
|
-
}
|
|
1236
|
-
function i18nSerialize(bundle, formatName, options) {
|
|
1237
|
-
const format = formatName.toLowerCase();
|
|
1238
|
-
let serializer;
|
|
1239
|
-
switch (format) {
|
|
1240
|
-
case "xmb":
|
|
1241
|
-
serializer = new Xmb();
|
|
1242
|
-
break;
|
|
1243
|
-
case "xliff2":
|
|
1244
|
-
case "xlf2":
|
|
1245
|
-
serializer = new Xliff2();
|
|
1246
|
-
break;
|
|
1247
|
-
case "xlf":
|
|
1248
|
-
case "xliff":
|
|
1249
|
-
default:
|
|
1250
|
-
serializer = new Xliff();
|
|
1251
|
-
}
|
|
1252
|
-
return bundle.write(serializer, getPathNormalizer(options.basePath));
|
|
1253
|
-
}
|
|
1254
|
-
function getPathNormalizer(basePath) {
|
|
1255
|
-
return (sourcePath) => {
|
|
1256
|
-
sourcePath = basePath ? path.relative(basePath, sourcePath) : sourcePath;
|
|
1257
|
-
return sourcePath.split(path.sep).join("/");
|
|
1258
|
-
};
|
|
1259
|
-
}
|
|
1260
|
-
|
|
1261
|
-
// packages/compiler-cli/src/typescript_support.js
|
|
1262
|
-
import ts13 from "typescript";
|
|
1263
|
-
|
|
1264
|
-
// packages/compiler-cli/src/version_helpers.js
|
|
1265
|
-
function toNumbers(value) {
|
|
1266
|
-
const suffixIndex = value.lastIndexOf("-");
|
|
1267
|
-
return value.slice(0, suffixIndex === -1 ? value.length : suffixIndex).split(".").map((segment) => {
|
|
1268
|
-
const parsed = parseInt(segment, 10);
|
|
1269
|
-
if (isNaN(parsed)) {
|
|
1270
|
-
throw Error(`Unable to parse version string ${value}.`);
|
|
1271
|
-
}
|
|
1272
|
-
return parsed;
|
|
1273
|
-
});
|
|
1274
|
-
}
|
|
1275
|
-
function compareNumbers(a, b) {
|
|
1276
|
-
const max = Math.max(a.length, b.length);
|
|
1277
|
-
const min = Math.min(a.length, b.length);
|
|
1278
|
-
for (let i = 0; i < min; i++) {
|
|
1279
|
-
if (a[i] > b[i])
|
|
1280
|
-
return 1;
|
|
1281
|
-
if (a[i] < b[i])
|
|
1282
|
-
return -1;
|
|
1283
|
-
}
|
|
1284
|
-
if (min !== max) {
|
|
1285
|
-
const longestArray = a.length === max ? a : b;
|
|
1286
|
-
const comparisonResult = a.length === max ? 1 : -1;
|
|
1287
|
-
for (let i = min; i < max; i++) {
|
|
1288
|
-
if (longestArray[i] > 0) {
|
|
1289
|
-
return comparisonResult;
|
|
1290
|
-
}
|
|
1291
|
-
}
|
|
1292
|
-
}
|
|
1293
|
-
return 0;
|
|
1294
|
-
}
|
|
1295
|
-
function compareVersions(v1, v2) {
|
|
1296
|
-
return compareNumbers(toNumbers(v1), toNumbers(v2));
|
|
1297
|
-
}
|
|
1298
|
-
|
|
1299
|
-
// packages/compiler-cli/src/typescript_support.js
|
|
1300
|
-
var MIN_TS_VERSION = "5.8.0";
|
|
1301
|
-
var MAX_TS_VERSION = "6.0.0";
|
|
1302
|
-
var tsVersion = ts13.version;
|
|
1303
|
-
function checkVersion(version, minVersion, maxVersion) {
|
|
1304
|
-
if (compareVersions(version, minVersion) < 0 || compareVersions(version, maxVersion) >= 0) {
|
|
1305
|
-
throw new Error(`The Angular Compiler requires TypeScript >=${minVersion} and <${maxVersion} but ${version} was found instead.`);
|
|
1306
|
-
}
|
|
1307
|
-
}
|
|
1308
|
-
function verifySupportedTypeScriptVersion() {
|
|
1309
|
-
checkVersion(tsVersion, MIN_TS_VERSION, MAX_TS_VERSION);
|
|
1310
|
-
}
|
|
1224
|
+
// packages/compiler-cli/src/ngtsc/core/api/src/public_options.js
|
|
1225
|
+
var DiagnosticCategoryLabel;
|
|
1226
|
+
(function(DiagnosticCategoryLabel2) {
|
|
1227
|
+
DiagnosticCategoryLabel2["Warning"] = "warning";
|
|
1228
|
+
DiagnosticCategoryLabel2["Error"] = "error";
|
|
1229
|
+
DiagnosticCategoryLabel2["Suppress"] = "suppress";
|
|
1230
|
+
})(DiagnosticCategoryLabel || (DiagnosticCategoryLabel = {}));
|
|
1311
1231
|
|
|
1312
1232
|
// packages/compiler-cli/src/ngtsc/core/src/compiler.js
|
|
1313
|
-
import
|
|
1233
|
+
import ts26 from "typescript";
|
|
1314
1234
|
|
|
1315
1235
|
// packages/compiler-cli/src/ngtsc/cycles/src/analyzer.js
|
|
1316
1236
|
var CycleAnalyzer = class {
|
|
@@ -2804,7 +2724,7 @@ var StandaloneComponentScopeReader = class {
|
|
|
2804
2724
|
};
|
|
2805
2725
|
|
|
2806
2726
|
// packages/compiler-cli/src/ngtsc/typecheck/extended/checks/interpolated_signal_not_invoked/index.js
|
|
2807
|
-
import { ASTWithSource as ASTWithSource2, BindingType, Interpolation, PrefixNot, PropertyRead as PropertyRead2, TmplAstBoundAttribute } from "@angular/compiler";
|
|
2727
|
+
import { ASTWithSource as ASTWithSource2, BindingType, Interpolation, PrefixNot, PropertyRead as PropertyRead2, TmplAstBoundAttribute, TmplAstElement as TmplAstElement2, TmplAstIfBlock, TmplAstSwitchBlock, TmplAstTemplate as TmplAstTemplate2 } from "@angular/compiler";
|
|
2808
2728
|
|
|
2809
2729
|
// packages/compiler-cli/src/ngtsc/typecheck/src/symbol_util.js
|
|
2810
2730
|
import ts18 from "typescript";
|
|
@@ -2831,16 +2751,6 @@ function isSignalSymbol(symbol) {
|
|
|
2831
2751
|
// packages/compiler-cli/src/ngtsc/typecheck/extended/api/api.js
|
|
2832
2752
|
import { CombinedRecursiveAstVisitor as CombinedRecursiveAstVisitor2 } from "@angular/compiler";
|
|
2833
2753
|
var TemplateCheckWithVisitor = class {
|
|
2834
|
-
/**
|
|
2835
|
-
* When extended diagnostics were first introduced, the visitor wasn't implemented correctly
|
|
2836
|
-
* which meant that it wasn't visiting the `templateAttrs` of structural directives (e.g.
|
|
2837
|
-
* the expression of `*ngIf`). Fixing the issue causes a lot of internal breakages and will likely
|
|
2838
|
-
* need to be done in a major version to avoid external breakages. This flag is used to opt out
|
|
2839
|
-
* pre-existing diagnostics from the correct behavior until the breakages have been fixed while
|
|
2840
|
-
* ensuring that newly-written diagnostics are correct from the beginning.
|
|
2841
|
-
* TODO(crisbeto): remove this flag and fix the internal brekages.
|
|
2842
|
-
*/
|
|
2843
|
-
canVisitStructuralAttributes = true;
|
|
2844
2754
|
/**
|
|
2845
2755
|
* Base implementation for run function, visits all nodes in template and calls
|
|
2846
2756
|
* `visitNode()` for each one.
|
|
@@ -2873,9 +2783,7 @@ var TemplateVisitor2 = class extends CombinedRecursiveAstVisitor2 {
|
|
|
2873
2783
|
this.visitAllTemplateNodes(template.outputs);
|
|
2874
2784
|
}
|
|
2875
2785
|
this.visitAllTemplateNodes(template.directives);
|
|
2876
|
-
|
|
2877
|
-
this.visitAllTemplateNodes(template.templateAttrs);
|
|
2878
|
-
}
|
|
2786
|
+
this.visitAllTemplateNodes(template.templateAttrs);
|
|
2879
2787
|
this.visitAllTemplateNodes(template.variables);
|
|
2880
2788
|
this.visitAllTemplateNodes(template.references);
|
|
2881
2789
|
this.visitAllTemplateNodes(template.children);
|
|
@@ -2895,27 +2803,53 @@ var InterpolatedSignalCheck = class extends TemplateCheckWithVisitor {
|
|
|
2895
2803
|
visitNode(ctx, component, node) {
|
|
2896
2804
|
if (node instanceof Interpolation) {
|
|
2897
2805
|
return node.expressions.map((item) => item instanceof PrefixNot ? item.expression : item).filter((item) => item instanceof PropertyRead2).flatMap((item) => buildDiagnosticForSignal(ctx, item, component));
|
|
2898
|
-
} else if (node instanceof
|
|
2899
|
-
const
|
|
2900
|
-
|
|
2901
|
-
|
|
2902
|
-
|
|
2903
|
-
const
|
|
2904
|
-
|
|
2905
|
-
|
|
2906
|
-
|
|
2907
|
-
|
|
2908
|
-
|
|
2909
|
-
|
|
2910
|
-
|
|
2911
|
-
|
|
2912
|
-
)
|
|
2913
|
-
|
|
2806
|
+
} else if (node instanceof TmplAstElement2 && node.inputs.length > 0) {
|
|
2807
|
+
const directivesOfElement = ctx.templateTypeChecker.getDirectivesOfNode(component, node);
|
|
2808
|
+
return node.inputs.flatMap((input) => checkBoundAttribute(ctx, component, directivesOfElement, input));
|
|
2809
|
+
} else if (node instanceof TmplAstTemplate2 && node.tagName === "ng-template") {
|
|
2810
|
+
const directivesOfElement = ctx.templateTypeChecker.getDirectivesOfNode(component, node);
|
|
2811
|
+
const inputDiagnostics = node.inputs.flatMap((input) => {
|
|
2812
|
+
return checkBoundAttribute(ctx, component, directivesOfElement, input);
|
|
2813
|
+
});
|
|
2814
|
+
const templateAttrDiagnostics = node.templateAttrs.flatMap((attr) => {
|
|
2815
|
+
if (!(attr instanceof TmplAstBoundAttribute)) {
|
|
2816
|
+
return [];
|
|
2817
|
+
}
|
|
2818
|
+
return checkBoundAttribute(ctx, component, directivesOfElement, attr);
|
|
2819
|
+
});
|
|
2820
|
+
return inputDiagnostics.concat(templateAttrDiagnostics);
|
|
2821
|
+
} else if (node instanceof TmplAstIfBlock) {
|
|
2822
|
+
return node.branches.map((branch) => branch.expression).filter((expr) => expr instanceof ASTWithSource2).map((expr) => {
|
|
2823
|
+
const ast = expr.ast;
|
|
2824
|
+
return ast instanceof PrefixNot ? ast.expression : ast;
|
|
2825
|
+
}).filter((ast) => ast instanceof PropertyRead2).flatMap((item) => buildDiagnosticForSignal(ctx, item, component));
|
|
2826
|
+
} else if (node instanceof TmplAstSwitchBlock && node.expression instanceof ASTWithSource2) {
|
|
2827
|
+
const expression = node.expression.ast instanceof PrefixNot ? node.expression.ast.expression : node.expression.ast;
|
|
2828
|
+
if (expression instanceof PropertyRead2) {
|
|
2829
|
+
return buildDiagnosticForSignal(ctx, expression, component);
|
|
2914
2830
|
}
|
|
2915
2831
|
}
|
|
2916
2832
|
return [];
|
|
2917
2833
|
}
|
|
2918
2834
|
};
|
|
2835
|
+
function checkBoundAttribute(ctx, component, directivesOfElement, node) {
|
|
2836
|
+
if (directivesOfElement !== null && directivesOfElement.some((dir) => dir.inputs.getByBindingPropertyName(node.name) !== null)) {
|
|
2837
|
+
return [];
|
|
2838
|
+
}
|
|
2839
|
+
const nodeAst = isPropertyReadNodeAst(node);
|
|
2840
|
+
if (
|
|
2841
|
+
// a bound property like `[prop]="mySignal"`
|
|
2842
|
+
(node.type === BindingType.Property || // or a class binding like `[class.myClass]="mySignal"`
|
|
2843
|
+
node.type === BindingType.Class || // or a style binding like `[style.width]="mySignal"`
|
|
2844
|
+
node.type === BindingType.Style || // or an attribute binding like `[attr.role]="mySignal"`
|
|
2845
|
+
node.type === BindingType.Attribute || // or an animation binding like `[animate.enter]="mySignal"`
|
|
2846
|
+
node.type === BindingType.Animation || // or an animation binding like `[@myAnimation]="mySignal"`
|
|
2847
|
+
node.type === BindingType.LegacyAnimation) && nodeAst
|
|
2848
|
+
) {
|
|
2849
|
+
return buildDiagnosticForSignal(ctx, nodeAst, component);
|
|
2850
|
+
}
|
|
2851
|
+
return [];
|
|
2852
|
+
}
|
|
2919
2853
|
function isPropertyReadNodeAst(node) {
|
|
2920
2854
|
if (node.value instanceof ASTWithSource2 === false) {
|
|
2921
2855
|
return void 0;
|
|
@@ -2942,8 +2876,11 @@ function buildDiagnosticForSignal(ctx, node, component) {
|
|
|
2942
2876
|
const diagnostic = ctx.makeTemplateDiagnostic(templateMapping.span, errorString);
|
|
2943
2877
|
return [diagnostic];
|
|
2944
2878
|
}
|
|
2879
|
+
if (!isFunctionInstanceProperty(node.name) && !isSignalInstanceProperty(node.name)) {
|
|
2880
|
+
return [];
|
|
2881
|
+
}
|
|
2945
2882
|
const symbolOfReceiver = ctx.templateTypeChecker.getSymbolOfNode(node.receiver, component);
|
|
2946
|
-
if (
|
|
2883
|
+
if (symbolOfReceiver !== null && symbolOfReceiver.kind === SymbolKind.Expression && isSignalReference(symbolOfReceiver)) {
|
|
2947
2884
|
const templateMapping = ctx.templateTypeChecker.getSourceMappingAtTcbLocation(symbolOfReceiver.tcbLocation);
|
|
2948
2885
|
const errorString = `${node.receiver.name} is a function and should be invoked: ${node.receiver.name}()`;
|
|
2949
2886
|
const diagnostic = ctx.makeTemplateDiagnostic(templateMapping.span, errorString);
|
|
@@ -2981,7 +2918,7 @@ var factory2 = {
|
|
|
2981
2918
|
};
|
|
2982
2919
|
|
|
2983
2920
|
// packages/compiler-cli/src/ngtsc/typecheck/extended/checks/missing_control_flow_directive/index.js
|
|
2984
|
-
import { TmplAstTemplate as
|
|
2921
|
+
import { TmplAstTemplate as TmplAstTemplate3 } from "@angular/compiler";
|
|
2985
2922
|
var KNOWN_CONTROL_FLOW_DIRECTIVES = /* @__PURE__ */ new Map([
|
|
2986
2923
|
["ngIf", { directive: "NgIf", builtIn: "@if" }],
|
|
2987
2924
|
["ngFor", { directive: "NgFor", builtIn: "@for" }],
|
|
@@ -2998,7 +2935,7 @@ var MissingControlFlowDirectiveCheck = class extends TemplateCheckWithVisitor {
|
|
|
2998
2935
|
return super.run(ctx, component, template);
|
|
2999
2936
|
}
|
|
3000
2937
|
visitNode(ctx, component, node) {
|
|
3001
|
-
if (!(node instanceof
|
|
2938
|
+
if (!(node instanceof TmplAstTemplate3))
|
|
3002
2939
|
return [];
|
|
3003
2940
|
const controlFlowAttr = node.templateAttrs.find((attr) => KNOWN_CONTROL_FLOW_DIRECTIVES.has(attr.name));
|
|
3004
2941
|
if (!controlFlowAttr)
|
|
@@ -3023,12 +2960,12 @@ var factory3 = {
|
|
|
3023
2960
|
};
|
|
3024
2961
|
|
|
3025
2962
|
// packages/compiler-cli/src/ngtsc/typecheck/extended/checks/missing_ngforof_let/index.js
|
|
3026
|
-
import { TmplAstTemplate as
|
|
2963
|
+
import { TmplAstTemplate as TmplAstTemplate4 } from "@angular/compiler";
|
|
3027
2964
|
var MissingNgForOfLetCheck = class extends TemplateCheckWithVisitor {
|
|
3028
2965
|
code = ErrorCode.MISSING_NGFOROF_LET;
|
|
3029
2966
|
visitNode(ctx, component, node) {
|
|
3030
|
-
const isTemplate = node instanceof
|
|
3031
|
-
if (!(node instanceof
|
|
2967
|
+
const isTemplate = node instanceof TmplAstTemplate4;
|
|
2968
|
+
if (!(node instanceof TmplAstTemplate4)) {
|
|
3032
2969
|
return [];
|
|
3033
2970
|
}
|
|
3034
2971
|
if (node.templateAttrs.length === 0) {
|
|
@@ -3053,14 +2990,16 @@ var factory4 = {
|
|
|
3053
2990
|
};
|
|
3054
2991
|
|
|
3055
2992
|
// packages/compiler-cli/src/ngtsc/typecheck/extended/checks/missing_structural_directive/index.js
|
|
3056
|
-
import { TmplAstTemplate as
|
|
2993
|
+
import { TmplAstTemplate as TmplAstTemplate5 } from "@angular/compiler";
|
|
3057
2994
|
var KNOWN_CONTROL_FLOW_DIRECTIVES2 = /* @__PURE__ */ new Set([
|
|
3058
2995
|
"ngIf",
|
|
3059
2996
|
"ngFor",
|
|
3060
2997
|
"ngForOf",
|
|
3061
2998
|
"ngForTrackBy",
|
|
3062
2999
|
"ngSwitchCase",
|
|
3063
|
-
"ngSwitchDefault"
|
|
3000
|
+
"ngSwitchDefault",
|
|
3001
|
+
"ngIfThen",
|
|
3002
|
+
"ngIfElse"
|
|
3064
3003
|
]);
|
|
3065
3004
|
var MissingStructuralDirectiveCheck = class extends TemplateCheckWithVisitor {
|
|
3066
3005
|
code = ErrorCode.MISSING_STRUCTURAL_DIRECTIVE;
|
|
@@ -3072,15 +3011,15 @@ var MissingStructuralDirectiveCheck = class extends TemplateCheckWithVisitor {
|
|
|
3072
3011
|
return super.run(ctx, component, template);
|
|
3073
3012
|
}
|
|
3074
3013
|
visitNode(ctx, component, node) {
|
|
3075
|
-
if (!(node instanceof
|
|
3014
|
+
if (!(node instanceof TmplAstTemplate5))
|
|
3076
3015
|
return [];
|
|
3077
3016
|
const customStructuralDirective = node.templateAttrs.find((attr) => !KNOWN_CONTROL_FLOW_DIRECTIVES2.has(attr.name));
|
|
3078
3017
|
if (!customStructuralDirective)
|
|
3079
3018
|
return [];
|
|
3080
3019
|
const symbol = ctx.templateTypeChecker.getSymbolOfNode(node, component);
|
|
3081
|
-
|
|
3020
|
+
const hasStructuralDirective = symbol?.directives.some((dir) => dir.selector?.includes(`[${customStructuralDirective.name}]`));
|
|
3021
|
+
if (hasStructuralDirective)
|
|
3082
3022
|
return [];
|
|
3083
|
-
}
|
|
3084
3023
|
const sourceSpan = customStructuralDirective.keySpan || customStructuralDirective.sourceSpan;
|
|
3085
3024
|
const errorMessage = `A structural directive \`${customStructuralDirective.name}\` was used in the template without a corresponding import in the component. Make sure that the directive is included in the \`@Component.imports\` array of this component.`;
|
|
3086
3025
|
return [ctx.makeTemplateDiagnostic(sourceSpan, errorMessage)];
|
|
@@ -3096,7 +3035,6 @@ var factory5 = {
|
|
|
3096
3035
|
import { Binary } from "@angular/compiler";
|
|
3097
3036
|
import ts19 from "typescript";
|
|
3098
3037
|
var NullishCoalescingNotNullableCheck = class extends TemplateCheckWithVisitor {
|
|
3099
|
-
canVisitStructuralAttributes = false;
|
|
3100
3038
|
code = ErrorCode.NULLISH_COALESCING_NOT_NULLABLE;
|
|
3101
3039
|
visitNode(ctx, component, node) {
|
|
3102
3040
|
if (!(node instanceof Binary) || node.operation !== "??")
|
|
@@ -3136,14 +3074,22 @@ var factory6 = {
|
|
|
3136
3074
|
};
|
|
3137
3075
|
|
|
3138
3076
|
// packages/compiler-cli/src/ngtsc/typecheck/extended/checks/optional_chain_not_nullable/index.js
|
|
3139
|
-
import { SafeCall, SafeKeyedRead, SafePropertyRead } from "@angular/compiler";
|
|
3077
|
+
import { KeyedRead, SafeCall, SafeKeyedRead, SafePropertyRead } from "@angular/compiler";
|
|
3140
3078
|
import ts20 from "typescript";
|
|
3141
3079
|
var OptionalChainNotNullableCheck = class extends TemplateCheckWithVisitor {
|
|
3142
|
-
|
|
3080
|
+
noUncheckedIndexedAccess;
|
|
3143
3081
|
code = ErrorCode.OPTIONAL_CHAIN_NOT_NULLABLE;
|
|
3082
|
+
constructor(noUncheckedIndexedAccess) {
|
|
3083
|
+
super();
|
|
3084
|
+
this.noUncheckedIndexedAccess = noUncheckedIndexedAccess;
|
|
3085
|
+
}
|
|
3144
3086
|
visitNode(ctx, component, node) {
|
|
3145
|
-
if (!(node instanceof SafeCall) && !(node instanceof SafePropertyRead) && !(node instanceof SafeKeyedRead))
|
|
3087
|
+
if (!(node instanceof SafeCall) && !(node instanceof SafePropertyRead) && !(node instanceof SafeKeyedRead)) {
|
|
3146
3088
|
return [];
|
|
3089
|
+
}
|
|
3090
|
+
if (node.receiver instanceof KeyedRead && !this.noUncheckedIndexedAccess) {
|
|
3091
|
+
return [];
|
|
3092
|
+
}
|
|
3147
3093
|
const symbolLeft = ctx.templateTypeChecker.getSymbolOfNode(node.receiver, component);
|
|
3148
3094
|
if (symbolLeft === null || symbolLeft.kind !== SymbolKind.Expression) {
|
|
3149
3095
|
return [];
|
|
@@ -3175,7 +3121,8 @@ var factory7 = {
|
|
|
3175
3121
|
if (!strictNullChecks) {
|
|
3176
3122
|
return null;
|
|
3177
3123
|
}
|
|
3178
|
-
|
|
3124
|
+
const noUncheckedIndexedAccess = !!options.noUncheckedIndexedAccess;
|
|
3125
|
+
return new OptionalChainNotNullableCheck(noUncheckedIndexedAccess);
|
|
3179
3126
|
}
|
|
3180
3127
|
};
|
|
3181
3128
|
|
|
@@ -3453,30 +3400,84 @@ var factory15 = {
|
|
|
3453
3400
|
create: () => new UninvokedFunctionInTextInterpolation()
|
|
3454
3401
|
};
|
|
3455
3402
|
|
|
3456
|
-
// packages/compiler-cli/src/ngtsc/typecheck/extended/
|
|
3457
|
-
import
|
|
3458
|
-
|
|
3459
|
-
|
|
3460
|
-
|
|
3461
|
-
(
|
|
3462
|
-
|
|
3463
|
-
|
|
3464
|
-
|
|
3465
|
-
|
|
3403
|
+
// packages/compiler-cli/src/ngtsc/typecheck/extended/checks/defer_trigger_misconfiguration/index.js
|
|
3404
|
+
import { TmplAstDeferredBlock, TmplAstHoverDeferredTrigger, TmplAstImmediateDeferredTrigger, TmplAstInteractionDeferredTrigger, TmplAstTimerDeferredTrigger, TmplAstViewportDeferredTrigger } from "@angular/compiler";
|
|
3405
|
+
var DeferTriggerMisconfiguration = class extends TemplateCheckWithVisitor {
|
|
3406
|
+
code = ErrorCode.DEFER_TRIGGER_MISCONFIGURATION;
|
|
3407
|
+
visitNode(ctx, component, node) {
|
|
3408
|
+
if (!(node instanceof TmplAstDeferredBlock))
|
|
3409
|
+
return [];
|
|
3410
|
+
const mainKeys = Object.keys(node.triggers);
|
|
3411
|
+
const prefetchKeys = Object.keys(node.prefetchTriggers);
|
|
3412
|
+
const mains = mainKeys.map((k) => node.triggers[k]).filter((t) => t !== void 0 && t !== null);
|
|
3413
|
+
const prefetches = prefetchKeys.map((k) => node.prefetchTriggers[k]).filter((t) => t !== void 0 && t !== null);
|
|
3414
|
+
const diags = [];
|
|
3415
|
+
const hasImmediateMain = mains.some((t) => t instanceof TmplAstImmediateDeferredTrigger);
|
|
3416
|
+
if (hasImmediateMain) {
|
|
3417
|
+
if (mains.length > 1) {
|
|
3418
|
+
const msg = `The 'immediate' trigger makes additional triggers redundant.`;
|
|
3419
|
+
diags.push(ctx.makeTemplateDiagnostic(node.sourceSpan, msg));
|
|
3420
|
+
}
|
|
3421
|
+
if (prefetches.length > 0) {
|
|
3422
|
+
const msg = `Prefetch triggers have no effect because 'immediate' executes earlier.`;
|
|
3423
|
+
diags.push(ctx.makeTemplateDiagnostic(node.sourceSpan, msg));
|
|
3424
|
+
}
|
|
3425
|
+
}
|
|
3426
|
+
if (mains.length === 1 && prefetches.length > 0) {
|
|
3427
|
+
const main = mains[0];
|
|
3428
|
+
for (const pre of prefetches) {
|
|
3429
|
+
const isTimerTriggger = main instanceof TmplAstTimerDeferredTrigger && pre instanceof TmplAstTimerDeferredTrigger;
|
|
3430
|
+
if (isTimerTriggger) {
|
|
3431
|
+
const mainDelay = main.delay;
|
|
3432
|
+
const preDelay = pre.delay;
|
|
3433
|
+
if (preDelay >= mainDelay) {
|
|
3434
|
+
const msg = `The Prefetch 'timer(${preDelay}ms)' is not scheduled before the main 'timer(${mainDelay}ms)', so it won\u2019t run prior to rendering. Lower the prefetch delay or remove it.`;
|
|
3435
|
+
diags.push(ctx.makeTemplateDiagnostic(pre.sourceSpan ?? node.sourceSpan, msg));
|
|
3436
|
+
}
|
|
3437
|
+
}
|
|
3438
|
+
const isHoverTrigger = main instanceof TmplAstHoverDeferredTrigger && pre instanceof TmplAstHoverDeferredTrigger;
|
|
3439
|
+
const isInteractionTrigger = main instanceof TmplAstInteractionDeferredTrigger && pre instanceof TmplAstInteractionDeferredTrigger;
|
|
3440
|
+
const isViewportTrigger = main instanceof TmplAstViewportDeferredTrigger && pre instanceof TmplAstViewportDeferredTrigger;
|
|
3441
|
+
if (isHoverTrigger || isInteractionTrigger || isViewportTrigger) {
|
|
3442
|
+
const mainRef = main.reference;
|
|
3443
|
+
const preRef = pre.reference;
|
|
3444
|
+
if (mainRef && preRef && mainRef === preRef) {
|
|
3445
|
+
const kindName = main.constructor.name.replace("DeferredTrigger", "").toLowerCase();
|
|
3446
|
+
const msg = `Prefetch '${kindName}' matches the main trigger and provides no benefit. Remove the prefetch modifier.`;
|
|
3447
|
+
diags.push(ctx.makeTemplateDiagnostic(pre.sourceSpan ?? node.sourceSpan, msg));
|
|
3448
|
+
}
|
|
3449
|
+
continue;
|
|
3450
|
+
}
|
|
3451
|
+
if (main.constructor === pre.constructor && !(main instanceof TmplAstTimerDeferredTrigger)) {
|
|
3452
|
+
const kind = main instanceof TmplAstImmediateDeferredTrigger ? "immediate" : main.constructor.name.replace("DeferredTrigger", "").toLowerCase();
|
|
3453
|
+
const msg = `Prefetch '${kind}' matches the main trigger and provides no benefit. Remove the prefetch modifier.`;
|
|
3454
|
+
diags.push(ctx.makeTemplateDiagnostic(pre.sourceSpan ?? node.sourceSpan, msg));
|
|
3455
|
+
}
|
|
3456
|
+
}
|
|
3457
|
+
}
|
|
3458
|
+
return diags;
|
|
3459
|
+
}
|
|
3460
|
+
};
|
|
3461
|
+
var factory16 = {
|
|
3462
|
+
code: ErrorCode.DEFER_TRIGGER_MISCONFIGURATION,
|
|
3463
|
+
name: ExtendedTemplateDiagnosticName.DEFER_TRIGGER_MISCONFIGURATION,
|
|
3464
|
+
create: () => new DeferTriggerMisconfiguration()
|
|
3465
|
+
};
|
|
3466
3466
|
|
|
3467
3467
|
// packages/compiler-cli/src/ngtsc/typecheck/extended/src/extended_template_checker.js
|
|
3468
|
+
import ts21 from "typescript";
|
|
3468
3469
|
var ExtendedTemplateCheckerImpl = class {
|
|
3469
3470
|
partialCtx;
|
|
3470
3471
|
templateChecks;
|
|
3471
3472
|
constructor(templateTypeChecker, typeChecker, templateCheckFactories, options) {
|
|
3472
3473
|
this.partialCtx = { templateTypeChecker, typeChecker };
|
|
3473
3474
|
this.templateChecks = /* @__PURE__ */ new Map();
|
|
3474
|
-
for (const
|
|
3475
|
-
const category = diagnosticLabelToCategory(options?.extendedDiagnostics?.checks?.[
|
|
3475
|
+
for (const factory17 of templateCheckFactories) {
|
|
3476
|
+
const category = diagnosticLabelToCategory(options?.extendedDiagnostics?.checks?.[factory17.name] ?? options?.extendedDiagnostics?.defaultCategory ?? DiagnosticCategoryLabel.Warning);
|
|
3476
3477
|
if (category === null) {
|
|
3477
3478
|
continue;
|
|
3478
3479
|
}
|
|
3479
|
-
const check =
|
|
3480
|
+
const check = factory17.create(options);
|
|
3480
3481
|
if (check === null) {
|
|
3481
3482
|
continue;
|
|
3482
3483
|
}
|
|
@@ -3536,12 +3537,13 @@ var ALL_DIAGNOSTIC_FACTORIES = [
|
|
|
3536
3537
|
factory8,
|
|
3537
3538
|
factory12,
|
|
3538
3539
|
factory14,
|
|
3539
|
-
factory15
|
|
3540
|
+
factory15,
|
|
3541
|
+
factory16
|
|
3540
3542
|
];
|
|
3541
3543
|
var SUPPORTED_DIAGNOSTIC_NAMES = /* @__PURE__ */ new Set([
|
|
3542
3544
|
ExtendedTemplateDiagnosticName.CONTROL_FLOW_PREVENTING_CONTENT_PROJECTION,
|
|
3543
3545
|
ExtendedTemplateDiagnosticName.UNUSED_STANDALONE_IMPORTS,
|
|
3544
|
-
...ALL_DIAGNOSTIC_FACTORIES.map((
|
|
3546
|
+
...ALL_DIAGNOSTIC_FACTORIES.map((factory17) => factory17.name)
|
|
3545
3547
|
]);
|
|
3546
3548
|
|
|
3547
3549
|
// packages/compiler-cli/src/ngtsc/typecheck/template_semantics/src/template_semantics_checker.js
|
|
@@ -3791,12 +3793,77 @@ function closestNode(start, predicate) {
|
|
|
3791
3793
|
return null;
|
|
3792
3794
|
}
|
|
3793
3795
|
|
|
3796
|
+
// packages/compiler-cli/src/ngtsc/validation/src/rules/forbidden_required_initializer_invocation_rule.js
|
|
3797
|
+
import ts25 from "typescript";
|
|
3798
|
+
var APIS_TO_CHECK2 = [
|
|
3799
|
+
INPUT_INITIALIZER_FN,
|
|
3800
|
+
MODEL_INITIALIZER_FN,
|
|
3801
|
+
...QUERY_INITIALIZER_FNS
|
|
3802
|
+
];
|
|
3803
|
+
var ForbiddenRequiredInitializersInvocationRule = class {
|
|
3804
|
+
reflector;
|
|
3805
|
+
importedSymbolsTracker;
|
|
3806
|
+
constructor(reflector, importedSymbolsTracker) {
|
|
3807
|
+
this.reflector = reflector;
|
|
3808
|
+
this.importedSymbolsTracker = importedSymbolsTracker;
|
|
3809
|
+
}
|
|
3810
|
+
shouldCheck(sourceFile) {
|
|
3811
|
+
return APIS_TO_CHECK2.some(({ functionName, owningModule }) => {
|
|
3812
|
+
return this.importedSymbolsTracker.hasNamedImport(sourceFile, functionName, owningModule) || this.importedSymbolsTracker.hasNamespaceImport(sourceFile, owningModule);
|
|
3813
|
+
});
|
|
3814
|
+
}
|
|
3815
|
+
checkNode(node) {
|
|
3816
|
+
if (!ts25.isClassDeclaration(node))
|
|
3817
|
+
return null;
|
|
3818
|
+
const requiredInitializerDeclarations = node.members.filter((m) => ts25.isPropertyDeclaration(m) && this.isPropDeclarationARequiredInitializer(m));
|
|
3819
|
+
const diagnostics = [];
|
|
3820
|
+
for (let decl of node.members) {
|
|
3821
|
+
if (!ts25.isPropertyDeclaration(decl))
|
|
3822
|
+
continue;
|
|
3823
|
+
const initiallizerExpr = decl.initializer;
|
|
3824
|
+
if (!initiallizerExpr)
|
|
3825
|
+
continue;
|
|
3826
|
+
checkForbiddenInvocation(initiallizerExpr);
|
|
3827
|
+
}
|
|
3828
|
+
function checkForbiddenInvocation(node2) {
|
|
3829
|
+
if (ts25.isArrowFunction(node2) || ts25.isFunctionExpression(node2))
|
|
3830
|
+
return;
|
|
3831
|
+
if (ts25.isPropertyAccessExpression(node2) && node2.expression.kind === ts25.SyntaxKind.ThisKeyword && // With the following we make sure we only flag invoked required initializers
|
|
3832
|
+
ts25.isCallExpression(node2.parent) && node2.parent.expression === node2) {
|
|
3833
|
+
const requiredProp = requiredInitializerDeclarations.find((prop) => prop.name.getText() === node2.name.getText());
|
|
3834
|
+
if (requiredProp) {
|
|
3835
|
+
const initializerFn = requiredProp.initializer.expression.expression.getText();
|
|
3836
|
+
diagnostics.push(makeDiagnostic(ErrorCode.FORBIDDEN_REQUIRED_INITIALIZER_INVOCATION, node2, `\`${node2.name.getText()}\` is a required \`${initializerFn}\` and does not have a value in this context.`));
|
|
3837
|
+
}
|
|
3838
|
+
}
|
|
3839
|
+
return node2.forEachChild(checkForbiddenInvocation);
|
|
3840
|
+
}
|
|
3841
|
+
const ctor = getConstructorFromClass(node);
|
|
3842
|
+
if (ctor) {
|
|
3843
|
+
checkForbiddenInvocation(ctor);
|
|
3844
|
+
}
|
|
3845
|
+
return diagnostics;
|
|
3846
|
+
}
|
|
3847
|
+
isPropDeclarationARequiredInitializer(node) {
|
|
3848
|
+
if (!node.initializer)
|
|
3849
|
+
return false;
|
|
3850
|
+
const identifiedInitializer = tryParseInitializerApi(APIS_TO_CHECK2, node.initializer, this.reflector, this.importedSymbolsTracker);
|
|
3851
|
+
if (identifiedInitializer === null || !identifiedInitializer.isRequired)
|
|
3852
|
+
return false;
|
|
3853
|
+
return true;
|
|
3854
|
+
}
|
|
3855
|
+
};
|
|
3856
|
+
function getConstructorFromClass(node) {
|
|
3857
|
+
return node.members.find((m) => ts25.isConstructorDeclaration(m) && m.body !== void 0);
|
|
3858
|
+
}
|
|
3859
|
+
|
|
3794
3860
|
// packages/compiler-cli/src/ngtsc/validation/src/source_file_validator.js
|
|
3795
3861
|
var SourceFileValidator = class {
|
|
3796
3862
|
rules;
|
|
3797
3863
|
constructor(reflector, importedSymbolsTracker, templateTypeChecker, typeCheckingConfig) {
|
|
3798
3864
|
this.rules = [new InitializerApiUsageRule(reflector, importedSymbolsTracker)];
|
|
3799
3865
|
this.rules.push(new UnusedStandaloneImportsRule(templateTypeChecker, typeCheckingConfig, importedSymbolsTracker));
|
|
3866
|
+
this.rules.push(new ForbiddenRequiredInitializersInvocationRule(reflector, importedSymbolsTracker));
|
|
3800
3867
|
}
|
|
3801
3868
|
/**
|
|
3802
3869
|
* Gets the diagnostics for a specific file, or null if the file is valid.
|
|
@@ -3986,8 +4053,8 @@ var NgCompiler = class _NgCompiler {
|
|
|
3986
4053
|
this.delegatingPerfRecorder = new DelegatingPerfRecorder(this.perfRecorder);
|
|
3987
4054
|
this.usePoisonedData = usePoisonedData || !!options._compilePoisonedComponents;
|
|
3988
4055
|
this.enableTemplateTypeChecker = enableTemplateTypeChecker || !!options._enableTemplateTypeChecker;
|
|
3989
|
-
this.enableBlockSyntax =
|
|
3990
|
-
this.enableLetSyntax =
|
|
4056
|
+
this.enableBlockSyntax = this.angularCoreVersion === null || coreVersionSupportsFeature(this.angularCoreVersion, ">= 17.0.0");
|
|
4057
|
+
this.enableLetSyntax = this.angularCoreVersion === null || coreVersionSupportsFeature(this.angularCoreVersion, ">= 18.1.0");
|
|
3991
4058
|
this.enableSelectorless = options["_enableSelectorless"] ?? false;
|
|
3992
4059
|
this.emitDeclarationOnly = !!options.emitDeclarationOnly && !!options._experimentalAllowEmitDeclarationOnly;
|
|
3993
4060
|
this.implicitStandaloneValue = this.angularCoreVersion === null || coreVersionSupportsFeature(this.angularCoreVersion, ">= 19.0.0");
|
|
@@ -3996,7 +4063,7 @@ var NgCompiler = class _NgCompiler {
|
|
|
3996
4063
|
this.currentProgram = inputProgram;
|
|
3997
4064
|
this.closureCompilerEnabled = !!this.options.annotateForClosureCompiler;
|
|
3998
4065
|
this.entryPoint = adapter.entryPoint !== null ? getSourceFileOrNull(inputProgram, adapter.entryPoint) : null;
|
|
3999
|
-
const moduleResolutionCache =
|
|
4066
|
+
const moduleResolutionCache = ts26.createModuleResolutionCache(
|
|
4000
4067
|
this.adapter.getCurrentDirectory(),
|
|
4001
4068
|
// doen't retain a reference to `this`, if other closures in the constructor here reference
|
|
4002
4069
|
// `this` internally then a closure created here would retain them. This can cause major
|
|
@@ -4044,7 +4111,7 @@ var NgCompiler = class _NgCompiler {
|
|
|
4044
4111
|
}
|
|
4045
4112
|
for (const clazz of classesToUpdate) {
|
|
4046
4113
|
this.compilation.traitCompiler.updateResources(clazz);
|
|
4047
|
-
if (!
|
|
4114
|
+
if (!ts26.isClassDeclaration(clazz)) {
|
|
4048
4115
|
continue;
|
|
4049
4116
|
}
|
|
4050
4117
|
this.compilation.templateTypeChecker.invalidateClass(clazz);
|
|
@@ -4254,12 +4321,12 @@ var NgCompiler = class _NgCompiler {
|
|
|
4254
4321
|
if (compilation.supportJitMode && compilation.jitDeclarationRegistry.jitDeclarations.size > 0) {
|
|
4255
4322
|
const { jitDeclarations } = compilation.jitDeclarationRegistry;
|
|
4256
4323
|
const jitDeclarationsArray = Array.from(jitDeclarations);
|
|
4257
|
-
const jitDeclarationOriginalNodes = new Set(jitDeclarationsArray.map((d) =>
|
|
4324
|
+
const jitDeclarationOriginalNodes = new Set(jitDeclarationsArray.map((d) => ts26.getOriginalNode(d)));
|
|
4258
4325
|
const sourceFilesWithJit = new Set(jitDeclarationsArray.map((d) => d.getSourceFile().fileName));
|
|
4259
4326
|
before.push((ctx) => {
|
|
4260
4327
|
const reflectionHost = new TypeScriptReflectionHost(this.inputProgram.getTypeChecker());
|
|
4261
4328
|
const jitTransform = angularJitApplicationTransform(this.inputProgram, compilation.isCore, (node) => {
|
|
4262
|
-
node =
|
|
4329
|
+
node = ts26.getOriginalNode(node, ts26.isClassDeclaration);
|
|
4263
4330
|
return reflectionHost.isClass(node) && jitDeclarationOriginalNodes.has(node);
|
|
4264
4331
|
})(ctx);
|
|
4265
4332
|
return (sourceFile) => {
|
|
@@ -4338,16 +4405,16 @@ var NgCompiler = class _NgCompiler {
|
|
|
4338
4405
|
return null;
|
|
4339
4406
|
}
|
|
4340
4407
|
const sourceFile = node.getSourceFile();
|
|
4341
|
-
const printer =
|
|
4342
|
-
const nodeText = printer.printNode(
|
|
4343
|
-
return
|
|
4408
|
+
const printer = ts26.createPrinter();
|
|
4409
|
+
const nodeText = printer.printNode(ts26.EmitHint.Unspecified, callback, sourceFile);
|
|
4410
|
+
return ts26.transpileModule(nodeText, {
|
|
4344
4411
|
compilerOptions: {
|
|
4345
4412
|
...this.options,
|
|
4346
4413
|
// Some module types can produce additional code (see #60795) whereas we need the
|
|
4347
4414
|
// HMR update module to use a native `export`. Override the `target` and `module`
|
|
4348
4415
|
// to ensure that it looks as expected.
|
|
4349
|
-
module:
|
|
4350
|
-
target:
|
|
4416
|
+
module: ts26.ModuleKind.ES2022,
|
|
4417
|
+
target: ts26.ScriptTarget.ES2022
|
|
4351
4418
|
},
|
|
4352
4419
|
fileName: sourceFile.fileName,
|
|
4353
4420
|
reportDiagnostics: false
|
|
@@ -4663,7 +4730,7 @@ var NgCompiler = class _NgCompiler {
|
|
|
4663
4730
|
const supportJitMode = this.options["supportJitMode"] ?? true;
|
|
4664
4731
|
const supportTestBed = this.options["supportTestBed"] ?? true;
|
|
4665
4732
|
const externalRuntimeStyles = this.options["externalRuntimeStyles"] ?? false;
|
|
4666
|
-
const typeCheckHostBindings = this.options.typeCheckHostBindings ??
|
|
4733
|
+
const typeCheckHostBindings = this.options.typeCheckHostBindings ?? true;
|
|
4667
4734
|
if (supportTestBed === false && compilationMode === CompilationMode.PARTIAL) {
|
|
4668
4735
|
throw new Error('TestBed support ("supportTestBed" option) cannot be disabled in partial compilation mode.');
|
|
4669
4736
|
}
|
|
@@ -4723,18 +4790,18 @@ function isAngularCorePackage(program) {
|
|
|
4723
4790
|
return false;
|
|
4724
4791
|
}
|
|
4725
4792
|
return r3Symbols.statements.some((stmt) => {
|
|
4726
|
-
if (!
|
|
4793
|
+
if (!ts26.isVariableStatement(stmt)) {
|
|
4727
4794
|
return false;
|
|
4728
4795
|
}
|
|
4729
|
-
const modifiers =
|
|
4730
|
-
if (modifiers === void 0 || !modifiers.some((mod) => mod.kind ===
|
|
4796
|
+
const modifiers = ts26.getModifiers(stmt);
|
|
4797
|
+
if (modifiers === void 0 || !modifiers.some((mod) => mod.kind === ts26.SyntaxKind.ExportKeyword)) {
|
|
4731
4798
|
return false;
|
|
4732
4799
|
}
|
|
4733
4800
|
return stmt.declarationList.declarations.some((decl) => {
|
|
4734
|
-
if (!
|
|
4801
|
+
if (!ts26.isIdentifier(decl.name) || decl.name.text !== "ITS_JUST_ANGULAR") {
|
|
4735
4802
|
return false;
|
|
4736
4803
|
}
|
|
4737
|
-
if (decl.initializer === void 0 || decl.initializer.kind !==
|
|
4804
|
+
if (decl.initializer === void 0 || decl.initializer.kind !== ts26.SyntaxKind.TrueKeyword) {
|
|
4738
4805
|
return false;
|
|
4739
4806
|
}
|
|
4740
4807
|
return true;
|
|
@@ -4747,7 +4814,7 @@ function getR3SymbolsFile(program) {
|
|
|
4747
4814
|
function* verifyCompatibleTypeCheckOptions(options) {
|
|
4748
4815
|
if (options.fullTemplateTypeCheck === false && options.strictTemplates === true) {
|
|
4749
4816
|
yield makeConfigDiagnostic({
|
|
4750
|
-
category:
|
|
4817
|
+
category: ts26.DiagnosticCategory.Error,
|
|
4751
4818
|
code: ErrorCode.CONFIG_STRICT_TEMPLATES_IMPLIES_FULL_TEMPLATE_TYPECHECK,
|
|
4752
4819
|
messageText: `
|
|
4753
4820
|
Angular compiler option "strictTemplates" is enabled, however "fullTemplateTypeCheck" is disabled.
|
|
@@ -4766,7 +4833,7 @@ https://angular.dev/tools/cli/template-typecheck
|
|
|
4766
4833
|
}
|
|
4767
4834
|
if (options.extendedDiagnostics && options.strictTemplates === false) {
|
|
4768
4835
|
yield makeConfigDiagnostic({
|
|
4769
|
-
category:
|
|
4836
|
+
category: ts26.DiagnosticCategory.Error,
|
|
4770
4837
|
code: ErrorCode.CONFIG_EXTENDED_DIAGNOSTICS_IMPLIES_STRICT_TEMPLATES,
|
|
4771
4838
|
messageText: `
|
|
4772
4839
|
Angular compiler option "extendedDiagnostics" is configured, however "strictTemplates" is disabled.
|
|
@@ -4783,7 +4850,7 @@ One of the following actions is required:
|
|
|
4783
4850
|
const defaultCategory = options.extendedDiagnostics?.defaultCategory;
|
|
4784
4851
|
if (defaultCategory && !allowedCategoryLabels.includes(defaultCategory)) {
|
|
4785
4852
|
yield makeConfigDiagnostic({
|
|
4786
|
-
category:
|
|
4853
|
+
category: ts26.DiagnosticCategory.Error,
|
|
4787
4854
|
code: ErrorCode.CONFIG_EXTENDED_DIAGNOSTICS_UNKNOWN_CATEGORY_LABEL,
|
|
4788
4855
|
messageText: `
|
|
4789
4856
|
Angular compiler option "extendedDiagnostics.defaultCategory" has an unknown diagnostic category: "${defaultCategory}".
|
|
@@ -4796,7 +4863,7 @@ ${allowedCategoryLabels.join("\n")}
|
|
|
4796
4863
|
for (const [checkName, category] of Object.entries(options.extendedDiagnostics?.checks ?? {})) {
|
|
4797
4864
|
if (!SUPPORTED_DIAGNOSTIC_NAMES.has(checkName)) {
|
|
4798
4865
|
yield makeConfigDiagnostic({
|
|
4799
|
-
category:
|
|
4866
|
+
category: ts26.DiagnosticCategory.Error,
|
|
4800
4867
|
code: ErrorCode.CONFIG_EXTENDED_DIAGNOSTICS_UNKNOWN_CHECK,
|
|
4801
4868
|
messageText: `
|
|
4802
4869
|
Angular compiler option "extendedDiagnostics.checks" has an unknown check: "${checkName}".
|
|
@@ -4808,7 +4875,7 @@ ${Array.from(SUPPORTED_DIAGNOSTIC_NAMES).join("\n")}
|
|
|
4808
4875
|
}
|
|
4809
4876
|
if (!allowedCategoryLabels.includes(category)) {
|
|
4810
4877
|
yield makeConfigDiagnostic({
|
|
4811
|
-
category:
|
|
4878
|
+
category: ts26.DiagnosticCategory.Error,
|
|
4812
4879
|
code: ErrorCode.CONFIG_EXTENDED_DIAGNOSTICS_UNKNOWN_CATEGORY_LABEL,
|
|
4813
4880
|
messageText: `
|
|
4814
4881
|
Angular compiler option "extendedDiagnostics.checks['${checkName}']" has an unknown diagnostic category: "${category}".
|
|
@@ -4826,7 +4893,7 @@ function verifyEmitDeclarationOnly(options) {
|
|
|
4826
4893
|
}
|
|
4827
4894
|
return [
|
|
4828
4895
|
makeConfigDiagnostic({
|
|
4829
|
-
category:
|
|
4896
|
+
category: ts26.DiagnosticCategory.Error,
|
|
4830
4897
|
code: ErrorCode.CONFIG_EMIT_DECLARATION_ONLY_UNSUPPORTED,
|
|
4831
4898
|
messageText: 'TS compiler option "emitDeclarationOnly" is not supported.'
|
|
4832
4899
|
})
|
|
@@ -4851,7 +4918,7 @@ var ReferenceGraphAdapter = class {
|
|
|
4851
4918
|
for (const { node } of references) {
|
|
4852
4919
|
let sourceFile = node.getSourceFile();
|
|
4853
4920
|
if (sourceFile === void 0) {
|
|
4854
|
-
sourceFile =
|
|
4921
|
+
sourceFile = ts26.getOriginalNode(node).getSourceFile();
|
|
4855
4922
|
}
|
|
4856
4923
|
if (sourceFile === void 0 || !isDtsPath(sourceFile.fileName)) {
|
|
4857
4924
|
this.graph.add(source, node);
|
|
@@ -4892,7 +4959,7 @@ function versionMapFromProgram(program, driver) {
|
|
|
4892
4959
|
}
|
|
4893
4960
|
|
|
4894
4961
|
// packages/compiler-cli/src/ngtsc/core/src/host.js
|
|
4895
|
-
import
|
|
4962
|
+
import ts27 from "typescript";
|
|
4896
4963
|
var DelegatingCompilerHost = class {
|
|
4897
4964
|
delegate;
|
|
4898
4965
|
createHash;
|
|
@@ -5031,7 +5098,7 @@ var NgCompilerHost = class _NgCompilerHost extends DelegatingCompilerHost {
|
|
|
5031
5098
|
entryPoint = findFlatIndexEntryPoint(normalizedTsInputFiles);
|
|
5032
5099
|
if (entryPoint === null) {
|
|
5033
5100
|
diagnostics.push({
|
|
5034
|
-
category:
|
|
5101
|
+
category: ts27.DiagnosticCategory.Error,
|
|
5035
5102
|
code: ngErrorCode(ErrorCode.CONFIG_FLAT_MODULE_NO_INDEX),
|
|
5036
5103
|
file: void 0,
|
|
5037
5104
|
start: void 0,
|
|
@@ -5085,501 +5152,31 @@ var NgCompilerHost = class _NgCompilerHost extends DelegatingCompilerHost {
|
|
|
5085
5152
|
return this.fileNameToModuleName !== void 0 ? this : null;
|
|
5086
5153
|
}
|
|
5087
5154
|
createCachedResolveModuleNamesFunction() {
|
|
5088
|
-
const moduleResolutionCache =
|
|
5155
|
+
const moduleResolutionCache = ts27.createModuleResolutionCache(this.getCurrentDirectory(), this.getCanonicalFileName.bind(this));
|
|
5089
5156
|
return (moduleNames, containingFile, reusedNames, redirectedReference, options) => {
|
|
5090
5157
|
return moduleNames.map((moduleName) => {
|
|
5091
|
-
const module =
|
|
5158
|
+
const module = ts27.resolveModuleName(moduleName, containingFile, options, this, moduleResolutionCache, redirectedReference);
|
|
5092
5159
|
return module.resolvedModule;
|
|
5093
5160
|
});
|
|
5094
5161
|
};
|
|
5095
5162
|
}
|
|
5096
5163
|
};
|
|
5097
5164
|
|
|
5098
|
-
// packages/compiler-cli/src/ngtsc/program.js
|
|
5099
|
-
var NgtscProgram = class {
|
|
5100
|
-
options;
|
|
5101
|
-
compiler;
|
|
5102
|
-
/**
|
|
5103
|
-
* The primary TypeScript program, which is used for analysis and emit.
|
|
5104
|
-
*/
|
|
5105
|
-
tsProgram;
|
|
5106
|
-
host;
|
|
5107
|
-
incrementalStrategy;
|
|
5108
|
-
constructor(rootNames, options, delegateHost, oldProgram) {
|
|
5109
|
-
this.options = options;
|
|
5110
|
-
const perfRecorder = ActivePerfRecorder.zeroedToNow();
|
|
5111
|
-
perfRecorder.phase(PerfPhase.Setup);
|
|
5112
|
-
if (!options.disableTypeScriptVersionCheck) {
|
|
5113
|
-
verifySupportedTypeScriptVersion();
|
|
5114
|
-
}
|
|
5115
|
-
if (options.compilationMode === "experimental-local") {
|
|
5116
|
-
options.noEmitOnError = false;
|
|
5117
|
-
}
|
|
5118
|
-
const reuseProgram = oldProgram?.compiler.getCurrentProgram();
|
|
5119
|
-
this.host = NgCompilerHost.wrap(delegateHost, rootNames, options, reuseProgram ?? null);
|
|
5120
|
-
if (reuseProgram !== void 0) {
|
|
5121
|
-
retagAllTsFiles(reuseProgram);
|
|
5122
|
-
}
|
|
5123
|
-
this.tsProgram = perfRecorder.inPhase(PerfPhase.TypeScriptProgramCreate, () => ts27.createProgram(this.host.inputFiles, options, this.host, reuseProgram));
|
|
5124
|
-
perfRecorder.phase(PerfPhase.Unaccounted);
|
|
5125
|
-
perfRecorder.memory(PerfCheckpoint.TypeScriptProgramCreate);
|
|
5126
|
-
this.host.postProgramCreationCleanup();
|
|
5127
|
-
const programDriver = new TsCreateProgramDriver(this.tsProgram, this.host, this.options, this.host.shimExtensionPrefixes);
|
|
5128
|
-
this.incrementalStrategy = oldProgram !== void 0 ? oldProgram.incrementalStrategy.toNextBuildStrategy() : new TrackedIncrementalBuildStrategy();
|
|
5129
|
-
const modifiedResourceFiles = /* @__PURE__ */ new Set();
|
|
5130
|
-
if (this.host.getModifiedResourceFiles !== void 0) {
|
|
5131
|
-
const strings = this.host.getModifiedResourceFiles();
|
|
5132
|
-
if (strings !== void 0) {
|
|
5133
|
-
for (const fileString of strings) {
|
|
5134
|
-
modifiedResourceFiles.add(absoluteFrom(fileString));
|
|
5135
|
-
}
|
|
5136
|
-
}
|
|
5137
|
-
}
|
|
5138
|
-
let ticket;
|
|
5139
|
-
if (oldProgram === void 0) {
|
|
5140
|
-
ticket = freshCompilationTicket(
|
|
5141
|
-
this.tsProgram,
|
|
5142
|
-
options,
|
|
5143
|
-
this.incrementalStrategy,
|
|
5144
|
-
programDriver,
|
|
5145
|
-
perfRecorder,
|
|
5146
|
-
/* enableTemplateTypeChecker */
|
|
5147
|
-
false,
|
|
5148
|
-
/* usePoisonedData */
|
|
5149
|
-
false
|
|
5150
|
-
);
|
|
5151
|
-
} else {
|
|
5152
|
-
ticket = incrementalFromCompilerTicket(oldProgram.compiler, this.tsProgram, this.incrementalStrategy, programDriver, modifiedResourceFiles, perfRecorder);
|
|
5153
|
-
}
|
|
5154
|
-
this.compiler = NgCompiler.fromTicket(ticket, this.host);
|
|
5155
|
-
}
|
|
5156
|
-
getTsProgram() {
|
|
5157
|
-
return this.tsProgram;
|
|
5158
|
-
}
|
|
5159
|
-
getReuseTsProgram() {
|
|
5160
|
-
return this.compiler.getCurrentProgram();
|
|
5161
|
-
}
|
|
5162
|
-
getTsOptionDiagnostics(cancellationToken) {
|
|
5163
|
-
return this.compiler.perfRecorder.inPhase(PerfPhase.TypeScriptDiagnostics, () => this.tsProgram.getOptionsDiagnostics(cancellationToken));
|
|
5164
|
-
}
|
|
5165
|
-
getTsSyntacticDiagnostics(sourceFile, cancellationToken) {
|
|
5166
|
-
return this.compiler.perfRecorder.inPhase(PerfPhase.TypeScriptDiagnostics, () => {
|
|
5167
|
-
const ignoredFiles = this.compiler.ignoreForDiagnostics;
|
|
5168
|
-
let res;
|
|
5169
|
-
if (sourceFile !== void 0) {
|
|
5170
|
-
if (ignoredFiles.has(sourceFile)) {
|
|
5171
|
-
return [];
|
|
5172
|
-
}
|
|
5173
|
-
res = this.tsProgram.getSyntacticDiagnostics(sourceFile, cancellationToken);
|
|
5174
|
-
} else {
|
|
5175
|
-
const diagnostics = [];
|
|
5176
|
-
for (const sf of this.tsProgram.getSourceFiles()) {
|
|
5177
|
-
if (!ignoredFiles.has(sf)) {
|
|
5178
|
-
diagnostics.push(...this.tsProgram.getSyntacticDiagnostics(sf, cancellationToken));
|
|
5179
|
-
}
|
|
5180
|
-
}
|
|
5181
|
-
res = diagnostics;
|
|
5182
|
-
}
|
|
5183
|
-
return res;
|
|
5184
|
-
});
|
|
5185
|
-
}
|
|
5186
|
-
getTsSemanticDiagnostics(sourceFile, cancellationToken) {
|
|
5187
|
-
if (this.options.compilationMode === "experimental-local") {
|
|
5188
|
-
return [];
|
|
5189
|
-
}
|
|
5190
|
-
return this.compiler.perfRecorder.inPhase(PerfPhase.TypeScriptDiagnostics, () => {
|
|
5191
|
-
const ignoredFiles = this.compiler.ignoreForDiagnostics;
|
|
5192
|
-
let res;
|
|
5193
|
-
if (sourceFile !== void 0) {
|
|
5194
|
-
if (ignoredFiles.has(sourceFile)) {
|
|
5195
|
-
return [];
|
|
5196
|
-
}
|
|
5197
|
-
res = this.tsProgram.getSemanticDiagnostics(sourceFile, cancellationToken);
|
|
5198
|
-
} else {
|
|
5199
|
-
const diagnostics = [];
|
|
5200
|
-
for (const sf of this.tsProgram.getSourceFiles()) {
|
|
5201
|
-
if (!ignoredFiles.has(sf)) {
|
|
5202
|
-
diagnostics.push(...this.tsProgram.getSemanticDiagnostics(sf, cancellationToken));
|
|
5203
|
-
}
|
|
5204
|
-
}
|
|
5205
|
-
res = diagnostics;
|
|
5206
|
-
}
|
|
5207
|
-
return res;
|
|
5208
|
-
});
|
|
5209
|
-
}
|
|
5210
|
-
getNgOptionDiagnostics(cancellationToken) {
|
|
5211
|
-
return this.compiler.getOptionDiagnostics();
|
|
5212
|
-
}
|
|
5213
|
-
getNgStructuralDiagnostics(cancellationToken) {
|
|
5214
|
-
return [];
|
|
5215
|
-
}
|
|
5216
|
-
getNgSemanticDiagnostics(fileName, cancellationToken) {
|
|
5217
|
-
let sf = void 0;
|
|
5218
|
-
if (fileName !== void 0) {
|
|
5219
|
-
sf = this.tsProgram.getSourceFile(fileName);
|
|
5220
|
-
if (sf === void 0) {
|
|
5221
|
-
return [];
|
|
5222
|
-
}
|
|
5223
|
-
}
|
|
5224
|
-
if (sf === void 0) {
|
|
5225
|
-
return this.compiler.getDiagnostics();
|
|
5226
|
-
} else {
|
|
5227
|
-
return this.compiler.getDiagnosticsForFile(sf, OptimizeFor.WholeProgram);
|
|
5228
|
-
}
|
|
5229
|
-
}
|
|
5230
|
-
/**
|
|
5231
|
-
* Ensure that the `NgCompiler` has properly analyzed the program, and allow for the asynchronous
|
|
5232
|
-
* loading of any resources during the process.
|
|
5233
|
-
*
|
|
5234
|
-
* This is used by the Angular CLI to allow for spawning (async) child compilations for things
|
|
5235
|
-
* like SASS files used in `styleUrls`.
|
|
5236
|
-
*/
|
|
5237
|
-
loadNgStructureAsync() {
|
|
5238
|
-
return this.compiler.analyzeAsync();
|
|
5239
|
-
}
|
|
5240
|
-
listLazyRoutes(entryRoute) {
|
|
5241
|
-
return [];
|
|
5242
|
-
}
|
|
5243
|
-
emitXi18n() {
|
|
5244
|
-
const ctx = new MessageBundle(new HtmlParser(), [], {}, this.options.i18nOutLocale ?? null, this.options.i18nPreserveWhitespaceForLegacyExtraction);
|
|
5245
|
-
this.compiler.xi18n(ctx);
|
|
5246
|
-
i18nExtract(this.options.i18nOutFormat ?? null, this.options.i18nOutFile ?? null, this.host, this.options, ctx, resolve);
|
|
5247
|
-
}
|
|
5248
|
-
emit(opts) {
|
|
5249
|
-
if (opts !== void 0 && opts.emitFlags !== void 0 && opts.emitFlags & EmitFlags.I18nBundle) {
|
|
5250
|
-
this.emitXi18n();
|
|
5251
|
-
if (!(opts.emitFlags & EmitFlags.JS)) {
|
|
5252
|
-
return {
|
|
5253
|
-
diagnostics: [],
|
|
5254
|
-
emitSkipped: true,
|
|
5255
|
-
emittedFiles: []
|
|
5256
|
-
};
|
|
5257
|
-
}
|
|
5258
|
-
}
|
|
5259
|
-
const forceEmit = opts?.forceEmit ?? false;
|
|
5260
|
-
this.compiler.perfRecorder.memory(PerfCheckpoint.PreEmit);
|
|
5261
|
-
const res = this.compiler.perfRecorder.inPhase(PerfPhase.TypeScriptEmit, () => {
|
|
5262
|
-
const { transformers } = this.compiler.prepareEmit();
|
|
5263
|
-
const ignoreFiles = this.compiler.ignoreForEmit;
|
|
5264
|
-
const emitCallback = opts?.emitCallback ?? defaultEmitCallback;
|
|
5265
|
-
const writeFile = (fileName, data, writeByteOrderMark, onError, sourceFiles) => {
|
|
5266
|
-
if (sourceFiles !== void 0) {
|
|
5267
|
-
for (const writtenSf of sourceFiles) {
|
|
5268
|
-
if (writtenSf.isDeclarationFile) {
|
|
5269
|
-
continue;
|
|
5270
|
-
}
|
|
5271
|
-
this.compiler.incrementalCompilation.recordSuccessfulEmit(writtenSf);
|
|
5272
|
-
}
|
|
5273
|
-
}
|
|
5274
|
-
this.host.writeFile(fileName, data, writeByteOrderMark, onError, sourceFiles);
|
|
5275
|
-
};
|
|
5276
|
-
const customTransforms = opts && opts.customTransformers;
|
|
5277
|
-
const beforeTransforms = transformers.before || [];
|
|
5278
|
-
const afterDeclarationsTransforms = transformers.afterDeclarations;
|
|
5279
|
-
if (customTransforms !== void 0 && customTransforms.beforeTs !== void 0) {
|
|
5280
|
-
beforeTransforms.push(...customTransforms.beforeTs);
|
|
5281
|
-
}
|
|
5282
|
-
const emitResults = [];
|
|
5283
|
-
for (const targetSourceFile of this.tsProgram.getSourceFiles()) {
|
|
5284
|
-
if (targetSourceFile.isDeclarationFile || ignoreFiles.has(targetSourceFile)) {
|
|
5285
|
-
continue;
|
|
5286
|
-
}
|
|
5287
|
-
if (!forceEmit && this.compiler.incrementalCompilation.safeToSkipEmit(targetSourceFile)) {
|
|
5288
|
-
this.compiler.perfRecorder.eventCount(PerfEvent.EmitSkipSourceFile);
|
|
5289
|
-
continue;
|
|
5290
|
-
}
|
|
5291
|
-
this.compiler.perfRecorder.eventCount(PerfEvent.EmitSourceFile);
|
|
5292
|
-
emitResults.push(emitCallback({
|
|
5293
|
-
targetSourceFile,
|
|
5294
|
-
program: this.tsProgram,
|
|
5295
|
-
host: this.host,
|
|
5296
|
-
options: this.options,
|
|
5297
|
-
emitOnlyDtsFiles: false,
|
|
5298
|
-
writeFile,
|
|
5299
|
-
customTransformers: {
|
|
5300
|
-
before: beforeTransforms,
|
|
5301
|
-
after: customTransforms && customTransforms.afterTs,
|
|
5302
|
-
afterDeclarations: afterDeclarationsTransforms
|
|
5303
|
-
}
|
|
5304
|
-
}));
|
|
5305
|
-
}
|
|
5306
|
-
this.compiler.perfRecorder.memory(PerfCheckpoint.Emit);
|
|
5307
|
-
return (opts && opts.mergeEmitResultsCallback || mergeEmitResults)(emitResults);
|
|
5308
|
-
});
|
|
5309
|
-
if (this.options.tracePerformance !== void 0) {
|
|
5310
|
-
const perf = this.compiler.perfRecorder.finalize();
|
|
5311
|
-
getFileSystem().writeFile(getFileSystem().resolve(this.options.tracePerformance), JSON.stringify(perf, null, 2));
|
|
5312
|
-
}
|
|
5313
|
-
return res;
|
|
5314
|
-
}
|
|
5315
|
-
getIndexedComponents() {
|
|
5316
|
-
return this.compiler.getIndexedComponents();
|
|
5317
|
-
}
|
|
5318
|
-
/**
|
|
5319
|
-
* Gets information for the current program that may be used to generate API
|
|
5320
|
-
* reference documentation. This includes Angular-specific information, such
|
|
5321
|
-
* as component inputs and outputs.
|
|
5322
|
-
*
|
|
5323
|
-
* @param entryPoint Path to the entry point for the package for which API
|
|
5324
|
-
* docs should be extracted.
|
|
5325
|
-
*/
|
|
5326
|
-
getApiDocumentation(entryPoint, privateModules) {
|
|
5327
|
-
return this.compiler.getApiDocumentation(entryPoint, privateModules);
|
|
5328
|
-
}
|
|
5329
|
-
getEmittedSourceFiles() {
|
|
5330
|
-
throw new Error("Method not implemented.");
|
|
5331
|
-
}
|
|
5332
|
-
};
|
|
5333
|
-
var defaultEmitCallback = ({ program, targetSourceFile, writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers }) => program.emit(targetSourceFile, writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers);
|
|
5334
|
-
function mergeEmitResults(emitResults) {
|
|
5335
|
-
const diagnostics = [];
|
|
5336
|
-
let emitSkipped = false;
|
|
5337
|
-
const emittedFiles = [];
|
|
5338
|
-
for (const er of emitResults) {
|
|
5339
|
-
diagnostics.push(...er.diagnostics);
|
|
5340
|
-
emitSkipped = emitSkipped || er.emitSkipped;
|
|
5341
|
-
emittedFiles.push(...er.emittedFiles || []);
|
|
5342
|
-
}
|
|
5343
|
-
return { diagnostics, emitSkipped, emittedFiles };
|
|
5344
|
-
}
|
|
5345
|
-
|
|
5346
|
-
// packages/compiler-cli/src/transformers/program.js
|
|
5347
|
-
function createProgram({ rootNames, options, host, oldProgram }) {
|
|
5348
|
-
return new NgtscProgram(rootNames, options, host, oldProgram);
|
|
5349
|
-
}
|
|
5350
|
-
|
|
5351
|
-
// packages/compiler-cli/src/perform_compile.js
|
|
5352
|
-
import ts29 from "typescript";
|
|
5353
|
-
|
|
5354
|
-
// packages/compiler-cli/src/transformers/util.js
|
|
5355
|
-
import ts28 from "typescript";
|
|
5356
|
-
function createMessageDiagnostic(messageText) {
|
|
5357
|
-
return {
|
|
5358
|
-
file: void 0,
|
|
5359
|
-
start: void 0,
|
|
5360
|
-
length: void 0,
|
|
5361
|
-
category: ts28.DiagnosticCategory.Message,
|
|
5362
|
-
messageText,
|
|
5363
|
-
code: DEFAULT_ERROR_CODE,
|
|
5364
|
-
source: SOURCE
|
|
5365
|
-
};
|
|
5366
|
-
}
|
|
5367
|
-
|
|
5368
|
-
// packages/compiler-cli/src/perform_compile.js
|
|
5369
|
-
var defaultFormatHost = {
|
|
5370
|
-
getCurrentDirectory: () => ts29.sys.getCurrentDirectory(),
|
|
5371
|
-
getCanonicalFileName: (fileName) => fileName,
|
|
5372
|
-
getNewLine: () => ts29.sys.newLine
|
|
5373
|
-
};
|
|
5374
|
-
function formatDiagnostics(diags, host = defaultFormatHost) {
|
|
5375
|
-
if (diags && diags.length) {
|
|
5376
|
-
return diags.map((diagnostic) => replaceTsWithNgInErrors(ts29.formatDiagnosticsWithColorAndContext([diagnostic], host))).join("");
|
|
5377
|
-
} else {
|
|
5378
|
-
return "";
|
|
5379
|
-
}
|
|
5380
|
-
}
|
|
5381
|
-
function calcProjectFileAndBasePath(project, host = getFileSystem()) {
|
|
5382
|
-
const absProject = host.resolve(project);
|
|
5383
|
-
const projectIsDir = host.lstat(absProject).isDirectory();
|
|
5384
|
-
const projectFile = projectIsDir ? host.join(absProject, "tsconfig.json") : absProject;
|
|
5385
|
-
const projectDir = projectIsDir ? absProject : host.dirname(absProject);
|
|
5386
|
-
const basePath = host.resolve(projectDir);
|
|
5387
|
-
return { projectFile, basePath };
|
|
5388
|
-
}
|
|
5389
|
-
function readConfiguration(project, existingOptions, host = getFileSystem()) {
|
|
5390
|
-
try {
|
|
5391
|
-
const fs = getFileSystem();
|
|
5392
|
-
const readConfigFile = (configFile) => ts29.readConfigFile(configFile, (file) => host.readFile(host.resolve(file)));
|
|
5393
|
-
const readAngularCompilerOptions = (configFile, parentOptions = {}) => {
|
|
5394
|
-
const { config: config2, error: error2 } = readConfigFile(configFile);
|
|
5395
|
-
if (error2) {
|
|
5396
|
-
return parentOptions;
|
|
5397
|
-
}
|
|
5398
|
-
const angularCompilerOptions = config2.angularCompilerOptions ?? config2.bazelOptions?.angularCompilerOptions;
|
|
5399
|
-
let existingNgCompilerOptions = { ...angularCompilerOptions, ...parentOptions };
|
|
5400
|
-
if (!config2.extends) {
|
|
5401
|
-
return existingNgCompilerOptions;
|
|
5402
|
-
}
|
|
5403
|
-
const extendsPaths = typeof config2.extends === "string" ? [config2.extends] : config2.extends;
|
|
5404
|
-
return [...extendsPaths].reverse().reduce((prevOptions, extendsPath) => {
|
|
5405
|
-
const extendedConfigPath = getExtendedConfigPath(configFile, extendsPath, host, fs);
|
|
5406
|
-
return extendedConfigPath === null ? prevOptions : readAngularCompilerOptions(extendedConfigPath, prevOptions);
|
|
5407
|
-
}, existingNgCompilerOptions);
|
|
5408
|
-
};
|
|
5409
|
-
const { projectFile, basePath } = calcProjectFileAndBasePath(project, host);
|
|
5410
|
-
const configFileName = host.resolve(host.pwd(), projectFile);
|
|
5411
|
-
const { config, error } = readConfigFile(projectFile);
|
|
5412
|
-
if (error) {
|
|
5413
|
-
return {
|
|
5414
|
-
project,
|
|
5415
|
-
errors: [error],
|
|
5416
|
-
rootNames: [],
|
|
5417
|
-
options: {},
|
|
5418
|
-
emitFlags: EmitFlags.Default
|
|
5419
|
-
};
|
|
5420
|
-
}
|
|
5421
|
-
const existingCompilerOptions = {
|
|
5422
|
-
genDir: basePath,
|
|
5423
|
-
basePath,
|
|
5424
|
-
...readAngularCompilerOptions(configFileName),
|
|
5425
|
-
...existingOptions
|
|
5426
|
-
};
|
|
5427
|
-
const parseConfigHost = createParseConfigHost(host, fs);
|
|
5428
|
-
const { options, errors, fileNames: rootNames, projectReferences } = ts29.parseJsonConfigFileContent(config, parseConfigHost, basePath, existingCompilerOptions, configFileName);
|
|
5429
|
-
let emitFlags = EmitFlags.Default;
|
|
5430
|
-
if (!(options["skipMetadataEmit"] || options["flatModuleOutFile"])) {
|
|
5431
|
-
emitFlags |= EmitFlags.Metadata;
|
|
5432
|
-
}
|
|
5433
|
-
if (options["skipTemplateCodegen"]) {
|
|
5434
|
-
emitFlags = emitFlags & ~EmitFlags.Codegen;
|
|
5435
|
-
}
|
|
5436
|
-
return { project: projectFile, rootNames, projectReferences, options, errors, emitFlags };
|
|
5437
|
-
} catch (e) {
|
|
5438
|
-
const errors = [
|
|
5439
|
-
{
|
|
5440
|
-
category: ts29.DiagnosticCategory.Error,
|
|
5441
|
-
messageText: e.stack ?? e.message,
|
|
5442
|
-
file: void 0,
|
|
5443
|
-
start: void 0,
|
|
5444
|
-
length: void 0,
|
|
5445
|
-
source: "angular",
|
|
5446
|
-
code: UNKNOWN_ERROR_CODE
|
|
5447
|
-
}
|
|
5448
|
-
];
|
|
5449
|
-
return { project: "", errors, rootNames: [], options: {}, emitFlags: EmitFlags.Default };
|
|
5450
|
-
}
|
|
5451
|
-
}
|
|
5452
|
-
function createParseConfigHost(host, fs = getFileSystem()) {
|
|
5453
|
-
return {
|
|
5454
|
-
fileExists: host.exists.bind(host),
|
|
5455
|
-
readDirectory: createFileSystemTsReadDirectoryFn(fs),
|
|
5456
|
-
readFile: host.readFile.bind(host),
|
|
5457
|
-
useCaseSensitiveFileNames: fs.isCaseSensitive()
|
|
5458
|
-
};
|
|
5459
|
-
}
|
|
5460
|
-
function getExtendedConfigPath(configFile, extendsValue, host, fs) {
|
|
5461
|
-
const result = getExtendedConfigPathWorker(configFile, extendsValue, host, fs);
|
|
5462
|
-
if (result !== null) {
|
|
5463
|
-
return result;
|
|
5464
|
-
}
|
|
5465
|
-
return getExtendedConfigPathWorker(configFile, `${extendsValue}.json`, host, fs);
|
|
5466
|
-
}
|
|
5467
|
-
function getExtendedConfigPathWorker(configFile, extendsValue, host, fs) {
|
|
5468
|
-
if (extendsValue.startsWith(".") || fs.isRooted(extendsValue)) {
|
|
5469
|
-
const extendedConfigPath = host.resolve(host.dirname(configFile), extendsValue);
|
|
5470
|
-
if (host.exists(extendedConfigPath)) {
|
|
5471
|
-
return extendedConfigPath;
|
|
5472
|
-
}
|
|
5473
|
-
} else {
|
|
5474
|
-
const parseConfigHost = createParseConfigHost(host, fs);
|
|
5475
|
-
const { resolvedModule } = ts29.nodeModuleNameResolver(extendsValue, configFile, { moduleResolution: ts29.ModuleResolutionKind.Node10, resolveJsonModule: true }, parseConfigHost);
|
|
5476
|
-
if (resolvedModule) {
|
|
5477
|
-
return absoluteFrom(resolvedModule.resolvedFileName);
|
|
5478
|
-
}
|
|
5479
|
-
}
|
|
5480
|
-
return null;
|
|
5481
|
-
}
|
|
5482
|
-
function exitCodeFromResult(diags) {
|
|
5483
|
-
if (!diags)
|
|
5484
|
-
return 0;
|
|
5485
|
-
if (diags.every((diag) => diag.category !== ts29.DiagnosticCategory.Error)) {
|
|
5486
|
-
return 0;
|
|
5487
|
-
}
|
|
5488
|
-
return diags.some((d) => d.source === "angular" && d.code === UNKNOWN_ERROR_CODE) ? 2 : 1;
|
|
5489
|
-
}
|
|
5490
|
-
function performCompilation({ rootNames, options, host, oldProgram, emitCallback, mergeEmitResultsCallback, gatherDiagnostics = defaultGatherDiagnostics, customTransformers, emitFlags = EmitFlags.Default, forceEmit = false, modifiedResourceFiles = null }) {
|
|
5491
|
-
let program;
|
|
5492
|
-
let emitResult;
|
|
5493
|
-
let allDiagnostics = [];
|
|
5494
|
-
try {
|
|
5495
|
-
if (!host) {
|
|
5496
|
-
host = createCompilerHost({ options });
|
|
5497
|
-
}
|
|
5498
|
-
if (modifiedResourceFiles) {
|
|
5499
|
-
host.getModifiedResourceFiles = () => modifiedResourceFiles;
|
|
5500
|
-
}
|
|
5501
|
-
program = createProgram({ rootNames, host, options, oldProgram });
|
|
5502
|
-
const beforeDiags = Date.now();
|
|
5503
|
-
allDiagnostics.push(...gatherDiagnostics(program));
|
|
5504
|
-
if (options.diagnostics) {
|
|
5505
|
-
const afterDiags = Date.now();
|
|
5506
|
-
allDiagnostics.push(createMessageDiagnostic(`Time for diagnostics: ${afterDiags - beforeDiags}ms.`));
|
|
5507
|
-
}
|
|
5508
|
-
if (!hasErrors(allDiagnostics)) {
|
|
5509
|
-
emitResult = program.emit({
|
|
5510
|
-
emitCallback,
|
|
5511
|
-
mergeEmitResultsCallback,
|
|
5512
|
-
customTransformers,
|
|
5513
|
-
emitFlags,
|
|
5514
|
-
forceEmit
|
|
5515
|
-
});
|
|
5516
|
-
allDiagnostics.push(...emitResult.diagnostics);
|
|
5517
|
-
return { diagnostics: allDiagnostics, program, emitResult };
|
|
5518
|
-
}
|
|
5519
|
-
return { diagnostics: allDiagnostics, program };
|
|
5520
|
-
} catch (e) {
|
|
5521
|
-
program = void 0;
|
|
5522
|
-
allDiagnostics.push({
|
|
5523
|
-
category: ts29.DiagnosticCategory.Error,
|
|
5524
|
-
messageText: e.stack ?? e.message,
|
|
5525
|
-
code: UNKNOWN_ERROR_CODE,
|
|
5526
|
-
file: void 0,
|
|
5527
|
-
start: void 0,
|
|
5528
|
-
length: void 0
|
|
5529
|
-
});
|
|
5530
|
-
return { diagnostics: allDiagnostics, program };
|
|
5531
|
-
}
|
|
5532
|
-
}
|
|
5533
|
-
function defaultGatherDiagnostics(program) {
|
|
5534
|
-
const allDiagnostics = [];
|
|
5535
|
-
function checkDiagnostics(diags) {
|
|
5536
|
-
if (diags) {
|
|
5537
|
-
allDiagnostics.push(...diags);
|
|
5538
|
-
return !hasErrors(diags);
|
|
5539
|
-
}
|
|
5540
|
-
return true;
|
|
5541
|
-
}
|
|
5542
|
-
let checkOtherDiagnostics = true;
|
|
5543
|
-
checkOtherDiagnostics = checkOtherDiagnostics && checkDiagnostics([...program.getTsOptionDiagnostics(), ...program.getNgOptionDiagnostics()]);
|
|
5544
|
-
checkOtherDiagnostics = checkOtherDiagnostics && checkDiagnostics(program.getTsSyntacticDiagnostics());
|
|
5545
|
-
checkOtherDiagnostics = checkOtherDiagnostics && checkDiagnostics([
|
|
5546
|
-
...program.getTsSemanticDiagnostics(),
|
|
5547
|
-
...program.getNgStructuralDiagnostics()
|
|
5548
|
-
]);
|
|
5549
|
-
checkOtherDiagnostics = checkOtherDiagnostics && checkDiagnostics(program.getNgSemanticDiagnostics());
|
|
5550
|
-
return allDiagnostics;
|
|
5551
|
-
}
|
|
5552
|
-
function hasErrors(diags) {
|
|
5553
|
-
return diags.some((d) => d.category === ts29.DiagnosticCategory.Error);
|
|
5554
|
-
}
|
|
5555
|
-
|
|
5556
5165
|
export {
|
|
5557
|
-
DEFAULT_ERROR_CODE,
|
|
5558
|
-
UNKNOWN_ERROR_CODE,
|
|
5559
|
-
SOURCE,
|
|
5560
|
-
isTsDiagnostic,
|
|
5561
|
-
EmitFlags,
|
|
5562
|
-
createCompilerHost,
|
|
5563
5166
|
EntryType,
|
|
5564
5167
|
MemberType,
|
|
5565
5168
|
DecoratorType,
|
|
5566
5169
|
MemberTags,
|
|
5567
5170
|
isDocEntryWithSourceInfo,
|
|
5568
5171
|
DocsExtractor,
|
|
5172
|
+
TrackedIncrementalBuildStrategy,
|
|
5569
5173
|
PatchedProgramIncrementalBuildStrategy,
|
|
5174
|
+
DiagnosticCategoryLabel,
|
|
5570
5175
|
freshCompilationTicket,
|
|
5176
|
+
incrementalFromCompilerTicket,
|
|
5571
5177
|
incrementalFromStateTicket,
|
|
5572
5178
|
NgCompiler,
|
|
5573
|
-
NgCompilerHost
|
|
5574
|
-
NgtscProgram,
|
|
5575
|
-
createProgram,
|
|
5576
|
-
createMessageDiagnostic,
|
|
5577
|
-
formatDiagnostics,
|
|
5578
|
-
calcProjectFileAndBasePath,
|
|
5579
|
-
readConfiguration,
|
|
5580
|
-
exitCodeFromResult,
|
|
5581
|
-
performCompilation,
|
|
5582
|
-
defaultGatherDiagnostics
|
|
5179
|
+
NgCompilerHost
|
|
5583
5180
|
};
|
|
5584
5181
|
/**
|
|
5585
5182
|
* @license
|