@angular/compiler-cli 21.0.0-next.9 → 21.0.0-rc.1
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-SIOKS4LN.js → chunk-5UJIUEKT.js} +285 -799
- package/bundles/chunk-DBAV4W4V.js +644 -0
- package/bundles/chunk-DT6FD4OE.js +1 -1
- package/bundles/{chunk-3UF7UI6H.js → chunk-VBBJY6IR.js} +17827 -17100
- package/bundles/{chunk-IE2YQNTQ.js → chunk-YVYYMXOI.js} +1 -1
- package/bundles/index.js +18 -18
- package/bundles/private/migrations.js +49 -5
- package/bundles/private/testing.js +526 -0
- package/bundles/private/tooling.js +1 -2
- package/bundles/src/bin/ng_xi18n.js +4 -4
- package/bundles/src/bin/ngc.js +4 -4
- package/index.d.ts +1 -1
- package/linker/src/file_linker/partial_linkers/util.d.ts +1 -1
- package/package.json +5 -13
- package/private/migrations.d.ts +11 -5
- package/private/testing.d.ts +11 -0
- 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 +2 -0
- package/src/ngtsc/docs/src/entities.d.ts +7 -1
- package/src/ngtsc/docs/src/extractor.d.ts +6 -0
- package/src/ngtsc/docs/src/namespace_extractor.d.ts +15 -0
- package/src/ngtsc/docs/src/variable_extractor.d.ts +16 -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/translator.d.ts +1 -1
- package/src/ngtsc/typecheck/src/oob.d.ts +5 -0
- package/bundles/chunk-HRLHX4UA.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-HRLHX4UA.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-VBBJY6IR.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) {
|
|
@@ -149,6 +114,7 @@ var EntryType;
|
|
|
149
114
|
EntryType2["TypeAlias"] = "type_alias";
|
|
150
115
|
EntryType2["UndecoratedClass"] = "undecorated_class";
|
|
151
116
|
EntryType2["InitializerApiFunction"] = "initializer_api_function";
|
|
117
|
+
EntryType2["Namespace"] = "namespace";
|
|
152
118
|
})(EntryType || (EntryType = {}));
|
|
153
119
|
var MemberType;
|
|
154
120
|
(function(MemberType2) {
|
|
@@ -183,41 +149,41 @@ function isDocEntryWithSourceInfo(entry) {
|
|
|
183
149
|
import ts14 from "typescript";
|
|
184
150
|
|
|
185
151
|
// packages/compiler-cli/src/ngtsc/docs/src/class_extractor.js
|
|
186
|
-
import
|
|
152
|
+
import ts6 from "typescript";
|
|
187
153
|
|
|
188
154
|
// packages/compiler-cli/src/ngtsc/docs/src/jsdoc_extractor.js
|
|
189
|
-
import
|
|
155
|
+
import ts from "typescript";
|
|
190
156
|
var decoratorExpression = /@(?=(Injectable|Component|Directive|Pipe|NgModule|Input|Output|HostBinding|HostListener|Inject|Optional|Self|Host|SkipSelf|ViewChild|ViewChildren|ContentChild|ContentChildren))/g;
|
|
191
157
|
function extractJsDocTags(node) {
|
|
192
158
|
const escapedNode = getEscapedNode(node);
|
|
193
|
-
return
|
|
159
|
+
return ts.getJSDocTags(escapedNode).map((t) => {
|
|
194
160
|
return {
|
|
195
161
|
name: t.tagName.getText(),
|
|
196
|
-
comment: unescapeAngularDecorators(
|
|
162
|
+
comment: unescapeAngularDecorators(ts.getTextOfJSDocComment(t.comment) ?? "")
|
|
197
163
|
};
|
|
198
164
|
});
|
|
199
165
|
}
|
|
200
166
|
function extractJsDocDescription(node) {
|
|
201
167
|
const escapedNode = getEscapedNode(node);
|
|
202
|
-
const commentOrTag =
|
|
203
|
-
return
|
|
168
|
+
const commentOrTag = ts.getJSDocCommentsAndTags(escapedNode).find((d) => {
|
|
169
|
+
return ts.isJSDoc(d) || ts.isJSDocParameterTag(d);
|
|
204
170
|
});
|
|
205
171
|
const comment = commentOrTag?.comment ?? "";
|
|
206
|
-
const description = typeof comment === "string" ? comment :
|
|
172
|
+
const description = typeof comment === "string" ? comment : ts.getTextOfJSDocComment(comment) ?? "";
|
|
207
173
|
return unescapeAngularDecorators(description);
|
|
208
174
|
}
|
|
209
175
|
function extractRawJsDoc(node) {
|
|
210
|
-
const comment =
|
|
176
|
+
const comment = ts.getJSDocCommentsAndTags(node).find(ts.isJSDoc)?.getFullText() ?? "";
|
|
211
177
|
return unescapeAngularDecorators(comment);
|
|
212
178
|
}
|
|
213
179
|
function getEscapedNode(node) {
|
|
214
|
-
if (
|
|
180
|
+
if (ts.isParameter(node)) {
|
|
215
181
|
return node;
|
|
216
182
|
}
|
|
217
183
|
const rawComment = extractRawJsDoc(node);
|
|
218
184
|
const escaped = escapeAngularDecorators(rawComment);
|
|
219
|
-
const file =
|
|
220
|
-
return file.statements.find((s) =>
|
|
185
|
+
const file = ts.createSourceFile("x.ts", `${escaped}class X {}`, ts.ScriptTarget.ES2020, true);
|
|
186
|
+
return file.statements.find((s) => ts.isClassDeclaration(s));
|
|
221
187
|
}
|
|
222
188
|
function escapeAngularDecorators(comment) {
|
|
223
189
|
return comment.replace(decoratorExpression, "_NG_AT_");
|
|
@@ -227,7 +193,7 @@ function unescapeAngularDecorators(comment) {
|
|
|
227
193
|
}
|
|
228
194
|
|
|
229
195
|
// packages/compiler-cli/src/ngtsc/docs/src/properties_extractor.js
|
|
230
|
-
import
|
|
196
|
+
import ts5 from "typescript";
|
|
231
197
|
|
|
232
198
|
// packages/compiler-cli/src/ngtsc/docs/src/filters.js
|
|
233
199
|
function isAngularPrivateName(name) {
|
|
@@ -236,7 +202,7 @@ function isAngularPrivateName(name) {
|
|
|
236
202
|
}
|
|
237
203
|
|
|
238
204
|
// packages/compiler-cli/src/ngtsc/docs/src/function_extractor.js
|
|
239
|
-
import
|
|
205
|
+
import ts3 from "typescript";
|
|
240
206
|
|
|
241
207
|
// packages/compiler-cli/src/ngtsc/docs/src/generics_extractor.js
|
|
242
208
|
function extractGenerics(declaration) {
|
|
@@ -248,9 +214,9 @@ function extractGenerics(declaration) {
|
|
|
248
214
|
}
|
|
249
215
|
|
|
250
216
|
// packages/compiler-cli/src/ngtsc/docs/src/type_extractor.js
|
|
251
|
-
import
|
|
217
|
+
import ts2 from "typescript";
|
|
252
218
|
function extractResolvedTypeString(node, checker) {
|
|
253
|
-
return checker.typeToString(checker.getTypeAtLocation(node), void 0,
|
|
219
|
+
return checker.typeToString(checker.getTypeAtLocation(node), void 0, ts2.TypeFormatFlags.NoTruncation);
|
|
254
220
|
}
|
|
255
221
|
|
|
256
222
|
// packages/compiler-cli/src/ngtsc/docs/src/function_extractor.js
|
|
@@ -268,7 +234,7 @@ var FunctionExtractor = class {
|
|
|
268
234
|
const returnType = signature ? extractReturnType(signature, this.typeChecker) : "unknown";
|
|
269
235
|
const implementation = findImplementationOfFunction(this.exportDeclaration, this.typeChecker) ?? this.exportDeclaration;
|
|
270
236
|
const type = this.typeChecker.getTypeAtLocation(this.exportDeclaration);
|
|
271
|
-
const overloads =
|
|
237
|
+
const overloads = ts3.isConstructorDeclaration(this.exportDeclaration) ? constructorOverloads(this.exportDeclaration, this.typeChecker) : extractCallSignatures(this.name, this.typeChecker, type);
|
|
272
238
|
const jsdocsTags = extractJsDocTags(implementation);
|
|
273
239
|
const description = extractJsDocDescription(implementation);
|
|
274
240
|
return {
|
|
@@ -276,7 +242,7 @@ var FunctionExtractor = class {
|
|
|
276
242
|
signatures: overloads,
|
|
277
243
|
implementation: {
|
|
278
244
|
params: extractAllParams(implementation.parameters, this.typeChecker),
|
|
279
|
-
isNewType:
|
|
245
|
+
isNewType: ts3.isConstructSignatureDeclaration(implementation),
|
|
280
246
|
returnType,
|
|
281
247
|
returnDescription: jsdocsTags.find((tag) => tag.name === "returns")?.comment,
|
|
282
248
|
generics: extractGenerics(implementation),
|
|
@@ -296,7 +262,7 @@ var FunctionExtractor = class {
|
|
|
296
262
|
function constructorOverloads(constructorDeclaration, typeChecker) {
|
|
297
263
|
const classDeclaration = constructorDeclaration.parent;
|
|
298
264
|
const constructorNode = classDeclaration.members.filter((member) => {
|
|
299
|
-
return
|
|
265
|
+
return ts3.isConstructorDeclaration(member) && !member.body;
|
|
300
266
|
});
|
|
301
267
|
return constructorNode.map((n) => {
|
|
302
268
|
return {
|
|
@@ -325,7 +291,7 @@ function filterSignatureDeclarations(signatures) {
|
|
|
325
291
|
const result = [];
|
|
326
292
|
for (const signature of signatures) {
|
|
327
293
|
const decl = signature.getDeclaration();
|
|
328
|
-
if (
|
|
294
|
+
if (ts3.isFunctionDeclaration(decl) || ts3.isCallSignatureDeclaration(decl) || ts3.isMethodDeclaration(decl) || ts3.isConstructSignatureDeclaration(decl)) {
|
|
329
295
|
result.push({ signature, decl });
|
|
330
296
|
}
|
|
331
297
|
}
|
|
@@ -345,14 +311,14 @@ function extractCallSignatures(name, typeChecker, type) {
|
|
|
345
311
|
}));
|
|
346
312
|
}
|
|
347
313
|
function extractReturnType(signature, typeChecker) {
|
|
348
|
-
if (signature?.declaration?.type &&
|
|
314
|
+
if (signature?.declaration?.type && ts3.isTypePredicateNode(signature.declaration.type)) {
|
|
349
315
|
return signature.declaration.type.getText();
|
|
350
316
|
}
|
|
351
317
|
return typeChecker.typeToString(
|
|
352
318
|
typeChecker.getReturnTypeOfSignature(signature),
|
|
353
319
|
void 0,
|
|
354
320
|
// This ensures that e.g. `T | undefined` is not reduced to `T`.
|
|
355
|
-
|
|
321
|
+
ts3.TypeFormatFlags.NoTypeReduction | ts3.TypeFormatFlags.NoTruncation
|
|
356
322
|
);
|
|
357
323
|
}
|
|
358
324
|
function findImplementationOfFunction(node, typeChecker) {
|
|
@@ -360,18 +326,18 @@ function findImplementationOfFunction(node, typeChecker) {
|
|
|
360
326
|
return node;
|
|
361
327
|
}
|
|
362
328
|
const symbol = typeChecker.getSymbolAtLocation(node.name);
|
|
363
|
-
const implementation = symbol?.declarations?.find((s) =>
|
|
329
|
+
const implementation = symbol?.declarations?.find((s) => ts3.isFunctionDeclaration(s) && s.body !== void 0);
|
|
364
330
|
return implementation;
|
|
365
331
|
}
|
|
366
332
|
|
|
367
333
|
// packages/compiler-cli/src/ngtsc/docs/src/internal.js
|
|
368
|
-
import
|
|
334
|
+
import ts4 from "typescript";
|
|
369
335
|
function isInternal(member) {
|
|
370
336
|
return extractJsDocTags(member).some((tag) => tag.name === "internal") || hasLeadingInternalComment(member);
|
|
371
337
|
}
|
|
372
338
|
function hasLeadingInternalComment(member) {
|
|
373
339
|
const memberText = member.getSourceFile().text;
|
|
374
|
-
return
|
|
340
|
+
return ts4.reduceEachLeadingCommentRange(
|
|
375
341
|
memberText,
|
|
376
342
|
member.getFullStart(),
|
|
377
343
|
(pos, end, kind, hasTrailingNewLine, containsInternal) => {
|
|
@@ -418,9 +384,9 @@ var PropertiesExtractor = class {
|
|
|
418
384
|
return this.extractMethod(memberDeclaration);
|
|
419
385
|
} else if (this.isProperty(memberDeclaration) && !this.hasPrivateComputedProperty(memberDeclaration)) {
|
|
420
386
|
return this.extractClassProperty(memberDeclaration);
|
|
421
|
-
} else if (
|
|
387
|
+
} else if (ts5.isAccessor(memberDeclaration)) {
|
|
422
388
|
return this.extractGetterSetter(memberDeclaration);
|
|
423
|
-
} else if (
|
|
389
|
+
} else if (ts5.isConstructorDeclaration(memberDeclaration) && memberDeclaration.parameters.length > 0) {
|
|
424
390
|
return this.extractConstructor(memberDeclaration);
|
|
425
391
|
}
|
|
426
392
|
return void 0;
|
|
@@ -440,7 +406,7 @@ var PropertiesExtractor = class {
|
|
|
440
406
|
}
|
|
441
407
|
/** Extracts docs for a signature element (usually inside an interface). */
|
|
442
408
|
extractSignature(signature) {
|
|
443
|
-
const functionExtractor = new FunctionExtractor(
|
|
409
|
+
const functionExtractor = new FunctionExtractor(ts5.isConstructSignatureDeclaration(signature) ? "new" : "", signature, this.typeChecker);
|
|
444
410
|
return {
|
|
445
411
|
...functionExtractor.extract(),
|
|
446
412
|
memberType: MemberType.Method,
|
|
@@ -462,7 +428,7 @@ var PropertiesExtractor = class {
|
|
|
462
428
|
extractGetterSetter(accessor) {
|
|
463
429
|
return {
|
|
464
430
|
...this.extractClassProperty(accessor),
|
|
465
|
-
memberType:
|
|
431
|
+
memberType: ts5.isGetAccessor(accessor) ? MemberType.Getter : MemberType.Setter
|
|
466
432
|
};
|
|
467
433
|
}
|
|
468
434
|
extractConstructor(constructorDeclaration) {
|
|
@@ -474,7 +440,7 @@ var PropertiesExtractor = class {
|
|
|
474
440
|
};
|
|
475
441
|
}
|
|
476
442
|
extractInterfaceConformance(declaration) {
|
|
477
|
-
const implementClause = declaration.heritageClauses?.find((clause) => clause.token ===
|
|
443
|
+
const implementClause = declaration.heritageClauses?.find((clause) => clause.token === ts5.SyntaxKind.ImplementsKeyword);
|
|
478
444
|
return implementClause?.types.map((m) => m.getText()) ?? [];
|
|
479
445
|
}
|
|
480
446
|
/** Gets the tags for a member (protected, readonly, static, etc.) */
|
|
@@ -505,7 +471,7 @@ var PropertiesExtractor = class {
|
|
|
505
471
|
getMemberDeclarations() {
|
|
506
472
|
const type = this.typeChecker.getTypeAtLocation(this.declaration);
|
|
507
473
|
const members = type.getProperties();
|
|
508
|
-
const constructor = type.getSymbol()?.members?.get(
|
|
474
|
+
const constructor = type.getSymbol()?.members?.get(ts5.InternalSymbolName.Constructor);
|
|
509
475
|
const typeOfConstructor = this.typeChecker.getTypeOfSymbol(type.symbol);
|
|
510
476
|
const staticMembers = typeOfConstructor.getProperties();
|
|
511
477
|
const result = [];
|
|
@@ -522,9 +488,9 @@ var PropertiesExtractor = class {
|
|
|
522
488
|
/** The result only contains properties, method implementations and abstracts */
|
|
523
489
|
filterMethodOverloads(declarations) {
|
|
524
490
|
return declarations.filter((declaration, index) => {
|
|
525
|
-
if (
|
|
491
|
+
if (ts5.isFunctionDeclaration(declaration) || ts5.isMethodDeclaration(declaration) || ts5.isConstructorDeclaration(declaration)) {
|
|
526
492
|
const nextDeclaration = declarations[index + 1];
|
|
527
|
-
const isNextMethodWithSameName = nextDeclaration && (
|
|
493
|
+
const isNextMethodWithSameName = nextDeclaration && (ts5.isMethodDeclaration(nextDeclaration) && nextDeclaration.name.getText() === declaration.name?.getText() || ts5.isConstructorDeclaration(nextDeclaration) && ts5.isConstructorDeclaration(declaration));
|
|
528
494
|
return !isNextMethodWithSameName;
|
|
529
495
|
}
|
|
530
496
|
return true;
|
|
@@ -543,13 +509,13 @@ var PropertiesExtractor = class {
|
|
|
543
509
|
/** Gets the doc tag corresponding to a class member modifier (readonly, protected, etc.). */
|
|
544
510
|
getTagForMemberModifier(mod) {
|
|
545
511
|
switch (mod.kind) {
|
|
546
|
-
case
|
|
512
|
+
case ts5.SyntaxKind.StaticKeyword:
|
|
547
513
|
return MemberTags.Static;
|
|
548
|
-
case
|
|
514
|
+
case ts5.SyntaxKind.ReadonlyKeyword:
|
|
549
515
|
return MemberTags.Readonly;
|
|
550
|
-
case
|
|
516
|
+
case ts5.SyntaxKind.ProtectedKeyword:
|
|
551
517
|
return MemberTags.Protected;
|
|
552
|
-
case
|
|
518
|
+
case ts5.SyntaxKind.AbstractKeyword:
|
|
553
519
|
return MemberTags.Abstract;
|
|
554
520
|
default:
|
|
555
521
|
return void 0;
|
|
@@ -565,34 +531,34 @@ var PropertiesExtractor = class {
|
|
|
565
531
|
* - The member is marked as internal via JSDoc.
|
|
566
532
|
*/
|
|
567
533
|
isMemberExcluded(member) {
|
|
568
|
-
if (
|
|
534
|
+
if (ts5.isConstructorDeclaration(member)) {
|
|
569
535
|
return false;
|
|
570
536
|
}
|
|
571
|
-
return !member.name || !this.isDocumentableMember(member) || !
|
|
537
|
+
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);
|
|
572
538
|
}
|
|
573
539
|
/** Gets whether a class member is a method, property, or accessor. */
|
|
574
540
|
isDocumentableMember(member) {
|
|
575
|
-
return this.isMethod(member) || this.isProperty(member) ||
|
|
576
|
-
|
|
541
|
+
return this.isMethod(member) || this.isProperty(member) || ts5.isAccessor(member) || ts5.isConstructorDeclaration(member) || // Signatures are documentable if they are part of an interface.
|
|
542
|
+
ts5.isCallSignatureDeclaration(member);
|
|
577
543
|
}
|
|
578
544
|
/** Check if the parameter is a constructor parameter with a public modifier */
|
|
579
545
|
isPublicConstructorParameterProperty(node) {
|
|
580
|
-
if (
|
|
581
|
-
return node.modifiers.some((modifier) => modifier.kind ===
|
|
546
|
+
if (ts5.isParameterPropertyDeclaration(node, node.parent) && node.modifiers) {
|
|
547
|
+
return node.modifiers.some((modifier) => modifier.kind === ts5.SyntaxKind.PublicKeyword);
|
|
582
548
|
}
|
|
583
549
|
return false;
|
|
584
550
|
}
|
|
585
551
|
/** Gets whether a member is a property. */
|
|
586
552
|
isProperty(member) {
|
|
587
|
-
return
|
|
553
|
+
return ts5.isPropertyDeclaration(member) || ts5.isPropertySignature(member) || this.isPublicConstructorParameterProperty(member);
|
|
588
554
|
}
|
|
589
555
|
/** Gets whether a member is a method. */
|
|
590
556
|
isMethod(member) {
|
|
591
|
-
return
|
|
557
|
+
return ts5.isMethodDeclaration(member) || ts5.isMethodSignature(member);
|
|
592
558
|
}
|
|
593
559
|
/** Gets whether the given signature declaration is documentable. */
|
|
594
560
|
isDocumentableSignature(signature) {
|
|
595
|
-
return
|
|
561
|
+
return ts5.isConstructSignatureDeclaration(signature) || ts5.isCallSignatureDeclaration(signature);
|
|
596
562
|
}
|
|
597
563
|
/**
|
|
598
564
|
* Check wether a member has a private computed property name like [ɵWRITABLE_SIGNAL]
|
|
@@ -600,7 +566,7 @@ var PropertiesExtractor = class {
|
|
|
600
566
|
* This will prevent exposing private computed properties in the docs.
|
|
601
567
|
*/
|
|
602
568
|
hasPrivateComputedProperty(property) {
|
|
603
|
-
return
|
|
569
|
+
return ts5.isComputedPropertyName(property.name) && property.name.expression.getText().startsWith("\u0275");
|
|
604
570
|
}
|
|
605
571
|
};
|
|
606
572
|
|
|
@@ -626,14 +592,14 @@ var ClassExtractor = class extends PropertiesExtractor {
|
|
|
626
592
|
/** Gets whether the declaration for this extractor is abstract. */
|
|
627
593
|
isAbstract() {
|
|
628
594
|
const modifiers = this.declaration.modifiers ?? [];
|
|
629
|
-
return modifiers.some((mod) => mod.kind ===
|
|
595
|
+
return modifiers.some((mod) => mod.kind === ts6.SyntaxKind.AbstractKeyword);
|
|
630
596
|
}
|
|
631
597
|
extractInheritance(declaration) {
|
|
632
598
|
if (!declaration.heritageClauses) {
|
|
633
599
|
return void 0;
|
|
634
600
|
}
|
|
635
601
|
for (const clause of declaration.heritageClauses) {
|
|
636
|
-
if (clause.token ===
|
|
602
|
+
if (clause.token === ts6.SyntaxKind.ExtendsKeyword) {
|
|
637
603
|
const types = clause.types;
|
|
638
604
|
if (types.length > 0) {
|
|
639
605
|
const baseClass = types[0];
|
|
@@ -742,7 +708,7 @@ function extractClass(classDeclaration, metadataReader, typeChecker) {
|
|
|
742
708
|
}
|
|
743
709
|
function extractPipeSyntax(metadata, classDeclaration) {
|
|
744
710
|
const transformParams = classDeclaration.members.find((member) => {
|
|
745
|
-
return
|
|
711
|
+
return ts6.isMethodDeclaration(member) && member.name && ts6.isIdentifier(member.name) && member.name.getText() === "transform";
|
|
746
712
|
});
|
|
747
713
|
let paramNames = transformParams.parameters.slice(1).map((param) => {
|
|
748
714
|
return param.name.getText();
|
|
@@ -751,7 +717,7 @@ function extractPipeSyntax(metadata, classDeclaration) {
|
|
|
751
717
|
}
|
|
752
718
|
|
|
753
719
|
// packages/compiler-cli/src/ngtsc/docs/src/constant_extractor.js
|
|
754
|
-
import
|
|
720
|
+
import ts7 from "typescript";
|
|
755
721
|
var LITERAL_AS_ENUM_TAG = "object-literal-as-enum";
|
|
756
722
|
function extractConstant(declaration, typeChecker) {
|
|
757
723
|
const resolvedType = typeChecker.getBaseTypeOfLiteralType(typeChecker.getTypeAtLocation(declaration));
|
|
@@ -783,17 +749,17 @@ function isSyntheticAngularConstant(declaration) {
|
|
|
783
749
|
}
|
|
784
750
|
function extractLiteralPropertiesAsEnumMembers(declaration) {
|
|
785
751
|
let initializer = declaration.initializer;
|
|
786
|
-
while (initializer && (
|
|
752
|
+
while (initializer && (ts7.isAsExpression(initializer) || ts7.isParenthesizedExpression(initializer))) {
|
|
787
753
|
initializer = initializer.expression;
|
|
788
754
|
}
|
|
789
|
-
if (initializer === void 0 || !
|
|
790
|
-
throw new Error(`Declaration tagged with "${LITERAL_AS_ENUM_TAG}" must be initialized to an object literal, but received ${initializer ?
|
|
755
|
+
if (initializer === void 0 || !ts7.isObjectLiteralExpression(initializer)) {
|
|
756
|
+
throw new Error(`Declaration tagged with "${LITERAL_AS_ENUM_TAG}" must be initialized to an object literal, but received ${initializer ? ts7.SyntaxKind[initializer.kind] : "undefined"}`);
|
|
791
757
|
}
|
|
792
758
|
return initializer.properties.map((prop) => {
|
|
793
|
-
if (!
|
|
759
|
+
if (!ts7.isPropertyAssignment(prop) || !ts7.isIdentifier(prop.name)) {
|
|
794
760
|
throw new Error(`Property in declaration tagged with "${LITERAL_AS_ENUM_TAG}" must be a property assignment with a static name`);
|
|
795
761
|
}
|
|
796
|
-
if (!
|
|
762
|
+
if (!ts7.isNumericLiteral(prop.initializer) && !ts7.isStringLiteralLike(prop.initializer)) {
|
|
797
763
|
throw new Error(`Property in declaration tagged with "${LITERAL_AS_ENUM_TAG}" must be initialized to a number or string literal`);
|
|
798
764
|
}
|
|
799
765
|
return {
|
|
@@ -809,10 +775,10 @@ function extractLiteralPropertiesAsEnumMembers(declaration) {
|
|
|
809
775
|
}
|
|
810
776
|
|
|
811
777
|
// packages/compiler-cli/src/ngtsc/docs/src/decorator_extractor.js
|
|
812
|
-
import
|
|
778
|
+
import ts9 from "typescript";
|
|
813
779
|
|
|
814
780
|
// packages/compiler-cli/src/ngtsc/docs/src/interface_extractor.js
|
|
815
|
-
import
|
|
781
|
+
import ts8 from "typescript";
|
|
816
782
|
var InterfaceExtractor = class extends PropertiesExtractor {
|
|
817
783
|
constructor(declaration, typeChecker) {
|
|
818
784
|
super(declaration, typeChecker);
|
|
@@ -835,7 +801,7 @@ var InterfaceExtractor = class extends PropertiesExtractor {
|
|
|
835
801
|
return [];
|
|
836
802
|
}
|
|
837
803
|
for (const clause of declaration.heritageClauses) {
|
|
838
|
-
if (clause.token ===
|
|
804
|
+
if (clause.token === ts8.SyntaxKind.ExtendsKeyword) {
|
|
839
805
|
const types = clause.types;
|
|
840
806
|
if (types.length > 0) {
|
|
841
807
|
return types.map((t) => t.getText());
|
|
@@ -861,7 +827,7 @@ function extractorDecorator(declaration, typeChecker) {
|
|
|
861
827
|
let signatures = [];
|
|
862
828
|
if (!members) {
|
|
863
829
|
const decoratorInterface = getDecoratorDeclaration(declaration, typeChecker);
|
|
864
|
-
const callSignatures = decoratorInterface.members.filter(
|
|
830
|
+
const callSignatures = decoratorInterface.members.filter(ts9.isCallSignatureDeclaration);
|
|
865
831
|
signatures = getDecoratorSignatures(callSignatures, typeChecker);
|
|
866
832
|
}
|
|
867
833
|
return {
|
|
@@ -879,7 +845,7 @@ function isDecoratorDeclaration(declaration) {
|
|
|
879
845
|
return !!getDecoratorType(declaration);
|
|
880
846
|
}
|
|
881
847
|
function isDecoratorOptionsInterface(declaration) {
|
|
882
|
-
return declaration.getSourceFile().statements.some((s) =>
|
|
848
|
+
return declaration.getSourceFile().statements.some((s) => ts9.isVariableStatement(s) && s.declarationList.declarations.some((d) => isDecoratorDeclaration(d) && d.name.getText() === declaration.name.getText()));
|
|
883
849
|
}
|
|
884
850
|
function getDecoratorType(declaration) {
|
|
885
851
|
const initializer = declaration.initializer?.getFullText() ?? "";
|
|
@@ -897,7 +863,7 @@ function getDecoratorDeclaration(declaration, typeChecker) {
|
|
|
897
863
|
const decoratorType = typeChecker.getTypeAtLocation(decoratorDeclaration);
|
|
898
864
|
const aliasDeclaration = decoratorType.getSymbol().getDeclarations()[0];
|
|
899
865
|
const decoratorInterface = aliasDeclaration;
|
|
900
|
-
if (!decoratorInterface || !
|
|
866
|
+
if (!decoratorInterface || !ts9.isInterfaceDeclaration(decoratorInterface)) {
|
|
901
867
|
throw new Error(`No decorator interface found for "${decoratorName}".`);
|
|
902
868
|
}
|
|
903
869
|
return decoratorInterface;
|
|
@@ -908,12 +874,12 @@ function getDecoratorProperties(declaration, typeChecker) {
|
|
|
908
874
|
const firstParamType = typeChecker.getTypeAtLocation(decoratorFirstParam);
|
|
909
875
|
let firstParamTypeDecl;
|
|
910
876
|
if (firstParamType.isUnion()) {
|
|
911
|
-
const firstParamTypeUnion = firstParamType.types.find((t) => (t.flags &
|
|
877
|
+
const firstParamTypeUnion = firstParamType.types.find((t) => (t.flags & ts9.TypeFlags.Undefined) === 0);
|
|
912
878
|
firstParamTypeDecl = firstParamTypeUnion?.getSymbol()?.getDeclarations()[0];
|
|
913
879
|
} else {
|
|
914
880
|
firstParamTypeDecl = firstParamType.getSymbol()?.getDeclarations()[0];
|
|
915
881
|
}
|
|
916
|
-
if (!firstParamTypeDecl || !
|
|
882
|
+
if (!firstParamTypeDecl || !ts9.isInterfaceDeclaration(firstParamTypeDecl)) {
|
|
917
883
|
return null;
|
|
918
884
|
}
|
|
919
885
|
const interfaceDeclaration = firstParamTypeDecl;
|
|
@@ -941,7 +907,7 @@ function getDecoratorInterface(declaration, typeChecker) {
|
|
|
941
907
|
const symbol = typeChecker.getSymbolAtLocation(declaration.name);
|
|
942
908
|
const decoratorType = typeChecker.getTypeOfSymbolAtLocation(symbol, symbol.valueDeclaration);
|
|
943
909
|
const decoratorInterface = decoratorType.getSymbol()?.getDeclarations()[0];
|
|
944
|
-
if (!decoratorInterface || !
|
|
910
|
+
if (!decoratorInterface || !ts9.isInterfaceDeclaration(decoratorInterface)) {
|
|
945
911
|
throw new Error(`No decorator interface found for "${name}".`);
|
|
946
912
|
}
|
|
947
913
|
return decoratorInterface;
|
|
@@ -950,22 +916,22 @@ function getDecoratorJsDocNode(declaration, typeChecker) {
|
|
|
950
916
|
const name = declaration.name.getText();
|
|
951
917
|
const decoratorInterface = getDecoratorInterface(declaration, typeChecker);
|
|
952
918
|
const callSignature = decoratorInterface.members.filter((node) => {
|
|
953
|
-
return
|
|
919
|
+
return ts9.isCallSignatureDeclaration(node) && extractRawJsDoc(node);
|
|
954
920
|
}).at(-1);
|
|
955
|
-
if (!callSignature || !
|
|
921
|
+
if (!callSignature || !ts9.isCallSignatureDeclaration(callSignature)) {
|
|
956
922
|
throw new Error(`No call signature with JsDoc on "${name}Decorator"`);
|
|
957
923
|
}
|
|
958
924
|
return callSignature;
|
|
959
925
|
}
|
|
960
926
|
function getParamTypeString(paramNode, typeChecker) {
|
|
961
927
|
const type = typeChecker.getTypeAtLocation(paramNode);
|
|
962
|
-
const printer =
|
|
928
|
+
const printer = ts9.createPrinter({ removeComments: true });
|
|
963
929
|
const sourceFile = paramNode.getSourceFile();
|
|
964
930
|
const replace = [];
|
|
965
931
|
if (type.isUnion()) {
|
|
966
932
|
for (const subType of type.types) {
|
|
967
933
|
const decl = subType.getSymbol()?.getDeclarations()?.[0];
|
|
968
|
-
if (decl &&
|
|
934
|
+
if (decl && ts9.isInterfaceDeclaration(decl) && decl.name.text !== "Function") {
|
|
969
935
|
replace.push({
|
|
970
936
|
initial: subType.symbol.name,
|
|
971
937
|
replacedWith: expandType(decl, sourceFile, printer)
|
|
@@ -973,19 +939,19 @@ function getParamTypeString(paramNode, typeChecker) {
|
|
|
973
939
|
}
|
|
974
940
|
}
|
|
975
941
|
}
|
|
976
|
-
let result = printer.printNode(
|
|
942
|
+
let result = printer.printNode(ts9.EmitHint.Unspecified, paramNode, sourceFile).replace(new RegExp(`${paramNode.name.getText()}\\??: `), "").replaceAll(/\s+/g, " ");
|
|
977
943
|
for (const { initial, replacedWith } of replace) {
|
|
978
944
|
result = result.replace(initial, replacedWith);
|
|
979
945
|
}
|
|
980
946
|
return result;
|
|
981
947
|
}
|
|
982
948
|
function expandType(decl, sourceFile, printer) {
|
|
983
|
-
const props = decl.members.map((member) => printer.printNode(
|
|
949
|
+
const props = decl.members.map((member) => printer.printNode(ts9.EmitHint.Unspecified, member, sourceFile)).join(" ").replaceAll(/\s+/g, " ");
|
|
984
950
|
return `{${props}}`;
|
|
985
951
|
}
|
|
986
952
|
|
|
987
953
|
// packages/compiler-cli/src/ngtsc/docs/src/enum_extractor.js
|
|
988
|
-
import
|
|
954
|
+
import ts10 from "typescript";
|
|
989
955
|
function extractEnum(declaration, typeChecker) {
|
|
990
956
|
return {
|
|
991
957
|
name: declaration.name.getText(),
|
|
@@ -1009,11 +975,35 @@ function extractEnumMembers(declaration, checker) {
|
|
|
1009
975
|
}
|
|
1010
976
|
function getEnumMemberValue(memberNode) {
|
|
1011
977
|
const literal = memberNode.getChildren().find((n) => {
|
|
1012
|
-
return
|
|
978
|
+
return ts10.isNumericLiteral(n) || ts10.isStringLiteral(n) || ts10.isPrefixUnaryExpression(n) && n.operator === ts10.SyntaxKind.MinusToken && ts10.isNumericLiteral(n.operand);
|
|
1013
979
|
});
|
|
1014
980
|
return literal?.getText() ?? "";
|
|
1015
981
|
}
|
|
1016
982
|
|
|
983
|
+
// packages/compiler-cli/src/ngtsc/docs/src/import_extractor.js
|
|
984
|
+
import ts11 from "typescript";
|
|
985
|
+
function getImportedSymbols(sourceFile) {
|
|
986
|
+
const importSpecifiers = /* @__PURE__ */ new Map();
|
|
987
|
+
function visit(node) {
|
|
988
|
+
if (ts11.isImportDeclaration(node)) {
|
|
989
|
+
let moduleSpecifier = node.moduleSpecifier.getText(sourceFile).replace(/['"]/g, "");
|
|
990
|
+
if (moduleSpecifier.startsWith("@angular/")) {
|
|
991
|
+
const namedBindings = node.importClause?.namedBindings;
|
|
992
|
+
if (namedBindings && ts11.isNamedImports(namedBindings)) {
|
|
993
|
+
namedBindings.elements.forEach((importSpecifier) => {
|
|
994
|
+
const importName = importSpecifier.name.text;
|
|
995
|
+
const importAlias = importSpecifier.propertyName ? importSpecifier.propertyName.text : void 0;
|
|
996
|
+
importSpecifiers.set(importAlias ?? importName, moduleSpecifier);
|
|
997
|
+
});
|
|
998
|
+
}
|
|
999
|
+
}
|
|
1000
|
+
}
|
|
1001
|
+
ts11.forEachChild(node, visit);
|
|
1002
|
+
}
|
|
1003
|
+
visit(sourceFile);
|
|
1004
|
+
return importSpecifiers;
|
|
1005
|
+
}
|
|
1006
|
+
|
|
1017
1007
|
// packages/compiler-cli/src/ngtsc/docs/src/initializer_api_function_extractor.js
|
|
1018
1008
|
import ts12 from "typescript";
|
|
1019
1009
|
var initializerApiTag = "initializerApiFunction";
|
|
@@ -1123,6 +1113,9 @@ function extractFunctionWithOverloads(name, type, typeChecker) {
|
|
|
1123
1113
|
};
|
|
1124
1114
|
}
|
|
1125
1115
|
|
|
1116
|
+
// packages/compiler-cli/src/ngtsc/docs/src/namespace_extractor.js
|
|
1117
|
+
import ts13 from "typescript";
|
|
1118
|
+
|
|
1126
1119
|
// packages/compiler-cli/src/ngtsc/docs/src/type_alias_extractor.js
|
|
1127
1120
|
function extractTypeAlias(declaration) {
|
|
1128
1121
|
return {
|
|
@@ -1136,28 +1129,46 @@ function extractTypeAlias(declaration) {
|
|
|
1136
1129
|
};
|
|
1137
1130
|
}
|
|
1138
1131
|
|
|
1139
|
-
// packages/compiler-cli/src/ngtsc/docs/src/
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1132
|
+
// packages/compiler-cli/src/ngtsc/docs/src/variable_extractor.js
|
|
1133
|
+
function extractFromVariableStatement(statement, typeChecker) {
|
|
1134
|
+
return statement.declarationList.declarations.map((declaration) => extractConstant(declaration, typeChecker));
|
|
1135
|
+
}
|
|
1136
|
+
|
|
1137
|
+
// packages/compiler-cli/src/ngtsc/docs/src/namespace_extractor.js
|
|
1138
|
+
function extractNamespace(node, typeChecker) {
|
|
1139
|
+
const members = [];
|
|
1140
|
+
if (node.body && ts13.isModuleBlock(node.body)) {
|
|
1141
|
+
for (const statement of node.body.statements) {
|
|
1142
|
+
let entries = [];
|
|
1143
|
+
if (ts13.isInterfaceDeclaration(statement)) {
|
|
1144
|
+
entries.push(extractInterface(statement, typeChecker));
|
|
1145
|
+
} else if (ts13.isTypeAliasDeclaration(statement)) {
|
|
1146
|
+
entries.push(extractTypeAlias(statement));
|
|
1147
|
+
} else if (ts13.isFunctionDeclaration(statement)) {
|
|
1148
|
+
const name = statement.name?.getText();
|
|
1149
|
+
if (name) {
|
|
1150
|
+
entries.push(new FunctionExtractor(name, statement, typeChecker).extract());
|
|
1154
1151
|
}
|
|
1152
|
+
} else if (ts13.isVariableStatement(statement)) {
|
|
1153
|
+
entries.push(...extractFromVariableStatement(statement, typeChecker));
|
|
1154
|
+
}
|
|
1155
|
+
let isExported = false;
|
|
1156
|
+
if (ts13.canHaveModifiers(statement)) {
|
|
1157
|
+
isExported = (ts13.getModifiers(statement) ?? []).some((modifier) => modifier.kind === ts13.SyntaxKind.ExportKeyword);
|
|
1158
|
+
}
|
|
1159
|
+
if (isExported) {
|
|
1160
|
+
members.push(...entries);
|
|
1155
1161
|
}
|
|
1156
1162
|
}
|
|
1157
|
-
ts13.forEachChild(node, visit);
|
|
1158
1163
|
}
|
|
1159
|
-
|
|
1160
|
-
|
|
1164
|
+
return {
|
|
1165
|
+
name: node.name.getText(),
|
|
1166
|
+
entryType: EntryType.Namespace,
|
|
1167
|
+
description: extractJsDocDescription(node),
|
|
1168
|
+
rawComment: extractRawJsDoc(node),
|
|
1169
|
+
jsdocTags: extractJsDocTags(node),
|
|
1170
|
+
members
|
|
1171
|
+
};
|
|
1161
1172
|
}
|
|
1162
1173
|
|
|
1163
1174
|
// packages/compiler-cli/src/ngtsc/docs/src/extractor.js
|
|
@@ -1178,34 +1189,63 @@ var DocsExtractor = class {
|
|
|
1178
1189
|
const entries = [];
|
|
1179
1190
|
const symbols = /* @__PURE__ */ new Map();
|
|
1180
1191
|
const exportedDeclarations = this.getExportedDeclarations(sourceFile);
|
|
1181
|
-
|
|
1192
|
+
const groupedDeclarations = /* @__PURE__ */ new Map();
|
|
1193
|
+
for (const [exportName, declaration] of exportedDeclarations) {
|
|
1194
|
+
if (!groupedDeclarations.has(exportName)) {
|
|
1195
|
+
groupedDeclarations.set(exportName, []);
|
|
1196
|
+
}
|
|
1197
|
+
groupedDeclarations.get(exportName).push(declaration);
|
|
1198
|
+
}
|
|
1199
|
+
for (const [exportName, declarations] of groupedDeclarations.entries()) {
|
|
1182
1200
|
if (isAngularPrivateName(exportName)) {
|
|
1183
1201
|
continue;
|
|
1184
1202
|
}
|
|
1185
|
-
const entry = this.
|
|
1203
|
+
const entry = this.extractDeclarations(exportName, declarations);
|
|
1186
1204
|
if (entry && !isIgnoredDocEntry(entry)) {
|
|
1187
|
-
const realSourceFile =
|
|
1205
|
+
const realSourceFile = declarations[0].getSourceFile();
|
|
1188
1206
|
const importedSymbols = getImportedSymbols(realSourceFile);
|
|
1189
1207
|
importedSymbols.forEach((moduleName, symbolName) => {
|
|
1190
1208
|
if (symbolName.startsWith("\u0275") || privateModules.has(moduleName)) {
|
|
1191
1209
|
return;
|
|
1192
1210
|
}
|
|
1193
1211
|
if (symbols.has(symbolName) && symbols.get(symbolName) !== moduleName) {
|
|
1194
|
-
throw new Error(`
|
|
1212
|
+
throw new Error(`Ambiguous symbol \`${symbolName}\` exported by both ${symbols.get(symbolName)} & ${moduleName}`);
|
|
1195
1213
|
}
|
|
1196
1214
|
symbols.set(symbolName, moduleName);
|
|
1197
1215
|
});
|
|
1198
1216
|
entry.source = {
|
|
1199
1217
|
filePath: getRelativeFilePath(realSourceFile, rootDir),
|
|
1200
1218
|
// Start & End are off by 1
|
|
1201
|
-
startLine: ts14.getLineAndCharacterOfPosition(realSourceFile,
|
|
1202
|
-
endLine: ts14.getLineAndCharacterOfPosition(realSourceFile,
|
|
1219
|
+
startLine: ts14.getLineAndCharacterOfPosition(realSourceFile, declarations[0].getStart()).line + 1,
|
|
1220
|
+
endLine: ts14.getLineAndCharacterOfPosition(realSourceFile, declarations[0].getEnd()).line + 1
|
|
1203
1221
|
};
|
|
1204
1222
|
entries.push({ ...entry, name: exportName });
|
|
1205
1223
|
}
|
|
1206
1224
|
}
|
|
1207
1225
|
return { entries, symbols };
|
|
1208
1226
|
}
|
|
1227
|
+
/**
|
|
1228
|
+
* Extracts a documentation entry for a given set of declarations that are all exported under
|
|
1229
|
+
* the same name. This is used to combine entries, e.g. for a type and a namespace that are
|
|
1230
|
+
* exported under the same name.
|
|
1231
|
+
*/
|
|
1232
|
+
extractDeclarations(exportName, nodes) {
|
|
1233
|
+
const entries = nodes.map((node) => this.extractDeclaration(node));
|
|
1234
|
+
const decorator = entries.find((e) => e?.entryType === EntryType.Decorator);
|
|
1235
|
+
if (decorator) {
|
|
1236
|
+
return decorator;
|
|
1237
|
+
}
|
|
1238
|
+
const entry = entries[0];
|
|
1239
|
+
if (entries.length > 1) {
|
|
1240
|
+
const typeAlias = entries.find(isTypeAliasEntry);
|
|
1241
|
+
const namespace = entries.find(isNamespaceEntry);
|
|
1242
|
+
if (typeAlias && namespace) {
|
|
1243
|
+
typeAlias.members = namespace.members;
|
|
1244
|
+
return typeAlias;
|
|
1245
|
+
}
|
|
1246
|
+
}
|
|
1247
|
+
return entry ?? null;
|
|
1248
|
+
}
|
|
1209
1249
|
/** Extract the doc entry for a single declaration. */
|
|
1210
1250
|
extractDeclaration(node) {
|
|
1211
1251
|
if (isNamedClassDeclaration(node)) {
|
|
@@ -1230,14 +1270,32 @@ var DocsExtractor = class {
|
|
|
1230
1270
|
if (ts14.isEnumDeclaration(node)) {
|
|
1231
1271
|
return extractEnum(node, this.typeChecker);
|
|
1232
1272
|
}
|
|
1273
|
+
if (ts14.isModuleDeclaration(node)) {
|
|
1274
|
+
return extractNamespace(node, this.typeChecker);
|
|
1275
|
+
}
|
|
1233
1276
|
return null;
|
|
1234
1277
|
}
|
|
1235
1278
|
/** Gets the list of exported declarations for doc extraction. */
|
|
1236
1279
|
getExportedDeclarations(sourceFile) {
|
|
1237
|
-
const
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1280
|
+
const moduleSymbol = this.typeChecker.getSymbolAtLocation(sourceFile);
|
|
1281
|
+
if (!moduleSymbol) {
|
|
1282
|
+
return [];
|
|
1283
|
+
}
|
|
1284
|
+
const exportedSymbols = this.typeChecker.getExportsOfModule(moduleSymbol);
|
|
1285
|
+
const result = [];
|
|
1286
|
+
for (const symbol of exportedSymbols) {
|
|
1287
|
+
let declarations = symbol.getDeclarations();
|
|
1288
|
+
if (symbol.flags & ts14.SymbolFlags.Alias) {
|
|
1289
|
+
const aliasedSymbol = this.typeChecker.getAliasedSymbol(symbol);
|
|
1290
|
+
declarations = aliasedSymbol.getDeclarations();
|
|
1291
|
+
}
|
|
1292
|
+
if (declarations) {
|
|
1293
|
+
for (const declaration of declarations) {
|
|
1294
|
+
result.push([symbol.name, declaration]);
|
|
1295
|
+
}
|
|
1296
|
+
}
|
|
1297
|
+
}
|
|
1298
|
+
return result.sort(([, declarationA], [, declarationB]) => declarationA.pos - declarationB.pos);
|
|
1241
1299
|
}
|
|
1242
1300
|
};
|
|
1243
1301
|
function isIgnoredInterface(node) {
|
|
@@ -1255,115 +1313,23 @@ function getRelativeFilePath(sourceFile, rootDir) {
|
|
|
1255
1313
|
const relativePath = fullPath.replace(rootDir, "");
|
|
1256
1314
|
return relativePath;
|
|
1257
1315
|
}
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
import { HtmlParser, MessageBundle } from "@angular/compiler";
|
|
1261
|
-
import ts30 from "typescript";
|
|
1262
|
-
|
|
1263
|
-
// packages/compiler-cli/src/transformers/i18n.js
|
|
1264
|
-
import { Xliff, Xliff2, Xmb } from "@angular/compiler";
|
|
1265
|
-
import * as path from "path";
|
|
1266
|
-
function i18nGetExtension(formatName) {
|
|
1267
|
-
const format = formatName.toLowerCase();
|
|
1268
|
-
switch (format) {
|
|
1269
|
-
case "xmb":
|
|
1270
|
-
return "xmb";
|
|
1271
|
-
case "xlf":
|
|
1272
|
-
case "xlif":
|
|
1273
|
-
case "xliff":
|
|
1274
|
-
case "xlf2":
|
|
1275
|
-
case "xliff2":
|
|
1276
|
-
return "xlf";
|
|
1277
|
-
}
|
|
1278
|
-
throw new Error(`Unsupported format "${formatName}"`);
|
|
1279
|
-
}
|
|
1280
|
-
function i18nExtract(formatName, outFile, host, options, bundle, pathResolve = path.resolve) {
|
|
1281
|
-
formatName = formatName || "xlf";
|
|
1282
|
-
const ext = i18nGetExtension(formatName);
|
|
1283
|
-
const content = i18nSerialize(bundle, formatName, options);
|
|
1284
|
-
const dstFile = outFile || `messages.${ext}`;
|
|
1285
|
-
const dstPath = pathResolve(options.outDir || options.basePath, dstFile);
|
|
1286
|
-
host.writeFile(dstPath, content, false, void 0, []);
|
|
1287
|
-
return [dstPath];
|
|
1288
|
-
}
|
|
1289
|
-
function i18nSerialize(bundle, formatName, options) {
|
|
1290
|
-
const format = formatName.toLowerCase();
|
|
1291
|
-
let serializer;
|
|
1292
|
-
switch (format) {
|
|
1293
|
-
case "xmb":
|
|
1294
|
-
serializer = new Xmb();
|
|
1295
|
-
break;
|
|
1296
|
-
case "xliff2":
|
|
1297
|
-
case "xlf2":
|
|
1298
|
-
serializer = new Xliff2();
|
|
1299
|
-
break;
|
|
1300
|
-
case "xlf":
|
|
1301
|
-
case "xliff":
|
|
1302
|
-
default:
|
|
1303
|
-
serializer = new Xliff();
|
|
1304
|
-
}
|
|
1305
|
-
return bundle.write(serializer, getPathNormalizer(options.basePath));
|
|
1306
|
-
}
|
|
1307
|
-
function getPathNormalizer(basePath) {
|
|
1308
|
-
return (sourcePath) => {
|
|
1309
|
-
sourcePath = basePath ? path.relative(basePath, sourcePath) : sourcePath;
|
|
1310
|
-
return sourcePath.split(path.sep).join("/");
|
|
1311
|
-
};
|
|
1312
|
-
}
|
|
1313
|
-
|
|
1314
|
-
// packages/compiler-cli/src/typescript_support.js
|
|
1315
|
-
import ts15 from "typescript";
|
|
1316
|
-
|
|
1317
|
-
// packages/compiler-cli/src/version_helpers.js
|
|
1318
|
-
function toNumbers(value) {
|
|
1319
|
-
const suffixIndex = value.lastIndexOf("-");
|
|
1320
|
-
return value.slice(0, suffixIndex === -1 ? value.length : suffixIndex).split(".").map((segment) => {
|
|
1321
|
-
const parsed = parseInt(segment, 10);
|
|
1322
|
-
if (isNaN(parsed)) {
|
|
1323
|
-
throw Error(`Unable to parse version string ${value}.`);
|
|
1324
|
-
}
|
|
1325
|
-
return parsed;
|
|
1326
|
-
});
|
|
1327
|
-
}
|
|
1328
|
-
function compareNumbers(a, b) {
|
|
1329
|
-
const max = Math.max(a.length, b.length);
|
|
1330
|
-
const min = Math.min(a.length, b.length);
|
|
1331
|
-
for (let i = 0; i < min; i++) {
|
|
1332
|
-
if (a[i] > b[i])
|
|
1333
|
-
return 1;
|
|
1334
|
-
if (a[i] < b[i])
|
|
1335
|
-
return -1;
|
|
1336
|
-
}
|
|
1337
|
-
if (min !== max) {
|
|
1338
|
-
const longestArray = a.length === max ? a : b;
|
|
1339
|
-
const comparisonResult = a.length === max ? 1 : -1;
|
|
1340
|
-
for (let i = min; i < max; i++) {
|
|
1341
|
-
if (longestArray[i] > 0) {
|
|
1342
|
-
return comparisonResult;
|
|
1343
|
-
}
|
|
1344
|
-
}
|
|
1345
|
-
}
|
|
1346
|
-
return 0;
|
|
1316
|
+
function isTypeAliasEntry(e) {
|
|
1317
|
+
return e?.entryType === EntryType.TypeAlias;
|
|
1347
1318
|
}
|
|
1348
|
-
function
|
|
1349
|
-
return
|
|
1319
|
+
function isNamespaceEntry(e) {
|
|
1320
|
+
return e?.entryType === EntryType.Namespace;
|
|
1350
1321
|
}
|
|
1351
1322
|
|
|
1352
|
-
// packages/compiler-cli/src/
|
|
1353
|
-
var
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
}
|
|
1360
|
-
}
|
|
1361
|
-
function verifySupportedTypeScriptVersion() {
|
|
1362
|
-
checkVersion(tsVersion, MIN_TS_VERSION, MAX_TS_VERSION);
|
|
1363
|
-
}
|
|
1323
|
+
// packages/compiler-cli/src/ngtsc/core/api/src/public_options.js
|
|
1324
|
+
var DiagnosticCategoryLabel;
|
|
1325
|
+
(function(DiagnosticCategoryLabel2) {
|
|
1326
|
+
DiagnosticCategoryLabel2["Warning"] = "warning";
|
|
1327
|
+
DiagnosticCategoryLabel2["Error"] = "error";
|
|
1328
|
+
DiagnosticCategoryLabel2["Suppress"] = "suppress";
|
|
1329
|
+
})(DiagnosticCategoryLabel || (DiagnosticCategoryLabel = {}));
|
|
1364
1330
|
|
|
1365
1331
|
// packages/compiler-cli/src/ngtsc/core/src/compiler.js
|
|
1366
|
-
import
|
|
1332
|
+
import ts27 from "typescript";
|
|
1367
1333
|
|
|
1368
1334
|
// packages/compiler-cli/src/ngtsc/cycles/src/analyzer.js
|
|
1369
1335
|
var CycleAnalyzer = class {
|
|
@@ -1472,7 +1438,7 @@ var Cycle = class {
|
|
|
1472
1438
|
};
|
|
1473
1439
|
|
|
1474
1440
|
// packages/compiler-cli/src/ngtsc/cycles/src/imports.js
|
|
1475
|
-
import
|
|
1441
|
+
import ts15 from "typescript";
|
|
1476
1442
|
var ImportGraph = class {
|
|
1477
1443
|
checker;
|
|
1478
1444
|
perf;
|
|
@@ -1538,10 +1504,10 @@ var ImportGraph = class {
|
|
|
1538
1504
|
return this.perf.inPhase(PerfPhase.CycleDetection, () => {
|
|
1539
1505
|
const imports = /* @__PURE__ */ new Set();
|
|
1540
1506
|
for (const stmt of sf.statements) {
|
|
1541
|
-
if (!
|
|
1507
|
+
if (!ts15.isImportDeclaration(stmt) && !ts15.isExportDeclaration(stmt) || stmt.moduleSpecifier === void 0) {
|
|
1542
1508
|
continue;
|
|
1543
1509
|
}
|
|
1544
|
-
if (
|
|
1510
|
+
if (ts15.isImportDeclaration(stmt) && stmt.importClause !== void 0 && isTypeOnlyImportClause(stmt.importClause)) {
|
|
1545
1511
|
continue;
|
|
1546
1512
|
}
|
|
1547
1513
|
const symbol = this.checker.getSymbolAtLocation(stmt.moduleSpecifier);
|
|
@@ -1549,7 +1515,7 @@ var ImportGraph = class {
|
|
|
1549
1515
|
continue;
|
|
1550
1516
|
}
|
|
1551
1517
|
const moduleFile = symbol.valueDeclaration;
|
|
1552
|
-
if (
|
|
1518
|
+
if (ts15.isSourceFile(moduleFile) && isLocalFile(moduleFile)) {
|
|
1553
1519
|
imports.add(moduleFile);
|
|
1554
1520
|
}
|
|
1555
1521
|
}
|
|
@@ -1564,7 +1530,7 @@ function isTypeOnlyImportClause(node) {
|
|
|
1564
1530
|
if (node.isTypeOnly) {
|
|
1565
1531
|
return true;
|
|
1566
1532
|
}
|
|
1567
|
-
if (node.namedBindings !== void 0 &&
|
|
1533
|
+
if (node.namedBindings !== void 0 && ts15.isNamedImports(node.namedBindings) && node.namedBindings.elements.every((specifier) => specifier.isTypeOnly)) {
|
|
1568
1534
|
return true;
|
|
1569
1535
|
}
|
|
1570
1536
|
return false;
|
|
@@ -1592,7 +1558,7 @@ var Found = class {
|
|
|
1592
1558
|
};
|
|
1593
1559
|
|
|
1594
1560
|
// packages/compiler-cli/src/ngtsc/entry_point/src/generator.js
|
|
1595
|
-
import
|
|
1561
|
+
import ts16 from "typescript";
|
|
1596
1562
|
var FlatIndexGenerator = class {
|
|
1597
1563
|
entryPoint;
|
|
1598
1564
|
moduleName;
|
|
@@ -1611,7 +1577,7 @@ var FlatIndexGenerator = class {
|
|
|
1611
1577
|
|
|
1612
1578
|
export * from '${relativeEntryPoint}';
|
|
1613
1579
|
`;
|
|
1614
|
-
const genFile =
|
|
1580
|
+
const genFile = ts16.createSourceFile(this.flatIndexPath, contents, ts16.ScriptTarget.ES2015, true, ts16.ScriptKind.TS);
|
|
1615
1581
|
if (this.moduleName !== null) {
|
|
1616
1582
|
genFile.moduleName = this.moduleName;
|
|
1617
1583
|
}
|
|
@@ -1636,7 +1602,7 @@ function findFlatIndexEntryPoint(rootFiles) {
|
|
|
1636
1602
|
}
|
|
1637
1603
|
|
|
1638
1604
|
// packages/compiler-cli/src/ngtsc/entry_point/src/private_export_checker.js
|
|
1639
|
-
import
|
|
1605
|
+
import ts17 from "typescript";
|
|
1640
1606
|
function checkForPrivateExports(entryPoint, checker, refGraph) {
|
|
1641
1607
|
const diagnostics = [];
|
|
1642
1608
|
const topLevelExports = /* @__PURE__ */ new Set();
|
|
@@ -1646,7 +1612,7 @@ function checkForPrivateExports(entryPoint, checker, refGraph) {
|
|
|
1646
1612
|
}
|
|
1647
1613
|
const exportedSymbols = checker.getExportsOfModule(moduleSymbol);
|
|
1648
1614
|
exportedSymbols.forEach((symbol) => {
|
|
1649
|
-
if (symbol.flags &
|
|
1615
|
+
if (symbol.flags & ts17.SymbolFlags.Alias) {
|
|
1650
1616
|
symbol = checker.getAliasedSymbol(symbol);
|
|
1651
1617
|
}
|
|
1652
1618
|
const decl = symbol.valueDeclaration;
|
|
@@ -1670,7 +1636,7 @@ function checkForPrivateExports(entryPoint, checker, refGraph) {
|
|
|
1670
1636
|
visibleVia = transitivePath.map((seg) => getNameOfDeclaration(seg)).join(" -> ");
|
|
1671
1637
|
}
|
|
1672
1638
|
const diagnostic = {
|
|
1673
|
-
category:
|
|
1639
|
+
category: ts17.DiagnosticCategory.Error,
|
|
1674
1640
|
code: ngErrorCode(ErrorCode.SYMBOL_NOT_EXPORTED),
|
|
1675
1641
|
file: transitiveReference.getSourceFile(),
|
|
1676
1642
|
...getPosOfDeclaration(transitiveReference),
|
|
@@ -1690,7 +1656,7 @@ function getPosOfDeclaration(decl) {
|
|
|
1690
1656
|
};
|
|
1691
1657
|
}
|
|
1692
1658
|
function getIdentifierOfDeclaration(decl) {
|
|
1693
|
-
if ((
|
|
1659
|
+
if ((ts17.isClassDeclaration(decl) || ts17.isVariableDeclaration(decl) || ts17.isFunctionDeclaration(decl)) && decl.name !== void 0 && ts17.isIdentifier(decl.name)) {
|
|
1694
1660
|
return decl.name;
|
|
1695
1661
|
} else {
|
|
1696
1662
|
return null;
|
|
@@ -1702,13 +1668,13 @@ function getNameOfDeclaration(decl) {
|
|
|
1702
1668
|
}
|
|
1703
1669
|
function getDescriptorOfDeclaration(decl) {
|
|
1704
1670
|
switch (decl.kind) {
|
|
1705
|
-
case
|
|
1671
|
+
case ts17.SyntaxKind.ClassDeclaration:
|
|
1706
1672
|
return "class";
|
|
1707
|
-
case
|
|
1673
|
+
case ts17.SyntaxKind.FunctionDeclaration:
|
|
1708
1674
|
return "function";
|
|
1709
|
-
case
|
|
1675
|
+
case ts17.SyntaxKind.VariableDeclaration:
|
|
1710
1676
|
return "variable";
|
|
1711
|
-
case
|
|
1677
|
+
case ts17.SyntaxKind.EnumDeclaration:
|
|
1712
1678
|
return "enum";
|
|
1713
1679
|
default:
|
|
1714
1680
|
return "declaration";
|
|
@@ -2548,7 +2514,7 @@ var NgModuleIndexImpl = class {
|
|
|
2548
2514
|
};
|
|
2549
2515
|
|
|
2550
2516
|
// packages/compiler-cli/src/ngtsc/resource/src/loader.js
|
|
2551
|
-
import
|
|
2517
|
+
import ts18 from "typescript";
|
|
2552
2518
|
var CSS_PREPROCESSOR_EXT = /(\.scss|\.sass|\.less|\.styl)$/;
|
|
2553
2519
|
var RESOURCE_MARKER = ".$ngresource$";
|
|
2554
2520
|
var RESOURCE_MARKER_TS = RESOURCE_MARKER + ".ts";
|
|
@@ -2724,7 +2690,7 @@ var AdapterResourceLoader = class {
|
|
|
2724
2690
|
* for the file by setting up a module resolution for it that will fail.
|
|
2725
2691
|
*/
|
|
2726
2692
|
getResolvedCandidateLocations(url, fromFile) {
|
|
2727
|
-
const failedLookup =
|
|
2693
|
+
const failedLookup = ts18.resolveModuleName(url + RESOURCE_MARKER, fromFile, this.options, this.lookupResolutionHost);
|
|
2728
2694
|
if (failedLookup.failedLookupLocations === void 0) {
|
|
2729
2695
|
throw new Error(`Internal error: expected to find failedLookupLocations during resolution of resource '${url}' in context of ${fromFile}`);
|
|
2730
2696
|
}
|
|
@@ -2860,7 +2826,7 @@ var StandaloneComponentScopeReader = class {
|
|
|
2860
2826
|
import { ASTWithSource as ASTWithSource2, BindingType, Interpolation, PrefixNot, PropertyRead as PropertyRead2, TmplAstBoundAttribute, TmplAstElement as TmplAstElement2, TmplAstIfBlock, TmplAstSwitchBlock, TmplAstTemplate as TmplAstTemplate2 } from "@angular/compiler";
|
|
2861
2827
|
|
|
2862
2828
|
// packages/compiler-cli/src/ngtsc/typecheck/src/symbol_util.js
|
|
2863
|
-
import
|
|
2829
|
+
import ts19 from "typescript";
|
|
2864
2830
|
var SIGNAL_FNS = /* @__PURE__ */ new Set([
|
|
2865
2831
|
"WritableSignal",
|
|
2866
2832
|
"Signal",
|
|
@@ -2877,7 +2843,7 @@ function isSignalSymbol(symbol) {
|
|
|
2877
2843
|
const declarations = symbol.getDeclarations();
|
|
2878
2844
|
return declarations !== void 0 && declarations.some((decl) => {
|
|
2879
2845
|
const fileName = decl.getSourceFile().fileName;
|
|
2880
|
-
return (
|
|
2846
|
+
return (ts19.isInterfaceDeclaration(decl) || ts19.isTypeAliasDeclaration(decl)) && SIGNAL_FNS.has(decl.name.text) && (fileName.includes("@angular/core") || fileName.includes("angular2/rc/packages/core") || fileName.includes("bin/packages/core"));
|
|
2881
2847
|
});
|
|
2882
2848
|
}
|
|
2883
2849
|
|
|
@@ -3166,7 +3132,7 @@ var factory5 = {
|
|
|
3166
3132
|
|
|
3167
3133
|
// packages/compiler-cli/src/ngtsc/typecheck/extended/checks/nullish_coalescing_not_nullable/index.js
|
|
3168
3134
|
import { Binary } from "@angular/compiler";
|
|
3169
|
-
import
|
|
3135
|
+
import ts20 from "typescript";
|
|
3170
3136
|
var NullishCoalescingNotNullableCheck = class extends TemplateCheckWithVisitor {
|
|
3171
3137
|
code = ErrorCode.NULLISH_COALESCING_NOT_NULLABLE;
|
|
3172
3138
|
visitNode(ctx, component, node) {
|
|
@@ -3177,7 +3143,7 @@ var NullishCoalescingNotNullableCheck = class extends TemplateCheckWithVisitor {
|
|
|
3177
3143
|
return [];
|
|
3178
3144
|
}
|
|
3179
3145
|
const typeLeft = symbolLeft.tsType;
|
|
3180
|
-
if (typeLeft.flags & (
|
|
3146
|
+
if (typeLeft.flags & (ts20.TypeFlags.Any | ts20.TypeFlags.Unknown)) {
|
|
3181
3147
|
return [];
|
|
3182
3148
|
}
|
|
3183
3149
|
if (typeLeft.getNonNullableType() !== typeLeft)
|
|
@@ -3208,7 +3174,7 @@ var factory6 = {
|
|
|
3208
3174
|
|
|
3209
3175
|
// packages/compiler-cli/src/ngtsc/typecheck/extended/checks/optional_chain_not_nullable/index.js
|
|
3210
3176
|
import { KeyedRead, SafeCall, SafeKeyedRead, SafePropertyRead } from "@angular/compiler";
|
|
3211
|
-
import
|
|
3177
|
+
import ts21 from "typescript";
|
|
3212
3178
|
var OptionalChainNotNullableCheck = class extends TemplateCheckWithVisitor {
|
|
3213
3179
|
noUncheckedIndexedAccess;
|
|
3214
3180
|
code = ErrorCode.OPTIONAL_CHAIN_NOT_NULLABLE;
|
|
@@ -3228,7 +3194,7 @@ var OptionalChainNotNullableCheck = class extends TemplateCheckWithVisitor {
|
|
|
3228
3194
|
return [];
|
|
3229
3195
|
}
|
|
3230
3196
|
const typeLeft = symbolLeft.tsType;
|
|
3231
|
-
if (typeLeft.flags & (
|
|
3197
|
+
if (typeLeft.flags & (ts21.TypeFlags.Any | ts21.TypeFlags.Unknown)) {
|
|
3232
3198
|
return [];
|
|
3233
3199
|
}
|
|
3234
3200
|
if (typeLeft.getNonNullableType() !== typeLeft)
|
|
@@ -3598,17 +3564,7 @@ var factory16 = {
|
|
|
3598
3564
|
};
|
|
3599
3565
|
|
|
3600
3566
|
// packages/compiler-cli/src/ngtsc/typecheck/extended/src/extended_template_checker.js
|
|
3601
|
-
import
|
|
3602
|
-
|
|
3603
|
-
// packages/compiler-cli/src/ngtsc/core/api/src/public_options.js
|
|
3604
|
-
var DiagnosticCategoryLabel;
|
|
3605
|
-
(function(DiagnosticCategoryLabel2) {
|
|
3606
|
-
DiagnosticCategoryLabel2["Warning"] = "warning";
|
|
3607
|
-
DiagnosticCategoryLabel2["Error"] = "error";
|
|
3608
|
-
DiagnosticCategoryLabel2["Suppress"] = "suppress";
|
|
3609
|
-
})(DiagnosticCategoryLabel || (DiagnosticCategoryLabel = {}));
|
|
3610
|
-
|
|
3611
|
-
// packages/compiler-cli/src/ngtsc/typecheck/extended/src/extended_template_checker.js
|
|
3567
|
+
import ts22 from "typescript";
|
|
3612
3568
|
var ExtendedTemplateCheckerImpl = class {
|
|
3613
3569
|
partialCtx;
|
|
3614
3570
|
templateChecks;
|
|
@@ -3650,9 +3606,9 @@ var ExtendedTemplateCheckerImpl = class {
|
|
|
3650
3606
|
function diagnosticLabelToCategory(label) {
|
|
3651
3607
|
switch (label) {
|
|
3652
3608
|
case DiagnosticCategoryLabel.Warning:
|
|
3653
|
-
return
|
|
3609
|
+
return ts22.DiagnosticCategory.Warning;
|
|
3654
3610
|
case DiagnosticCategoryLabel.Error:
|
|
3655
|
-
return
|
|
3611
|
+
return ts22.DiagnosticCategory.Error;
|
|
3656
3612
|
case DiagnosticCategoryLabel.Suppress:
|
|
3657
3613
|
return null;
|
|
3658
3614
|
default:
|
|
@@ -3691,7 +3647,7 @@ var SUPPORTED_DIAGNOSTIC_NAMES = /* @__PURE__ */ new Set([
|
|
|
3691
3647
|
|
|
3692
3648
|
// packages/compiler-cli/src/ngtsc/typecheck/template_semantics/src/template_semantics_checker.js
|
|
3693
3649
|
import { ASTWithSource as ASTWithSource5, ImplicitReceiver as ImplicitReceiver2, ParsedEventType as ParsedEventType2, PropertyRead as PropertyRead6, Binary as Binary3, RecursiveAstVisitor, TmplAstBoundEvent as TmplAstBoundEvent3, TmplAstLetDeclaration as TmplAstLetDeclaration2, TmplAstRecursiveVisitor, TmplAstVariable as TmplAstVariable2 } from "@angular/compiler";
|
|
3694
|
-
import
|
|
3650
|
+
import ts23 from "typescript";
|
|
3695
3651
|
var TemplateSemanticsCheckerImpl = class {
|
|
3696
3652
|
templateTypeChecker;
|
|
3697
3653
|
constructor(templateTypeChecker) {
|
|
@@ -3774,7 +3730,7 @@ var ExpressionsSemanticsVisitor = class extends RecursiveAstVisitor {
|
|
|
3774
3730
|
}
|
|
3775
3731
|
makeIllegalTemplateVarDiagnostic(target, expressionNode, errorMessage) {
|
|
3776
3732
|
const span = target instanceof TmplAstVariable2 ? target.valueSpan || target.sourceSpan : target.sourceSpan;
|
|
3777
|
-
return this.templateTypeChecker.makeTemplateDiagnostic(this.component, expressionNode.handlerSpan,
|
|
3733
|
+
return this.templateTypeChecker.makeTemplateDiagnostic(this.component, expressionNode.handlerSpan, ts23.DiagnosticCategory.Error, ngErrorCode(ErrorCode.WRITE_TO_READ_ONLY_VARIABLE), errorMessage, [
|
|
3778
3734
|
{
|
|
3779
3735
|
text: `'${target.name}' is declared here.`,
|
|
3780
3736
|
start: span.start.offset,
|
|
@@ -3789,7 +3745,7 @@ function unwrapAstWithSource(ast) {
|
|
|
3789
3745
|
}
|
|
3790
3746
|
|
|
3791
3747
|
// packages/compiler-cli/src/ngtsc/validation/src/rules/initializer_api_usage_rule.js
|
|
3792
|
-
import
|
|
3748
|
+
import ts24 from "typescript";
|
|
3793
3749
|
var APIS_TO_CHECK = [
|
|
3794
3750
|
INPUT_INITIALIZER_FN,
|
|
3795
3751
|
MODEL_INITIALIZER_FN,
|
|
@@ -3809,13 +3765,13 @@ var InitializerApiUsageRule = class {
|
|
|
3809
3765
|
});
|
|
3810
3766
|
}
|
|
3811
3767
|
checkNode(node) {
|
|
3812
|
-
if (!
|
|
3768
|
+
if (!ts24.isCallExpression(node)) {
|
|
3813
3769
|
return null;
|
|
3814
3770
|
}
|
|
3815
|
-
while (node.parent && (
|
|
3771
|
+
while (node.parent && (ts24.isParenthesizedExpression(node.parent) || ts24.isAsExpression(node.parent))) {
|
|
3816
3772
|
node = node.parent;
|
|
3817
3773
|
}
|
|
3818
|
-
if (!node.parent || !
|
|
3774
|
+
if (!node.parent || !ts24.isCallExpression(node)) {
|
|
3819
3775
|
return null;
|
|
3820
3776
|
}
|
|
3821
3777
|
const identifiedInitializer = tryParseInitializerApi(APIS_TO_CHECK, node, this.reflector, this.importedSymbolsTracker);
|
|
@@ -3823,12 +3779,12 @@ var InitializerApiUsageRule = class {
|
|
|
3823
3779
|
return null;
|
|
3824
3780
|
}
|
|
3825
3781
|
const functionName = identifiedInitializer.api.functionName + (identifiedInitializer.isRequired ? ".required" : "");
|
|
3826
|
-
if (
|
|
3782
|
+
if (ts24.isPropertyDeclaration(node.parent) && node.parent.initializer === node) {
|
|
3827
3783
|
let closestClass = node.parent;
|
|
3828
|
-
while (closestClass && !
|
|
3784
|
+
while (closestClass && !ts24.isClassDeclaration(closestClass)) {
|
|
3829
3785
|
closestClass = closestClass.parent;
|
|
3830
3786
|
}
|
|
3831
|
-
if (closestClass &&
|
|
3787
|
+
if (closestClass && ts24.isClassDeclaration(closestClass)) {
|
|
3832
3788
|
const decorators = this.reflector.getDecoratorsOfDeclaration(closestClass);
|
|
3833
3789
|
const isComponentOrDirective = decorators !== null && decorators.some((decorator) => {
|
|
3834
3790
|
return decorator.import?.from === "@angular/core" && (decorator.name === "Component" || decorator.name === "Directive");
|
|
@@ -3841,7 +3797,7 @@ var InitializerApiUsageRule = class {
|
|
|
3841
3797
|
};
|
|
3842
3798
|
|
|
3843
3799
|
// packages/compiler-cli/src/ngtsc/validation/src/rules/unused_standalone_imports_rule.js
|
|
3844
|
-
import
|
|
3800
|
+
import ts25 from "typescript";
|
|
3845
3801
|
var UnusedStandaloneImportsRule = class {
|
|
3846
3802
|
templateTypeChecker;
|
|
3847
3803
|
typeCheckingConfig;
|
|
@@ -3855,7 +3811,7 @@ var UnusedStandaloneImportsRule = class {
|
|
|
3855
3811
|
return this.typeCheckingConfig.unusedStandaloneImports !== "suppress" && (this.importedSymbolsTracker.hasNamedImport(sourceFile, "Component", "@angular/core") || this.importedSymbolsTracker.hasNamespaceImport(sourceFile, "@angular/core"));
|
|
3856
3812
|
}
|
|
3857
3813
|
checkNode(node) {
|
|
3858
|
-
if (!
|
|
3814
|
+
if (!ts25.isClassDeclaration(node)) {
|
|
3859
3815
|
return null;
|
|
3860
3816
|
}
|
|
3861
3817
|
const metadata = this.templateTypeChecker.getDirectiveMetadata(node);
|
|
@@ -3871,8 +3827,8 @@ var UnusedStandaloneImportsRule = class {
|
|
|
3871
3827
|
if (unused === null) {
|
|
3872
3828
|
return null;
|
|
3873
3829
|
}
|
|
3874
|
-
const propertyAssignment = closestNode(metadata.rawImports,
|
|
3875
|
-
const category = this.typeCheckingConfig.unusedStandaloneImports === "error" ?
|
|
3830
|
+
const propertyAssignment = closestNode(metadata.rawImports, ts25.isPropertyAssignment);
|
|
3831
|
+
const category = this.typeCheckingConfig.unusedStandaloneImports === "error" ? ts25.DiagnosticCategory.Error : ts25.DiagnosticCategory.Warning;
|
|
3876
3832
|
if (unused.length === metadata.imports.length && propertyAssignment !== null) {
|
|
3877
3833
|
return makeDiagnostic(ErrorCode.UNUSED_STANDALONE_IMPORTS, propertyAssignment.name, "All imports are unused", void 0, category);
|
|
3878
3834
|
}
|
|
@@ -3916,8 +3872,8 @@ var UnusedStandaloneImportsRule = class {
|
|
|
3916
3872
|
}
|
|
3917
3873
|
let current = reference.getIdentityIn(rawImports.getSourceFile());
|
|
3918
3874
|
while (current !== null) {
|
|
3919
|
-
if (
|
|
3920
|
-
return !!current.modifiers?.some((m) => m.kind ===
|
|
3875
|
+
if (ts25.isVariableStatement(current)) {
|
|
3876
|
+
return !!current.modifiers?.some((m) => m.kind === ts25.SyntaxKind.ExportKeyword);
|
|
3921
3877
|
}
|
|
3922
3878
|
current = current.parent ?? null;
|
|
3923
3879
|
}
|
|
@@ -3937,7 +3893,7 @@ function closestNode(start, predicate) {
|
|
|
3937
3893
|
}
|
|
3938
3894
|
|
|
3939
3895
|
// packages/compiler-cli/src/ngtsc/validation/src/rules/forbidden_required_initializer_invocation_rule.js
|
|
3940
|
-
import
|
|
3896
|
+
import ts26 from "typescript";
|
|
3941
3897
|
var APIS_TO_CHECK2 = [
|
|
3942
3898
|
INPUT_INITIALIZER_FN,
|
|
3943
3899
|
MODEL_INITIALIZER_FN,
|
|
@@ -3956,12 +3912,12 @@ var ForbiddenRequiredInitializersInvocationRule = class {
|
|
|
3956
3912
|
});
|
|
3957
3913
|
}
|
|
3958
3914
|
checkNode(node) {
|
|
3959
|
-
if (!
|
|
3915
|
+
if (!ts26.isClassDeclaration(node))
|
|
3960
3916
|
return null;
|
|
3961
|
-
const requiredInitializerDeclarations = node.members.filter((m) =>
|
|
3917
|
+
const requiredInitializerDeclarations = node.members.filter((m) => ts26.isPropertyDeclaration(m) && this.isPropDeclarationARequiredInitializer(m));
|
|
3962
3918
|
const diagnostics = [];
|
|
3963
3919
|
for (let decl of node.members) {
|
|
3964
|
-
if (!
|
|
3920
|
+
if (!ts26.isPropertyDeclaration(decl))
|
|
3965
3921
|
continue;
|
|
3966
3922
|
const initiallizerExpr = decl.initializer;
|
|
3967
3923
|
if (!initiallizerExpr)
|
|
@@ -3969,10 +3925,10 @@ var ForbiddenRequiredInitializersInvocationRule = class {
|
|
|
3969
3925
|
checkForbiddenInvocation(initiallizerExpr);
|
|
3970
3926
|
}
|
|
3971
3927
|
function checkForbiddenInvocation(node2) {
|
|
3972
|
-
if (
|
|
3928
|
+
if (ts26.isArrowFunction(node2) || ts26.isFunctionExpression(node2))
|
|
3973
3929
|
return;
|
|
3974
|
-
if (
|
|
3975
|
-
|
|
3930
|
+
if (ts26.isPropertyAccessExpression(node2) && node2.expression.kind === ts26.SyntaxKind.ThisKeyword && // With the following we make sure we only flag invoked required initializers
|
|
3931
|
+
ts26.isCallExpression(node2.parent) && node2.parent.expression === node2) {
|
|
3976
3932
|
const requiredProp = requiredInitializerDeclarations.find((prop) => prop.name.getText() === node2.name.getText());
|
|
3977
3933
|
if (requiredProp) {
|
|
3978
3934
|
const initializerFn = requiredProp.initializer.expression.expression.getText();
|
|
@@ -3997,7 +3953,7 @@ var ForbiddenRequiredInitializersInvocationRule = class {
|
|
|
3997
3953
|
}
|
|
3998
3954
|
};
|
|
3999
3955
|
function getConstructorFromClass(node) {
|
|
4000
|
-
return node.members.find((m) =>
|
|
3956
|
+
return node.members.find((m) => ts26.isConstructorDeclaration(m) && m.body !== void 0);
|
|
4001
3957
|
}
|
|
4002
3958
|
|
|
4003
3959
|
// packages/compiler-cli/src/ngtsc/validation/src/source_file_validator.js
|
|
@@ -4206,7 +4162,7 @@ var NgCompiler = class _NgCompiler {
|
|
|
4206
4162
|
this.currentProgram = inputProgram;
|
|
4207
4163
|
this.closureCompilerEnabled = !!this.options.annotateForClosureCompiler;
|
|
4208
4164
|
this.entryPoint = adapter.entryPoint !== null ? getSourceFileOrNull(inputProgram, adapter.entryPoint) : null;
|
|
4209
|
-
const moduleResolutionCache =
|
|
4165
|
+
const moduleResolutionCache = ts27.createModuleResolutionCache(
|
|
4210
4166
|
this.adapter.getCurrentDirectory(),
|
|
4211
4167
|
// doen't retain a reference to `this`, if other closures in the constructor here reference
|
|
4212
4168
|
// `this` internally then a closure created here would retain them. This can cause major
|
|
@@ -4254,7 +4210,7 @@ var NgCompiler = class _NgCompiler {
|
|
|
4254
4210
|
}
|
|
4255
4211
|
for (const clazz of classesToUpdate) {
|
|
4256
4212
|
this.compilation.traitCompiler.updateResources(clazz);
|
|
4257
|
-
if (!
|
|
4213
|
+
if (!ts27.isClassDeclaration(clazz)) {
|
|
4258
4214
|
continue;
|
|
4259
4215
|
}
|
|
4260
4216
|
this.compilation.templateTypeChecker.invalidateClass(clazz);
|
|
@@ -4464,12 +4420,12 @@ var NgCompiler = class _NgCompiler {
|
|
|
4464
4420
|
if (compilation.supportJitMode && compilation.jitDeclarationRegistry.jitDeclarations.size > 0) {
|
|
4465
4421
|
const { jitDeclarations } = compilation.jitDeclarationRegistry;
|
|
4466
4422
|
const jitDeclarationsArray = Array.from(jitDeclarations);
|
|
4467
|
-
const jitDeclarationOriginalNodes = new Set(jitDeclarationsArray.map((d) =>
|
|
4423
|
+
const jitDeclarationOriginalNodes = new Set(jitDeclarationsArray.map((d) => ts27.getOriginalNode(d)));
|
|
4468
4424
|
const sourceFilesWithJit = new Set(jitDeclarationsArray.map((d) => d.getSourceFile().fileName));
|
|
4469
4425
|
before.push((ctx) => {
|
|
4470
4426
|
const reflectionHost = new TypeScriptReflectionHost(this.inputProgram.getTypeChecker());
|
|
4471
4427
|
const jitTransform = angularJitApplicationTransform(this.inputProgram, compilation.isCore, (node) => {
|
|
4472
|
-
node =
|
|
4428
|
+
node = ts27.getOriginalNode(node, ts27.isClassDeclaration);
|
|
4473
4429
|
return reflectionHost.isClass(node) && jitDeclarationOriginalNodes.has(node);
|
|
4474
4430
|
})(ctx);
|
|
4475
4431
|
return (sourceFile) => {
|
|
@@ -4548,16 +4504,16 @@ var NgCompiler = class _NgCompiler {
|
|
|
4548
4504
|
return null;
|
|
4549
4505
|
}
|
|
4550
4506
|
const sourceFile = node.getSourceFile();
|
|
4551
|
-
const printer =
|
|
4552
|
-
const nodeText = printer.printNode(
|
|
4553
|
-
return
|
|
4507
|
+
const printer = ts27.createPrinter();
|
|
4508
|
+
const nodeText = printer.printNode(ts27.EmitHint.Unspecified, callback, sourceFile);
|
|
4509
|
+
return ts27.transpileModule(nodeText, {
|
|
4554
4510
|
compilerOptions: {
|
|
4555
4511
|
...this.options,
|
|
4556
4512
|
// Some module types can produce additional code (see #60795) whereas we need the
|
|
4557
4513
|
// HMR update module to use a native `export`. Override the `target` and `module`
|
|
4558
4514
|
// to ensure that it looks as expected.
|
|
4559
|
-
module:
|
|
4560
|
-
target:
|
|
4515
|
+
module: ts27.ModuleKind.ES2022,
|
|
4516
|
+
target: ts27.ScriptTarget.ES2022
|
|
4561
4517
|
},
|
|
4562
4518
|
fileName: sourceFile.fileName,
|
|
4563
4519
|
reportDiagnostics: false
|
|
@@ -4933,18 +4889,18 @@ function isAngularCorePackage(program) {
|
|
|
4933
4889
|
return false;
|
|
4934
4890
|
}
|
|
4935
4891
|
return r3Symbols.statements.some((stmt) => {
|
|
4936
|
-
if (!
|
|
4892
|
+
if (!ts27.isVariableStatement(stmt)) {
|
|
4937
4893
|
return false;
|
|
4938
4894
|
}
|
|
4939
|
-
const modifiers =
|
|
4940
|
-
if (modifiers === void 0 || !modifiers.some((mod) => mod.kind ===
|
|
4895
|
+
const modifiers = ts27.getModifiers(stmt);
|
|
4896
|
+
if (modifiers === void 0 || !modifiers.some((mod) => mod.kind === ts27.SyntaxKind.ExportKeyword)) {
|
|
4941
4897
|
return false;
|
|
4942
4898
|
}
|
|
4943
4899
|
return stmt.declarationList.declarations.some((decl) => {
|
|
4944
|
-
if (!
|
|
4900
|
+
if (!ts27.isIdentifier(decl.name) || decl.name.text !== "ITS_JUST_ANGULAR") {
|
|
4945
4901
|
return false;
|
|
4946
4902
|
}
|
|
4947
|
-
if (decl.initializer === void 0 || decl.initializer.kind !==
|
|
4903
|
+
if (decl.initializer === void 0 || decl.initializer.kind !== ts27.SyntaxKind.TrueKeyword) {
|
|
4948
4904
|
return false;
|
|
4949
4905
|
}
|
|
4950
4906
|
return true;
|
|
@@ -4957,7 +4913,7 @@ function getR3SymbolsFile(program) {
|
|
|
4957
4913
|
function* verifyCompatibleTypeCheckOptions(options) {
|
|
4958
4914
|
if (options.fullTemplateTypeCheck === false && options.strictTemplates === true) {
|
|
4959
4915
|
yield makeConfigDiagnostic({
|
|
4960
|
-
category:
|
|
4916
|
+
category: ts27.DiagnosticCategory.Error,
|
|
4961
4917
|
code: ErrorCode.CONFIG_STRICT_TEMPLATES_IMPLIES_FULL_TEMPLATE_TYPECHECK,
|
|
4962
4918
|
messageText: `
|
|
4963
4919
|
Angular compiler option "strictTemplates" is enabled, however "fullTemplateTypeCheck" is disabled.
|
|
@@ -4976,7 +4932,7 @@ https://angular.dev/tools/cli/template-typecheck
|
|
|
4976
4932
|
}
|
|
4977
4933
|
if (options.extendedDiagnostics && options.strictTemplates === false) {
|
|
4978
4934
|
yield makeConfigDiagnostic({
|
|
4979
|
-
category:
|
|
4935
|
+
category: ts27.DiagnosticCategory.Error,
|
|
4980
4936
|
code: ErrorCode.CONFIG_EXTENDED_DIAGNOSTICS_IMPLIES_STRICT_TEMPLATES,
|
|
4981
4937
|
messageText: `
|
|
4982
4938
|
Angular compiler option "extendedDiagnostics" is configured, however "strictTemplates" is disabled.
|
|
@@ -4993,7 +4949,7 @@ One of the following actions is required:
|
|
|
4993
4949
|
const defaultCategory = options.extendedDiagnostics?.defaultCategory;
|
|
4994
4950
|
if (defaultCategory && !allowedCategoryLabels.includes(defaultCategory)) {
|
|
4995
4951
|
yield makeConfigDiagnostic({
|
|
4996
|
-
category:
|
|
4952
|
+
category: ts27.DiagnosticCategory.Error,
|
|
4997
4953
|
code: ErrorCode.CONFIG_EXTENDED_DIAGNOSTICS_UNKNOWN_CATEGORY_LABEL,
|
|
4998
4954
|
messageText: `
|
|
4999
4955
|
Angular compiler option "extendedDiagnostics.defaultCategory" has an unknown diagnostic category: "${defaultCategory}".
|
|
@@ -5006,7 +4962,7 @@ ${allowedCategoryLabels.join("\n")}
|
|
|
5006
4962
|
for (const [checkName, category] of Object.entries(options.extendedDiagnostics?.checks ?? {})) {
|
|
5007
4963
|
if (!SUPPORTED_DIAGNOSTIC_NAMES.has(checkName)) {
|
|
5008
4964
|
yield makeConfigDiagnostic({
|
|
5009
|
-
category:
|
|
4965
|
+
category: ts27.DiagnosticCategory.Error,
|
|
5010
4966
|
code: ErrorCode.CONFIG_EXTENDED_DIAGNOSTICS_UNKNOWN_CHECK,
|
|
5011
4967
|
messageText: `
|
|
5012
4968
|
Angular compiler option "extendedDiagnostics.checks" has an unknown check: "${checkName}".
|
|
@@ -5018,7 +4974,7 @@ ${Array.from(SUPPORTED_DIAGNOSTIC_NAMES).join("\n")}
|
|
|
5018
4974
|
}
|
|
5019
4975
|
if (!allowedCategoryLabels.includes(category)) {
|
|
5020
4976
|
yield makeConfigDiagnostic({
|
|
5021
|
-
category:
|
|
4977
|
+
category: ts27.DiagnosticCategory.Error,
|
|
5022
4978
|
code: ErrorCode.CONFIG_EXTENDED_DIAGNOSTICS_UNKNOWN_CATEGORY_LABEL,
|
|
5023
4979
|
messageText: `
|
|
5024
4980
|
Angular compiler option "extendedDiagnostics.checks['${checkName}']" has an unknown diagnostic category: "${category}".
|
|
@@ -5036,7 +4992,7 @@ function verifyEmitDeclarationOnly(options) {
|
|
|
5036
4992
|
}
|
|
5037
4993
|
return [
|
|
5038
4994
|
makeConfigDiagnostic({
|
|
5039
|
-
category:
|
|
4995
|
+
category: ts27.DiagnosticCategory.Error,
|
|
5040
4996
|
code: ErrorCode.CONFIG_EMIT_DECLARATION_ONLY_UNSUPPORTED,
|
|
5041
4997
|
messageText: 'TS compiler option "emitDeclarationOnly" is not supported.'
|
|
5042
4998
|
})
|
|
@@ -5061,7 +5017,7 @@ var ReferenceGraphAdapter = class {
|
|
|
5061
5017
|
for (const { node } of references) {
|
|
5062
5018
|
let sourceFile = node.getSourceFile();
|
|
5063
5019
|
if (sourceFile === void 0) {
|
|
5064
|
-
sourceFile =
|
|
5020
|
+
sourceFile = ts27.getOriginalNode(node).getSourceFile();
|
|
5065
5021
|
}
|
|
5066
5022
|
if (sourceFile === void 0 || !isDtsPath(sourceFile.fileName)) {
|
|
5067
5023
|
this.graph.add(source, node);
|
|
@@ -5102,7 +5058,7 @@ function versionMapFromProgram(program, driver) {
|
|
|
5102
5058
|
}
|
|
5103
5059
|
|
|
5104
5060
|
// packages/compiler-cli/src/ngtsc/core/src/host.js
|
|
5105
|
-
import
|
|
5061
|
+
import ts28 from "typescript";
|
|
5106
5062
|
var DelegatingCompilerHost = class {
|
|
5107
5063
|
delegate;
|
|
5108
5064
|
createHash;
|
|
@@ -5241,7 +5197,7 @@ var NgCompilerHost = class _NgCompilerHost extends DelegatingCompilerHost {
|
|
|
5241
5197
|
entryPoint = findFlatIndexEntryPoint(normalizedTsInputFiles);
|
|
5242
5198
|
if (entryPoint === null) {
|
|
5243
5199
|
diagnostics.push({
|
|
5244
|
-
category:
|
|
5200
|
+
category: ts28.DiagnosticCategory.Error,
|
|
5245
5201
|
code: ngErrorCode(ErrorCode.CONFIG_FLAT_MODULE_NO_INDEX),
|
|
5246
5202
|
file: void 0,
|
|
5247
5203
|
start: void 0,
|
|
@@ -5295,501 +5251,31 @@ var NgCompilerHost = class _NgCompilerHost extends DelegatingCompilerHost {
|
|
|
5295
5251
|
return this.fileNameToModuleName !== void 0 ? this : null;
|
|
5296
5252
|
}
|
|
5297
5253
|
createCachedResolveModuleNamesFunction() {
|
|
5298
|
-
const moduleResolutionCache =
|
|
5254
|
+
const moduleResolutionCache = ts28.createModuleResolutionCache(this.getCurrentDirectory(), this.getCanonicalFileName.bind(this));
|
|
5299
5255
|
return (moduleNames, containingFile, reusedNames, redirectedReference, options) => {
|
|
5300
5256
|
return moduleNames.map((moduleName) => {
|
|
5301
|
-
const module =
|
|
5257
|
+
const module = ts28.resolveModuleName(moduleName, containingFile, options, this, moduleResolutionCache, redirectedReference);
|
|
5302
5258
|
return module.resolvedModule;
|
|
5303
5259
|
});
|
|
5304
5260
|
};
|
|
5305
5261
|
}
|
|
5306
5262
|
};
|
|
5307
5263
|
|
|
5308
|
-
// packages/compiler-cli/src/ngtsc/program.js
|
|
5309
|
-
var NgtscProgram = class {
|
|
5310
|
-
options;
|
|
5311
|
-
compiler;
|
|
5312
|
-
/**
|
|
5313
|
-
* The primary TypeScript program, which is used for analysis and emit.
|
|
5314
|
-
*/
|
|
5315
|
-
tsProgram;
|
|
5316
|
-
host;
|
|
5317
|
-
incrementalStrategy;
|
|
5318
|
-
constructor(rootNames, options, delegateHost, oldProgram) {
|
|
5319
|
-
this.options = options;
|
|
5320
|
-
const perfRecorder = ActivePerfRecorder.zeroedToNow();
|
|
5321
|
-
perfRecorder.phase(PerfPhase.Setup);
|
|
5322
|
-
if (!options.disableTypeScriptVersionCheck) {
|
|
5323
|
-
verifySupportedTypeScriptVersion();
|
|
5324
|
-
}
|
|
5325
|
-
if (options.compilationMode === "experimental-local") {
|
|
5326
|
-
options.noEmitOnError = false;
|
|
5327
|
-
}
|
|
5328
|
-
const reuseProgram = oldProgram?.compiler.getCurrentProgram();
|
|
5329
|
-
this.host = NgCompilerHost.wrap(delegateHost, rootNames, options, reuseProgram ?? null);
|
|
5330
|
-
if (reuseProgram !== void 0) {
|
|
5331
|
-
retagAllTsFiles(reuseProgram);
|
|
5332
|
-
}
|
|
5333
|
-
this.tsProgram = perfRecorder.inPhase(PerfPhase.TypeScriptProgramCreate, () => ts30.createProgram(this.host.inputFiles, options, this.host, reuseProgram));
|
|
5334
|
-
perfRecorder.phase(PerfPhase.Unaccounted);
|
|
5335
|
-
perfRecorder.memory(PerfCheckpoint.TypeScriptProgramCreate);
|
|
5336
|
-
this.host.postProgramCreationCleanup();
|
|
5337
|
-
const programDriver = new TsCreateProgramDriver(this.tsProgram, this.host, this.options, this.host.shimExtensionPrefixes);
|
|
5338
|
-
this.incrementalStrategy = oldProgram !== void 0 ? oldProgram.incrementalStrategy.toNextBuildStrategy() : new TrackedIncrementalBuildStrategy();
|
|
5339
|
-
const modifiedResourceFiles = /* @__PURE__ */ new Set();
|
|
5340
|
-
if (this.host.getModifiedResourceFiles !== void 0) {
|
|
5341
|
-
const strings = this.host.getModifiedResourceFiles();
|
|
5342
|
-
if (strings !== void 0) {
|
|
5343
|
-
for (const fileString of strings) {
|
|
5344
|
-
modifiedResourceFiles.add(absoluteFrom(fileString));
|
|
5345
|
-
}
|
|
5346
|
-
}
|
|
5347
|
-
}
|
|
5348
|
-
let ticket;
|
|
5349
|
-
if (oldProgram === void 0) {
|
|
5350
|
-
ticket = freshCompilationTicket(
|
|
5351
|
-
this.tsProgram,
|
|
5352
|
-
options,
|
|
5353
|
-
this.incrementalStrategy,
|
|
5354
|
-
programDriver,
|
|
5355
|
-
perfRecorder,
|
|
5356
|
-
/* enableTemplateTypeChecker */
|
|
5357
|
-
false,
|
|
5358
|
-
/* usePoisonedData */
|
|
5359
|
-
false
|
|
5360
|
-
);
|
|
5361
|
-
} else {
|
|
5362
|
-
ticket = incrementalFromCompilerTicket(oldProgram.compiler, this.tsProgram, this.incrementalStrategy, programDriver, modifiedResourceFiles, perfRecorder);
|
|
5363
|
-
}
|
|
5364
|
-
this.compiler = NgCompiler.fromTicket(ticket, this.host);
|
|
5365
|
-
}
|
|
5366
|
-
getTsProgram() {
|
|
5367
|
-
return this.tsProgram;
|
|
5368
|
-
}
|
|
5369
|
-
getReuseTsProgram() {
|
|
5370
|
-
return this.compiler.getCurrentProgram();
|
|
5371
|
-
}
|
|
5372
|
-
getTsOptionDiagnostics(cancellationToken) {
|
|
5373
|
-
return this.compiler.perfRecorder.inPhase(PerfPhase.TypeScriptDiagnostics, () => this.tsProgram.getOptionsDiagnostics(cancellationToken));
|
|
5374
|
-
}
|
|
5375
|
-
getTsSyntacticDiagnostics(sourceFile, cancellationToken) {
|
|
5376
|
-
return this.compiler.perfRecorder.inPhase(PerfPhase.TypeScriptDiagnostics, () => {
|
|
5377
|
-
const ignoredFiles = this.compiler.ignoreForDiagnostics;
|
|
5378
|
-
let res;
|
|
5379
|
-
if (sourceFile !== void 0) {
|
|
5380
|
-
if (ignoredFiles.has(sourceFile)) {
|
|
5381
|
-
return [];
|
|
5382
|
-
}
|
|
5383
|
-
res = this.tsProgram.getSyntacticDiagnostics(sourceFile, cancellationToken);
|
|
5384
|
-
} else {
|
|
5385
|
-
const diagnostics = [];
|
|
5386
|
-
for (const sf of this.tsProgram.getSourceFiles()) {
|
|
5387
|
-
if (!ignoredFiles.has(sf)) {
|
|
5388
|
-
diagnostics.push(...this.tsProgram.getSyntacticDiagnostics(sf, cancellationToken));
|
|
5389
|
-
}
|
|
5390
|
-
}
|
|
5391
|
-
res = diagnostics;
|
|
5392
|
-
}
|
|
5393
|
-
return res;
|
|
5394
|
-
});
|
|
5395
|
-
}
|
|
5396
|
-
getTsSemanticDiagnostics(sourceFile, cancellationToken) {
|
|
5397
|
-
if (this.options.compilationMode === "experimental-local") {
|
|
5398
|
-
return [];
|
|
5399
|
-
}
|
|
5400
|
-
return this.compiler.perfRecorder.inPhase(PerfPhase.TypeScriptDiagnostics, () => {
|
|
5401
|
-
const ignoredFiles = this.compiler.ignoreForDiagnostics;
|
|
5402
|
-
let res;
|
|
5403
|
-
if (sourceFile !== void 0) {
|
|
5404
|
-
if (ignoredFiles.has(sourceFile)) {
|
|
5405
|
-
return [];
|
|
5406
|
-
}
|
|
5407
|
-
res = this.tsProgram.getSemanticDiagnostics(sourceFile, cancellationToken);
|
|
5408
|
-
} else {
|
|
5409
|
-
const diagnostics = [];
|
|
5410
|
-
for (const sf of this.tsProgram.getSourceFiles()) {
|
|
5411
|
-
if (!ignoredFiles.has(sf)) {
|
|
5412
|
-
diagnostics.push(...this.tsProgram.getSemanticDiagnostics(sf, cancellationToken));
|
|
5413
|
-
}
|
|
5414
|
-
}
|
|
5415
|
-
res = diagnostics;
|
|
5416
|
-
}
|
|
5417
|
-
return res;
|
|
5418
|
-
});
|
|
5419
|
-
}
|
|
5420
|
-
getNgOptionDiagnostics(cancellationToken) {
|
|
5421
|
-
return this.compiler.getOptionDiagnostics();
|
|
5422
|
-
}
|
|
5423
|
-
getNgStructuralDiagnostics(cancellationToken) {
|
|
5424
|
-
return [];
|
|
5425
|
-
}
|
|
5426
|
-
getNgSemanticDiagnostics(fileName, cancellationToken) {
|
|
5427
|
-
let sf = void 0;
|
|
5428
|
-
if (fileName !== void 0) {
|
|
5429
|
-
sf = this.tsProgram.getSourceFile(fileName);
|
|
5430
|
-
if (sf === void 0) {
|
|
5431
|
-
return [];
|
|
5432
|
-
}
|
|
5433
|
-
}
|
|
5434
|
-
if (sf === void 0) {
|
|
5435
|
-
return this.compiler.getDiagnostics();
|
|
5436
|
-
} else {
|
|
5437
|
-
return this.compiler.getDiagnosticsForFile(sf, OptimizeFor.WholeProgram);
|
|
5438
|
-
}
|
|
5439
|
-
}
|
|
5440
|
-
/**
|
|
5441
|
-
* Ensure that the `NgCompiler` has properly analyzed the program, and allow for the asynchronous
|
|
5442
|
-
* loading of any resources during the process.
|
|
5443
|
-
*
|
|
5444
|
-
* This is used by the Angular CLI to allow for spawning (async) child compilations for things
|
|
5445
|
-
* like SASS files used in `styleUrls`.
|
|
5446
|
-
*/
|
|
5447
|
-
loadNgStructureAsync() {
|
|
5448
|
-
return this.compiler.analyzeAsync();
|
|
5449
|
-
}
|
|
5450
|
-
listLazyRoutes(entryRoute) {
|
|
5451
|
-
return [];
|
|
5452
|
-
}
|
|
5453
|
-
emitXi18n() {
|
|
5454
|
-
const ctx = new MessageBundle(new HtmlParser(), [], {}, this.options.i18nOutLocale ?? null, this.options.i18nPreserveWhitespaceForLegacyExtraction);
|
|
5455
|
-
this.compiler.xi18n(ctx);
|
|
5456
|
-
i18nExtract(this.options.i18nOutFormat ?? null, this.options.i18nOutFile ?? null, this.host, this.options, ctx, resolve);
|
|
5457
|
-
}
|
|
5458
|
-
emit(opts) {
|
|
5459
|
-
if (opts !== void 0 && opts.emitFlags !== void 0 && opts.emitFlags & EmitFlags.I18nBundle) {
|
|
5460
|
-
this.emitXi18n();
|
|
5461
|
-
if (!(opts.emitFlags & EmitFlags.JS)) {
|
|
5462
|
-
return {
|
|
5463
|
-
diagnostics: [],
|
|
5464
|
-
emitSkipped: true,
|
|
5465
|
-
emittedFiles: []
|
|
5466
|
-
};
|
|
5467
|
-
}
|
|
5468
|
-
}
|
|
5469
|
-
const forceEmit = opts?.forceEmit ?? false;
|
|
5470
|
-
this.compiler.perfRecorder.memory(PerfCheckpoint.PreEmit);
|
|
5471
|
-
const res = this.compiler.perfRecorder.inPhase(PerfPhase.TypeScriptEmit, () => {
|
|
5472
|
-
const { transformers } = this.compiler.prepareEmit();
|
|
5473
|
-
const ignoreFiles = this.compiler.ignoreForEmit;
|
|
5474
|
-
const emitCallback = opts?.emitCallback ?? defaultEmitCallback;
|
|
5475
|
-
const writeFile = (fileName, data, writeByteOrderMark, onError, sourceFiles) => {
|
|
5476
|
-
if (sourceFiles !== void 0) {
|
|
5477
|
-
for (const writtenSf of sourceFiles) {
|
|
5478
|
-
if (writtenSf.isDeclarationFile) {
|
|
5479
|
-
continue;
|
|
5480
|
-
}
|
|
5481
|
-
this.compiler.incrementalCompilation.recordSuccessfulEmit(writtenSf);
|
|
5482
|
-
}
|
|
5483
|
-
}
|
|
5484
|
-
this.host.writeFile(fileName, data, writeByteOrderMark, onError, sourceFiles);
|
|
5485
|
-
};
|
|
5486
|
-
const customTransforms = opts && opts.customTransformers;
|
|
5487
|
-
const beforeTransforms = transformers.before || [];
|
|
5488
|
-
const afterDeclarationsTransforms = transformers.afterDeclarations;
|
|
5489
|
-
if (customTransforms !== void 0 && customTransforms.beforeTs !== void 0) {
|
|
5490
|
-
beforeTransforms.push(...customTransforms.beforeTs);
|
|
5491
|
-
}
|
|
5492
|
-
const emitResults = [];
|
|
5493
|
-
for (const targetSourceFile of this.tsProgram.getSourceFiles()) {
|
|
5494
|
-
if (targetSourceFile.isDeclarationFile || ignoreFiles.has(targetSourceFile)) {
|
|
5495
|
-
continue;
|
|
5496
|
-
}
|
|
5497
|
-
if (!forceEmit && this.compiler.incrementalCompilation.safeToSkipEmit(targetSourceFile)) {
|
|
5498
|
-
this.compiler.perfRecorder.eventCount(PerfEvent.EmitSkipSourceFile);
|
|
5499
|
-
continue;
|
|
5500
|
-
}
|
|
5501
|
-
this.compiler.perfRecorder.eventCount(PerfEvent.EmitSourceFile);
|
|
5502
|
-
emitResults.push(emitCallback({
|
|
5503
|
-
targetSourceFile,
|
|
5504
|
-
program: this.tsProgram,
|
|
5505
|
-
host: this.host,
|
|
5506
|
-
options: this.options,
|
|
5507
|
-
emitOnlyDtsFiles: false,
|
|
5508
|
-
writeFile,
|
|
5509
|
-
customTransformers: {
|
|
5510
|
-
before: beforeTransforms,
|
|
5511
|
-
after: customTransforms && customTransforms.afterTs,
|
|
5512
|
-
afterDeclarations: afterDeclarationsTransforms
|
|
5513
|
-
}
|
|
5514
|
-
}));
|
|
5515
|
-
}
|
|
5516
|
-
this.compiler.perfRecorder.memory(PerfCheckpoint.Emit);
|
|
5517
|
-
return (opts && opts.mergeEmitResultsCallback || mergeEmitResults)(emitResults);
|
|
5518
|
-
});
|
|
5519
|
-
if (this.options.tracePerformance !== void 0) {
|
|
5520
|
-
const perf = this.compiler.perfRecorder.finalize();
|
|
5521
|
-
getFileSystem().writeFile(getFileSystem().resolve(this.options.tracePerformance), JSON.stringify(perf, null, 2));
|
|
5522
|
-
}
|
|
5523
|
-
return res;
|
|
5524
|
-
}
|
|
5525
|
-
getIndexedComponents() {
|
|
5526
|
-
return this.compiler.getIndexedComponents();
|
|
5527
|
-
}
|
|
5528
|
-
/**
|
|
5529
|
-
* Gets information for the current program that may be used to generate API
|
|
5530
|
-
* reference documentation. This includes Angular-specific information, such
|
|
5531
|
-
* as component inputs and outputs.
|
|
5532
|
-
*
|
|
5533
|
-
* @param entryPoint Path to the entry point for the package for which API
|
|
5534
|
-
* docs should be extracted.
|
|
5535
|
-
*/
|
|
5536
|
-
getApiDocumentation(entryPoint, privateModules) {
|
|
5537
|
-
return this.compiler.getApiDocumentation(entryPoint, privateModules);
|
|
5538
|
-
}
|
|
5539
|
-
getEmittedSourceFiles() {
|
|
5540
|
-
throw new Error("Method not implemented.");
|
|
5541
|
-
}
|
|
5542
|
-
};
|
|
5543
|
-
var defaultEmitCallback = ({ program, targetSourceFile, writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers }) => program.emit(targetSourceFile, writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers);
|
|
5544
|
-
function mergeEmitResults(emitResults) {
|
|
5545
|
-
const diagnostics = [];
|
|
5546
|
-
let emitSkipped = false;
|
|
5547
|
-
const emittedFiles = [];
|
|
5548
|
-
for (const er of emitResults) {
|
|
5549
|
-
diagnostics.push(...er.diagnostics);
|
|
5550
|
-
emitSkipped = emitSkipped || er.emitSkipped;
|
|
5551
|
-
emittedFiles.push(...er.emittedFiles || []);
|
|
5552
|
-
}
|
|
5553
|
-
return { diagnostics, emitSkipped, emittedFiles };
|
|
5554
|
-
}
|
|
5555
|
-
|
|
5556
|
-
// packages/compiler-cli/src/transformers/program.js
|
|
5557
|
-
function createProgram({ rootNames, options, host, oldProgram }) {
|
|
5558
|
-
return new NgtscProgram(rootNames, options, host, oldProgram);
|
|
5559
|
-
}
|
|
5560
|
-
|
|
5561
|
-
// packages/compiler-cli/src/perform_compile.js
|
|
5562
|
-
import ts32 from "typescript";
|
|
5563
|
-
|
|
5564
|
-
// packages/compiler-cli/src/transformers/util.js
|
|
5565
|
-
import ts31 from "typescript";
|
|
5566
|
-
function createMessageDiagnostic(messageText) {
|
|
5567
|
-
return {
|
|
5568
|
-
file: void 0,
|
|
5569
|
-
start: void 0,
|
|
5570
|
-
length: void 0,
|
|
5571
|
-
category: ts31.DiagnosticCategory.Message,
|
|
5572
|
-
messageText,
|
|
5573
|
-
code: DEFAULT_ERROR_CODE,
|
|
5574
|
-
source: SOURCE
|
|
5575
|
-
};
|
|
5576
|
-
}
|
|
5577
|
-
|
|
5578
|
-
// packages/compiler-cli/src/perform_compile.js
|
|
5579
|
-
var defaultFormatHost = {
|
|
5580
|
-
getCurrentDirectory: () => ts32.sys.getCurrentDirectory(),
|
|
5581
|
-
getCanonicalFileName: (fileName) => fileName,
|
|
5582
|
-
getNewLine: () => ts32.sys.newLine
|
|
5583
|
-
};
|
|
5584
|
-
function formatDiagnostics(diags, host = defaultFormatHost) {
|
|
5585
|
-
if (diags && diags.length) {
|
|
5586
|
-
return diags.map((diagnostic) => replaceTsWithNgInErrors(ts32.formatDiagnosticsWithColorAndContext([diagnostic], host))).join("");
|
|
5587
|
-
} else {
|
|
5588
|
-
return "";
|
|
5589
|
-
}
|
|
5590
|
-
}
|
|
5591
|
-
function calcProjectFileAndBasePath(project, host = getFileSystem()) {
|
|
5592
|
-
const absProject = host.resolve(project);
|
|
5593
|
-
const projectIsDir = host.lstat(absProject).isDirectory();
|
|
5594
|
-
const projectFile = projectIsDir ? host.join(absProject, "tsconfig.json") : absProject;
|
|
5595
|
-
const projectDir = projectIsDir ? absProject : host.dirname(absProject);
|
|
5596
|
-
const basePath = host.resolve(projectDir);
|
|
5597
|
-
return { projectFile, basePath };
|
|
5598
|
-
}
|
|
5599
|
-
function readConfiguration(project, existingOptions, host = getFileSystem()) {
|
|
5600
|
-
try {
|
|
5601
|
-
const fs = getFileSystem();
|
|
5602
|
-
const readConfigFile = (configFile) => ts32.readConfigFile(configFile, (file) => host.readFile(host.resolve(file)));
|
|
5603
|
-
const readAngularCompilerOptions = (configFile, parentOptions = {}) => {
|
|
5604
|
-
const { config: config2, error: error2 } = readConfigFile(configFile);
|
|
5605
|
-
if (error2) {
|
|
5606
|
-
return parentOptions;
|
|
5607
|
-
}
|
|
5608
|
-
const angularCompilerOptions = config2.angularCompilerOptions ?? config2.bazelOptions?.angularCompilerOptions;
|
|
5609
|
-
let existingNgCompilerOptions = { ...angularCompilerOptions, ...parentOptions };
|
|
5610
|
-
if (!config2.extends) {
|
|
5611
|
-
return existingNgCompilerOptions;
|
|
5612
|
-
}
|
|
5613
|
-
const extendsPaths = typeof config2.extends === "string" ? [config2.extends] : config2.extends;
|
|
5614
|
-
return [...extendsPaths].reverse().reduce((prevOptions, extendsPath) => {
|
|
5615
|
-
const extendedConfigPath = getExtendedConfigPath(configFile, extendsPath, host, fs);
|
|
5616
|
-
return extendedConfigPath === null ? prevOptions : readAngularCompilerOptions(extendedConfigPath, prevOptions);
|
|
5617
|
-
}, existingNgCompilerOptions);
|
|
5618
|
-
};
|
|
5619
|
-
const { projectFile, basePath } = calcProjectFileAndBasePath(project, host);
|
|
5620
|
-
const configFileName = host.resolve(host.pwd(), projectFile);
|
|
5621
|
-
const { config, error } = readConfigFile(projectFile);
|
|
5622
|
-
if (error) {
|
|
5623
|
-
return {
|
|
5624
|
-
project,
|
|
5625
|
-
errors: [error],
|
|
5626
|
-
rootNames: [],
|
|
5627
|
-
options: {},
|
|
5628
|
-
emitFlags: EmitFlags.Default
|
|
5629
|
-
};
|
|
5630
|
-
}
|
|
5631
|
-
const existingCompilerOptions = {
|
|
5632
|
-
genDir: basePath,
|
|
5633
|
-
basePath,
|
|
5634
|
-
...readAngularCompilerOptions(configFileName),
|
|
5635
|
-
...existingOptions
|
|
5636
|
-
};
|
|
5637
|
-
const parseConfigHost = createParseConfigHost(host, fs);
|
|
5638
|
-
const { options, errors, fileNames: rootNames, projectReferences } = ts32.parseJsonConfigFileContent(config, parseConfigHost, basePath, existingCompilerOptions, configFileName);
|
|
5639
|
-
let emitFlags = EmitFlags.Default;
|
|
5640
|
-
if (!(options["skipMetadataEmit"] || options["flatModuleOutFile"])) {
|
|
5641
|
-
emitFlags |= EmitFlags.Metadata;
|
|
5642
|
-
}
|
|
5643
|
-
if (options["skipTemplateCodegen"]) {
|
|
5644
|
-
emitFlags = emitFlags & ~EmitFlags.Codegen;
|
|
5645
|
-
}
|
|
5646
|
-
return { project: projectFile, rootNames, projectReferences, options, errors, emitFlags };
|
|
5647
|
-
} catch (e) {
|
|
5648
|
-
const errors = [
|
|
5649
|
-
{
|
|
5650
|
-
category: ts32.DiagnosticCategory.Error,
|
|
5651
|
-
messageText: e.stack ?? e.message,
|
|
5652
|
-
file: void 0,
|
|
5653
|
-
start: void 0,
|
|
5654
|
-
length: void 0,
|
|
5655
|
-
source: "angular",
|
|
5656
|
-
code: UNKNOWN_ERROR_CODE
|
|
5657
|
-
}
|
|
5658
|
-
];
|
|
5659
|
-
return { project: "", errors, rootNames: [], options: {}, emitFlags: EmitFlags.Default };
|
|
5660
|
-
}
|
|
5661
|
-
}
|
|
5662
|
-
function createParseConfigHost(host, fs = getFileSystem()) {
|
|
5663
|
-
return {
|
|
5664
|
-
fileExists: host.exists.bind(host),
|
|
5665
|
-
readDirectory: createFileSystemTsReadDirectoryFn(fs),
|
|
5666
|
-
readFile: host.readFile.bind(host),
|
|
5667
|
-
useCaseSensitiveFileNames: fs.isCaseSensitive()
|
|
5668
|
-
};
|
|
5669
|
-
}
|
|
5670
|
-
function getExtendedConfigPath(configFile, extendsValue, host, fs) {
|
|
5671
|
-
const result = getExtendedConfigPathWorker(configFile, extendsValue, host, fs);
|
|
5672
|
-
if (result !== null) {
|
|
5673
|
-
return result;
|
|
5674
|
-
}
|
|
5675
|
-
return getExtendedConfigPathWorker(configFile, `${extendsValue}.json`, host, fs);
|
|
5676
|
-
}
|
|
5677
|
-
function getExtendedConfigPathWorker(configFile, extendsValue, host, fs) {
|
|
5678
|
-
if (extendsValue.startsWith(".") || fs.isRooted(extendsValue)) {
|
|
5679
|
-
const extendedConfigPath = host.resolve(host.dirname(configFile), extendsValue);
|
|
5680
|
-
if (host.exists(extendedConfigPath)) {
|
|
5681
|
-
return extendedConfigPath;
|
|
5682
|
-
}
|
|
5683
|
-
} else {
|
|
5684
|
-
const parseConfigHost = createParseConfigHost(host, fs);
|
|
5685
|
-
const { resolvedModule } = ts32.nodeModuleNameResolver(extendsValue, configFile, { moduleResolution: ts32.ModuleResolutionKind.Node10, resolveJsonModule: true }, parseConfigHost);
|
|
5686
|
-
if (resolvedModule) {
|
|
5687
|
-
return absoluteFrom(resolvedModule.resolvedFileName);
|
|
5688
|
-
}
|
|
5689
|
-
}
|
|
5690
|
-
return null;
|
|
5691
|
-
}
|
|
5692
|
-
function exitCodeFromResult(diags) {
|
|
5693
|
-
if (!diags)
|
|
5694
|
-
return 0;
|
|
5695
|
-
if (diags.every((diag) => diag.category !== ts32.DiagnosticCategory.Error)) {
|
|
5696
|
-
return 0;
|
|
5697
|
-
}
|
|
5698
|
-
return diags.some((d) => d.source === "angular" && d.code === UNKNOWN_ERROR_CODE) ? 2 : 1;
|
|
5699
|
-
}
|
|
5700
|
-
function performCompilation({ rootNames, options, host, oldProgram, emitCallback, mergeEmitResultsCallback, gatherDiagnostics = defaultGatherDiagnostics, customTransformers, emitFlags = EmitFlags.Default, forceEmit = false, modifiedResourceFiles = null }) {
|
|
5701
|
-
let program;
|
|
5702
|
-
let emitResult;
|
|
5703
|
-
let allDiagnostics = [];
|
|
5704
|
-
try {
|
|
5705
|
-
if (!host) {
|
|
5706
|
-
host = createCompilerHost({ options });
|
|
5707
|
-
}
|
|
5708
|
-
if (modifiedResourceFiles) {
|
|
5709
|
-
host.getModifiedResourceFiles = () => modifiedResourceFiles;
|
|
5710
|
-
}
|
|
5711
|
-
program = createProgram({ rootNames, host, options, oldProgram });
|
|
5712
|
-
const beforeDiags = Date.now();
|
|
5713
|
-
allDiagnostics.push(...gatherDiagnostics(program));
|
|
5714
|
-
if (options.diagnostics) {
|
|
5715
|
-
const afterDiags = Date.now();
|
|
5716
|
-
allDiagnostics.push(createMessageDiagnostic(`Time for diagnostics: ${afterDiags - beforeDiags}ms.`));
|
|
5717
|
-
}
|
|
5718
|
-
if (!hasErrors(allDiagnostics)) {
|
|
5719
|
-
emitResult = program.emit({
|
|
5720
|
-
emitCallback,
|
|
5721
|
-
mergeEmitResultsCallback,
|
|
5722
|
-
customTransformers,
|
|
5723
|
-
emitFlags,
|
|
5724
|
-
forceEmit
|
|
5725
|
-
});
|
|
5726
|
-
allDiagnostics.push(...emitResult.diagnostics);
|
|
5727
|
-
return { diagnostics: allDiagnostics, program, emitResult };
|
|
5728
|
-
}
|
|
5729
|
-
return { diagnostics: allDiagnostics, program };
|
|
5730
|
-
} catch (e) {
|
|
5731
|
-
program = void 0;
|
|
5732
|
-
allDiagnostics.push({
|
|
5733
|
-
category: ts32.DiagnosticCategory.Error,
|
|
5734
|
-
messageText: e.stack ?? e.message,
|
|
5735
|
-
code: UNKNOWN_ERROR_CODE,
|
|
5736
|
-
file: void 0,
|
|
5737
|
-
start: void 0,
|
|
5738
|
-
length: void 0
|
|
5739
|
-
});
|
|
5740
|
-
return { diagnostics: allDiagnostics, program };
|
|
5741
|
-
}
|
|
5742
|
-
}
|
|
5743
|
-
function defaultGatherDiagnostics(program) {
|
|
5744
|
-
const allDiagnostics = [];
|
|
5745
|
-
function checkDiagnostics(diags) {
|
|
5746
|
-
if (diags) {
|
|
5747
|
-
allDiagnostics.push(...diags);
|
|
5748
|
-
return !hasErrors(diags);
|
|
5749
|
-
}
|
|
5750
|
-
return true;
|
|
5751
|
-
}
|
|
5752
|
-
let checkOtherDiagnostics = true;
|
|
5753
|
-
checkOtherDiagnostics = checkOtherDiagnostics && checkDiagnostics([...program.getTsOptionDiagnostics(), ...program.getNgOptionDiagnostics()]);
|
|
5754
|
-
checkOtherDiagnostics = checkOtherDiagnostics && checkDiagnostics(program.getTsSyntacticDiagnostics());
|
|
5755
|
-
checkOtherDiagnostics = checkOtherDiagnostics && checkDiagnostics([
|
|
5756
|
-
...program.getTsSemanticDiagnostics(),
|
|
5757
|
-
...program.getNgStructuralDiagnostics()
|
|
5758
|
-
]);
|
|
5759
|
-
checkOtherDiagnostics = checkOtherDiagnostics && checkDiagnostics(program.getNgSemanticDiagnostics());
|
|
5760
|
-
return allDiagnostics;
|
|
5761
|
-
}
|
|
5762
|
-
function hasErrors(diags) {
|
|
5763
|
-
return diags.some((d) => d.category === ts32.DiagnosticCategory.Error);
|
|
5764
|
-
}
|
|
5765
|
-
|
|
5766
5264
|
export {
|
|
5767
|
-
DEFAULT_ERROR_CODE,
|
|
5768
|
-
UNKNOWN_ERROR_CODE,
|
|
5769
|
-
SOURCE,
|
|
5770
|
-
isTsDiagnostic,
|
|
5771
|
-
EmitFlags,
|
|
5772
|
-
createCompilerHost,
|
|
5773
5265
|
EntryType,
|
|
5774
5266
|
MemberType,
|
|
5775
5267
|
DecoratorType,
|
|
5776
5268
|
MemberTags,
|
|
5777
5269
|
isDocEntryWithSourceInfo,
|
|
5778
5270
|
DocsExtractor,
|
|
5271
|
+
TrackedIncrementalBuildStrategy,
|
|
5779
5272
|
PatchedProgramIncrementalBuildStrategy,
|
|
5273
|
+
DiagnosticCategoryLabel,
|
|
5780
5274
|
freshCompilationTicket,
|
|
5275
|
+
incrementalFromCompilerTicket,
|
|
5781
5276
|
incrementalFromStateTicket,
|
|
5782
5277
|
NgCompiler,
|
|
5783
|
-
NgCompilerHost
|
|
5784
|
-
NgtscProgram,
|
|
5785
|
-
createProgram,
|
|
5786
|
-
createMessageDiagnostic,
|
|
5787
|
-
formatDiagnostics,
|
|
5788
|
-
calcProjectFileAndBasePath,
|
|
5789
|
-
readConfiguration,
|
|
5790
|
-
exitCodeFromResult,
|
|
5791
|
-
performCompilation,
|
|
5792
|
-
defaultGatherDiagnostics
|
|
5278
|
+
NgCompilerHost
|
|
5793
5279
|
};
|
|
5794
5280
|
/**
|
|
5795
5281
|
* @license
|