@angular/compiler-cli 21.0.0-next.8 → 21.0.0-rc.0
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-ELPMV5DB.js → chunk-3CWKYDQ7.js} +9496 -8947
- package/bundles/chunk-DT6FD4OE.js +1 -1
- package/bundles/{chunk-MVFPDRXS.js → chunk-HSIRUBJU.js} +1 -1
- package/bundles/chunk-ZOLVJRLX.js +644 -0
- package/bundles/{chunk-NBFYHUMW.js → chunk-ZOZ6XVF3.js} +204 -762
- 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 +5 -0
- package/src/ngtsc/docs/src/class_extractor.d.ts +4 -5
- package/src/ngtsc/docs/src/entities.d.ts +7 -2
- package/src/ngtsc/docs/src/interface_extractor.d.ts +11 -0
- package/src/ngtsc/docs/src/properties_extractor.d.ts +96 -0
- package/src/ngtsc/file_system/testing/index.d.ts +12 -0
- package/src/ngtsc/file_system/testing/src/mock_file_system.d.ts +71 -0
- package/src/ngtsc/file_system/testing/src/mock_file_system_native.d.ts +15 -0
- package/src/ngtsc/file_system/testing/src/mock_file_system_posix.d.ts +12 -0
- package/src/ngtsc/file_system/testing/src/mock_file_system_windows.d.ts +12 -0
- package/src/ngtsc/file_system/testing/src/test_helper.d.ts +16 -0
- package/bundles/chunk-WXJFCHPN.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-WXJFCHPN.js";
|
|
8
5
|
import {
|
|
9
6
|
AbsoluteModuleStrategy,
|
|
10
7
|
ActivePerfRecorder,
|
|
@@ -66,13 +63,13 @@ import {
|
|
|
66
63
|
SymbolKind,
|
|
67
64
|
TemplateTypeCheckerImpl,
|
|
68
65
|
TraitCompiler,
|
|
69
|
-
TsCreateProgramDriver,
|
|
70
66
|
TypeCheckScopeRegistry,
|
|
71
67
|
TypeCheckShimGenerator,
|
|
72
68
|
TypeScriptReflectionHost,
|
|
73
69
|
UnifiedModulesAliasingHost,
|
|
74
70
|
UnifiedModulesStrategy,
|
|
75
71
|
aliasTransformFactory,
|
|
72
|
+
angularJitApplicationTransform,
|
|
76
73
|
declarationTransformFactory,
|
|
77
74
|
getRootDirs,
|
|
78
75
|
getSourceFileOrNull,
|
|
@@ -86,52 +83,20 @@ import {
|
|
|
86
83
|
ngErrorCode,
|
|
87
84
|
normalizeSeparators,
|
|
88
85
|
relativePathBetween,
|
|
89
|
-
replaceTsWithNgInErrors,
|
|
90
|
-
retagAllTsFiles,
|
|
91
86
|
signalMetadataTransform,
|
|
92
87
|
toUnredirectedSourceFile,
|
|
93
88
|
tryParseInitializerApi,
|
|
94
89
|
untagAllTsFiles
|
|
95
|
-
} from "./chunk-
|
|
90
|
+
} from "./chunk-3CWKYDQ7.js";
|
|
96
91
|
import {
|
|
97
92
|
LogicalFileSystem,
|
|
98
|
-
absoluteFrom,
|
|
99
93
|
absoluteFromSourceFile,
|
|
100
|
-
createFileSystemTsReadDirectoryFn,
|
|
101
94
|
dirname,
|
|
102
95
|
getFileSystem,
|
|
103
96
|
join,
|
|
104
97
|
resolve
|
|
105
98
|
} from "./chunk-GWZQLAGK.js";
|
|
106
99
|
|
|
107
|
-
// packages/compiler-cli/src/transformers/api.js
|
|
108
|
-
var DEFAULT_ERROR_CODE = 100;
|
|
109
|
-
var UNKNOWN_ERROR_CODE = 500;
|
|
110
|
-
var SOURCE = "angular";
|
|
111
|
-
function isTsDiagnostic(diagnostic) {
|
|
112
|
-
return diagnostic != null && diagnostic.source !== "angular";
|
|
113
|
-
}
|
|
114
|
-
var EmitFlags;
|
|
115
|
-
(function(EmitFlags2) {
|
|
116
|
-
EmitFlags2[EmitFlags2["DTS"] = 1] = "DTS";
|
|
117
|
-
EmitFlags2[EmitFlags2["JS"] = 2] = "JS";
|
|
118
|
-
EmitFlags2[EmitFlags2["Metadata"] = 4] = "Metadata";
|
|
119
|
-
EmitFlags2[EmitFlags2["I18nBundle"] = 8] = "I18nBundle";
|
|
120
|
-
EmitFlags2[EmitFlags2["Codegen"] = 16] = "Codegen";
|
|
121
|
-
EmitFlags2[EmitFlags2["Default"] = 19] = "Default";
|
|
122
|
-
EmitFlags2[EmitFlags2["All"] = 31] = "All";
|
|
123
|
-
})(EmitFlags || (EmitFlags = {}));
|
|
124
|
-
|
|
125
|
-
// packages/compiler-cli/src/transformers/compiler_host.js
|
|
126
|
-
import ts from "typescript";
|
|
127
|
-
var wrapHostForTest = null;
|
|
128
|
-
function createCompilerHost({ options, tsHost = ts.createCompilerHost(options, true) }) {
|
|
129
|
-
if (wrapHostForTest !== null) {
|
|
130
|
-
tsHost = wrapHostForTest(tsHost);
|
|
131
|
-
}
|
|
132
|
-
return tsHost;
|
|
133
|
-
}
|
|
134
|
-
|
|
135
100
|
// packages/compiler-cli/src/ngtsc/docs/src/entities.js
|
|
136
101
|
var EntryType;
|
|
137
102
|
(function(EntryType2) {
|
|
@@ -180,62 +145,44 @@ function isDocEntryWithSourceInfo(entry) {
|
|
|
180
145
|
}
|
|
181
146
|
|
|
182
147
|
// packages/compiler-cli/src/ngtsc/docs/src/extractor.js
|
|
183
|
-
import
|
|
148
|
+
import ts13 from "typescript";
|
|
184
149
|
|
|
185
150
|
// packages/compiler-cli/src/ngtsc/docs/src/class_extractor.js
|
|
186
151
|
import ts6 from "typescript";
|
|
187
152
|
|
|
188
|
-
// packages/compiler-cli/src/ngtsc/docs/src/filters.js
|
|
189
|
-
function isAngularPrivateName(name) {
|
|
190
|
-
const firstChar = name[0] ?? "";
|
|
191
|
-
return firstChar === "\u0275" || firstChar === "_";
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
// packages/compiler-cli/src/ngtsc/docs/src/function_extractor.js
|
|
195
|
-
import ts4 from "typescript";
|
|
196
|
-
|
|
197
|
-
// packages/compiler-cli/src/ngtsc/docs/src/generics_extractor.js
|
|
198
|
-
function extractGenerics(declaration) {
|
|
199
|
-
return declaration.typeParameters?.map((typeParam) => ({
|
|
200
|
-
name: typeParam.name.getText(),
|
|
201
|
-
constraint: typeParam.constraint?.getText(),
|
|
202
|
-
default: typeParam.default?.getText()
|
|
203
|
-
})) ?? [];
|
|
204
|
-
}
|
|
205
|
-
|
|
206
153
|
// packages/compiler-cli/src/ngtsc/docs/src/jsdoc_extractor.js
|
|
207
|
-
import
|
|
154
|
+
import ts from "typescript";
|
|
208
155
|
var decoratorExpression = /@(?=(Injectable|Component|Directive|Pipe|NgModule|Input|Output|HostBinding|HostListener|Inject|Optional|Self|Host|SkipSelf|ViewChild|ViewChildren|ContentChild|ContentChildren))/g;
|
|
209
156
|
function extractJsDocTags(node) {
|
|
210
157
|
const escapedNode = getEscapedNode(node);
|
|
211
|
-
return
|
|
158
|
+
return ts.getJSDocTags(escapedNode).map((t) => {
|
|
212
159
|
return {
|
|
213
160
|
name: t.tagName.getText(),
|
|
214
|
-
comment: unescapeAngularDecorators(
|
|
161
|
+
comment: unescapeAngularDecorators(ts.getTextOfJSDocComment(t.comment) ?? "")
|
|
215
162
|
};
|
|
216
163
|
});
|
|
217
164
|
}
|
|
218
165
|
function extractJsDocDescription(node) {
|
|
219
166
|
const escapedNode = getEscapedNode(node);
|
|
220
|
-
const commentOrTag =
|
|
221
|
-
return
|
|
167
|
+
const commentOrTag = ts.getJSDocCommentsAndTags(escapedNode).find((d) => {
|
|
168
|
+
return ts.isJSDoc(d) || ts.isJSDocParameterTag(d);
|
|
222
169
|
});
|
|
223
170
|
const comment = commentOrTag?.comment ?? "";
|
|
224
|
-
const description = typeof comment === "string" ? comment :
|
|
171
|
+
const description = typeof comment === "string" ? comment : ts.getTextOfJSDocComment(comment) ?? "";
|
|
225
172
|
return unescapeAngularDecorators(description);
|
|
226
173
|
}
|
|
227
174
|
function extractRawJsDoc(node) {
|
|
228
|
-
const comment =
|
|
175
|
+
const comment = ts.getJSDocCommentsAndTags(node).find(ts.isJSDoc)?.getFullText() ?? "";
|
|
229
176
|
return unescapeAngularDecorators(comment);
|
|
230
177
|
}
|
|
231
178
|
function getEscapedNode(node) {
|
|
232
|
-
if (
|
|
179
|
+
if (ts.isParameter(node)) {
|
|
233
180
|
return node;
|
|
234
181
|
}
|
|
235
182
|
const rawComment = extractRawJsDoc(node);
|
|
236
183
|
const escaped = escapeAngularDecorators(rawComment);
|
|
237
|
-
const file =
|
|
238
|
-
return file.statements.find((s) =>
|
|
184
|
+
const file = ts.createSourceFile("x.ts", `${escaped}class X {}`, ts.ScriptTarget.ES2020, true);
|
|
185
|
+
return file.statements.find((s) => ts.isClassDeclaration(s));
|
|
239
186
|
}
|
|
240
187
|
function escapeAngularDecorators(comment) {
|
|
241
188
|
return comment.replace(decoratorExpression, "_NG_AT_");
|
|
@@ -244,10 +191,31 @@ function unescapeAngularDecorators(comment) {
|
|
|
244
191
|
return comment.replace(/_NG_AT_/g, "@");
|
|
245
192
|
}
|
|
246
193
|
|
|
247
|
-
// packages/compiler-cli/src/ngtsc/docs/src/
|
|
194
|
+
// packages/compiler-cli/src/ngtsc/docs/src/properties_extractor.js
|
|
195
|
+
import ts5 from "typescript";
|
|
196
|
+
|
|
197
|
+
// packages/compiler-cli/src/ngtsc/docs/src/filters.js
|
|
198
|
+
function isAngularPrivateName(name) {
|
|
199
|
+
const firstChar = name[0] ?? "";
|
|
200
|
+
return firstChar === "\u0275" || firstChar === "_";
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
// packages/compiler-cli/src/ngtsc/docs/src/function_extractor.js
|
|
248
204
|
import ts3 from "typescript";
|
|
205
|
+
|
|
206
|
+
// packages/compiler-cli/src/ngtsc/docs/src/generics_extractor.js
|
|
207
|
+
function extractGenerics(declaration) {
|
|
208
|
+
return declaration.typeParameters?.map((typeParam) => ({
|
|
209
|
+
name: typeParam.name.getText(),
|
|
210
|
+
constraint: typeParam.constraint?.getText(),
|
|
211
|
+
default: typeParam.default?.getText()
|
|
212
|
+
})) ?? [];
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
// packages/compiler-cli/src/ngtsc/docs/src/type_extractor.js
|
|
216
|
+
import ts2 from "typescript";
|
|
249
217
|
function extractResolvedTypeString(node, checker) {
|
|
250
|
-
return checker.typeToString(checker.getTypeAtLocation(node), void 0,
|
|
218
|
+
return checker.typeToString(checker.getTypeAtLocation(node), void 0, ts2.TypeFormatFlags.NoTruncation);
|
|
251
219
|
}
|
|
252
220
|
|
|
253
221
|
// packages/compiler-cli/src/ngtsc/docs/src/function_extractor.js
|
|
@@ -265,7 +233,7 @@ var FunctionExtractor = class {
|
|
|
265
233
|
const returnType = signature ? extractReturnType(signature, this.typeChecker) : "unknown";
|
|
266
234
|
const implementation = findImplementationOfFunction(this.exportDeclaration, this.typeChecker) ?? this.exportDeclaration;
|
|
267
235
|
const type = this.typeChecker.getTypeAtLocation(this.exportDeclaration);
|
|
268
|
-
const overloads =
|
|
236
|
+
const overloads = ts3.isConstructorDeclaration(this.exportDeclaration) ? constructorOverloads(this.exportDeclaration, this.typeChecker) : extractCallSignatures(this.name, this.typeChecker, type);
|
|
269
237
|
const jsdocsTags = extractJsDocTags(implementation);
|
|
270
238
|
const description = extractJsDocDescription(implementation);
|
|
271
239
|
return {
|
|
@@ -273,7 +241,7 @@ var FunctionExtractor = class {
|
|
|
273
241
|
signatures: overloads,
|
|
274
242
|
implementation: {
|
|
275
243
|
params: extractAllParams(implementation.parameters, this.typeChecker),
|
|
276
|
-
isNewType:
|
|
244
|
+
isNewType: ts3.isConstructSignatureDeclaration(implementation),
|
|
277
245
|
returnType,
|
|
278
246
|
returnDescription: jsdocsTags.find((tag) => tag.name === "returns")?.comment,
|
|
279
247
|
generics: extractGenerics(implementation),
|
|
@@ -293,7 +261,7 @@ var FunctionExtractor = class {
|
|
|
293
261
|
function constructorOverloads(constructorDeclaration, typeChecker) {
|
|
294
262
|
const classDeclaration = constructorDeclaration.parent;
|
|
295
263
|
const constructorNode = classDeclaration.members.filter((member) => {
|
|
296
|
-
return
|
|
264
|
+
return ts3.isConstructorDeclaration(member) && !member.body;
|
|
297
265
|
});
|
|
298
266
|
return constructorNode.map((n) => {
|
|
299
267
|
return {
|
|
@@ -322,7 +290,7 @@ function filterSignatureDeclarations(signatures) {
|
|
|
322
290
|
const result = [];
|
|
323
291
|
for (const signature of signatures) {
|
|
324
292
|
const decl = signature.getDeclaration();
|
|
325
|
-
if (
|
|
293
|
+
if (ts3.isFunctionDeclaration(decl) || ts3.isCallSignatureDeclaration(decl) || ts3.isMethodDeclaration(decl) || ts3.isConstructSignatureDeclaration(decl)) {
|
|
326
294
|
result.push({ signature, decl });
|
|
327
295
|
}
|
|
328
296
|
}
|
|
@@ -342,14 +310,14 @@ function extractCallSignatures(name, typeChecker, type) {
|
|
|
342
310
|
}));
|
|
343
311
|
}
|
|
344
312
|
function extractReturnType(signature, typeChecker) {
|
|
345
|
-
if (signature?.declaration?.type &&
|
|
313
|
+
if (signature?.declaration?.type && ts3.isTypePredicateNode(signature.declaration.type)) {
|
|
346
314
|
return signature.declaration.type.getText();
|
|
347
315
|
}
|
|
348
316
|
return typeChecker.typeToString(
|
|
349
317
|
typeChecker.getReturnTypeOfSignature(signature),
|
|
350
318
|
void 0,
|
|
351
319
|
// This ensures that e.g. `T | undefined` is not reduced to `T`.
|
|
352
|
-
|
|
320
|
+
ts3.TypeFormatFlags.NoTypeReduction | ts3.TypeFormatFlags.NoTruncation
|
|
353
321
|
);
|
|
354
322
|
}
|
|
355
323
|
function findImplementationOfFunction(node, typeChecker) {
|
|
@@ -357,18 +325,18 @@ function findImplementationOfFunction(node, typeChecker) {
|
|
|
357
325
|
return node;
|
|
358
326
|
}
|
|
359
327
|
const symbol = typeChecker.getSymbolAtLocation(node.name);
|
|
360
|
-
const implementation = symbol?.declarations?.find((s) =>
|
|
328
|
+
const implementation = symbol?.declarations?.find((s) => ts3.isFunctionDeclaration(s) && s.body !== void 0);
|
|
361
329
|
return implementation;
|
|
362
330
|
}
|
|
363
331
|
|
|
364
332
|
// packages/compiler-cli/src/ngtsc/docs/src/internal.js
|
|
365
|
-
import
|
|
333
|
+
import ts4 from "typescript";
|
|
366
334
|
function isInternal(member) {
|
|
367
335
|
return extractJsDocTags(member).some((tag) => tag.name === "internal") || hasLeadingInternalComment(member);
|
|
368
336
|
}
|
|
369
337
|
function hasLeadingInternalComment(member) {
|
|
370
338
|
const memberText = member.getSourceFile().text;
|
|
371
|
-
return
|
|
339
|
+
return ts4.reduceEachLeadingCommentRange(
|
|
372
340
|
memberText,
|
|
373
341
|
member.getFullStart(),
|
|
374
342
|
(pos, end, kind, hasTrailingNewLine, containsInternal) => {
|
|
@@ -381,8 +349,8 @@ function hasLeadingInternalComment(member) {
|
|
|
381
349
|
) ?? false;
|
|
382
350
|
}
|
|
383
351
|
|
|
384
|
-
// packages/compiler-cli/src/ngtsc/docs/src/
|
|
385
|
-
var
|
|
352
|
+
// packages/compiler-cli/src/ngtsc/docs/src/properties_extractor.js
|
|
353
|
+
var PropertiesExtractor = class {
|
|
386
354
|
declaration;
|
|
387
355
|
typeChecker;
|
|
388
356
|
constructor(declaration, typeChecker) {
|
|
@@ -392,16 +360,8 @@ var ClassExtractor = class {
|
|
|
392
360
|
/** Extract docs info specific to classes. */
|
|
393
361
|
extract() {
|
|
394
362
|
return {
|
|
395
|
-
name: this.declaration.name.text,
|
|
396
|
-
isAbstract: this.isAbstract(),
|
|
397
|
-
entryType: ts6.isInterfaceDeclaration(this.declaration) ? EntryType.Interface : EntryType.UndecoratedClass,
|
|
398
363
|
members: this.extractSignatures().concat(this.extractAllClassMembers()),
|
|
399
|
-
generics: extractGenerics(this.declaration)
|
|
400
|
-
description: extractJsDocDescription(this.declaration),
|
|
401
|
-
jsdocTags: extractJsDocTags(this.declaration),
|
|
402
|
-
rawComment: extractRawJsDoc(this.declaration),
|
|
403
|
-
extends: this.extractInheritance(this.declaration),
|
|
404
|
-
implements: this.extractInterfaceConformance(this.declaration)
|
|
364
|
+
generics: extractGenerics(this.declaration)
|
|
405
365
|
};
|
|
406
366
|
}
|
|
407
367
|
/** Extracts doc info for a class's members. */
|
|
@@ -423,9 +383,9 @@ var ClassExtractor = class {
|
|
|
423
383
|
return this.extractMethod(memberDeclaration);
|
|
424
384
|
} else if (this.isProperty(memberDeclaration) && !this.hasPrivateComputedProperty(memberDeclaration)) {
|
|
425
385
|
return this.extractClassProperty(memberDeclaration);
|
|
426
|
-
} else if (
|
|
386
|
+
} else if (ts5.isAccessor(memberDeclaration)) {
|
|
427
387
|
return this.extractGetterSetter(memberDeclaration);
|
|
428
|
-
} else if (
|
|
388
|
+
} else if (ts5.isConstructorDeclaration(memberDeclaration) && memberDeclaration.parameters.length > 0) {
|
|
429
389
|
return this.extractConstructor(memberDeclaration);
|
|
430
390
|
}
|
|
431
391
|
return void 0;
|
|
@@ -445,7 +405,7 @@ var ClassExtractor = class {
|
|
|
445
405
|
}
|
|
446
406
|
/** Extracts docs for a signature element (usually inside an interface). */
|
|
447
407
|
extractSignature(signature) {
|
|
448
|
-
const functionExtractor = new FunctionExtractor(
|
|
408
|
+
const functionExtractor = new FunctionExtractor(ts5.isConstructSignatureDeclaration(signature) ? "new" : "", signature, this.typeChecker);
|
|
449
409
|
return {
|
|
450
410
|
...functionExtractor.extract(),
|
|
451
411
|
memberType: MemberType.Method,
|
|
@@ -467,7 +427,7 @@ var ClassExtractor = class {
|
|
|
467
427
|
extractGetterSetter(accessor) {
|
|
468
428
|
return {
|
|
469
429
|
...this.extractClassProperty(accessor),
|
|
470
|
-
memberType:
|
|
430
|
+
memberType: ts5.isGetAccessor(accessor) ? MemberType.Getter : MemberType.Setter
|
|
471
431
|
};
|
|
472
432
|
}
|
|
473
433
|
extractConstructor(constructorDeclaration) {
|
|
@@ -478,23 +438,8 @@ var ClassExtractor = class {
|
|
|
478
438
|
memberTags: this.getMemberTags(constructorDeclaration)
|
|
479
439
|
};
|
|
480
440
|
}
|
|
481
|
-
extractInheritance(declaration) {
|
|
482
|
-
if (!declaration.heritageClauses) {
|
|
483
|
-
return void 0;
|
|
484
|
-
}
|
|
485
|
-
for (const clause of declaration.heritageClauses) {
|
|
486
|
-
if (clause.token === ts6.SyntaxKind.ExtendsKeyword) {
|
|
487
|
-
const types = clause.types;
|
|
488
|
-
if (types.length > 0) {
|
|
489
|
-
const baseClass = types[0];
|
|
490
|
-
return baseClass.getText();
|
|
491
|
-
}
|
|
492
|
-
}
|
|
493
|
-
}
|
|
494
|
-
return void 0;
|
|
495
|
-
}
|
|
496
441
|
extractInterfaceConformance(declaration) {
|
|
497
|
-
const implementClause = declaration.heritageClauses?.find((clause) => clause.token ===
|
|
442
|
+
const implementClause = declaration.heritageClauses?.find((clause) => clause.token === ts5.SyntaxKind.ImplementsKeyword);
|
|
498
443
|
return implementClause?.types.map((m) => m.getText()) ?? [];
|
|
499
444
|
}
|
|
500
445
|
/** Gets the tags for a member (protected, readonly, static, etc.) */
|
|
@@ -525,7 +470,7 @@ var ClassExtractor = class {
|
|
|
525
470
|
getMemberDeclarations() {
|
|
526
471
|
const type = this.typeChecker.getTypeAtLocation(this.declaration);
|
|
527
472
|
const members = type.getProperties();
|
|
528
|
-
const constructor = type.getSymbol()?.members?.get(
|
|
473
|
+
const constructor = type.getSymbol()?.members?.get(ts5.InternalSymbolName.Constructor);
|
|
529
474
|
const typeOfConstructor = this.typeChecker.getTypeOfSymbol(type.symbol);
|
|
530
475
|
const staticMembers = typeOfConstructor.getProperties();
|
|
531
476
|
const result = [];
|
|
@@ -542,9 +487,9 @@ var ClassExtractor = class {
|
|
|
542
487
|
/** The result only contains properties, method implementations and abstracts */
|
|
543
488
|
filterMethodOverloads(declarations) {
|
|
544
489
|
return declarations.filter((declaration, index) => {
|
|
545
|
-
if (
|
|
490
|
+
if (ts5.isFunctionDeclaration(declaration) || ts5.isMethodDeclaration(declaration) || ts5.isConstructorDeclaration(declaration)) {
|
|
546
491
|
const nextDeclaration = declarations[index + 1];
|
|
547
|
-
const isNextMethodWithSameName = nextDeclaration && (
|
|
492
|
+
const isNextMethodWithSameName = nextDeclaration && (ts5.isMethodDeclaration(nextDeclaration) && nextDeclaration.name.getText() === declaration.name?.getText() || ts5.isConstructorDeclaration(nextDeclaration) && ts5.isConstructorDeclaration(declaration));
|
|
548
493
|
return !isNextMethodWithSameName;
|
|
549
494
|
}
|
|
550
495
|
return true;
|
|
@@ -563,13 +508,13 @@ var ClassExtractor = class {
|
|
|
563
508
|
/** Gets the doc tag corresponding to a class member modifier (readonly, protected, etc.). */
|
|
564
509
|
getTagForMemberModifier(mod) {
|
|
565
510
|
switch (mod.kind) {
|
|
566
|
-
case
|
|
511
|
+
case ts5.SyntaxKind.StaticKeyword:
|
|
567
512
|
return MemberTags.Static;
|
|
568
|
-
case
|
|
513
|
+
case ts5.SyntaxKind.ReadonlyKeyword:
|
|
569
514
|
return MemberTags.Readonly;
|
|
570
|
-
case
|
|
515
|
+
case ts5.SyntaxKind.ProtectedKeyword:
|
|
571
516
|
return MemberTags.Protected;
|
|
572
|
-
case
|
|
517
|
+
case ts5.SyntaxKind.AbstractKeyword:
|
|
573
518
|
return MemberTags.Abstract;
|
|
574
519
|
default:
|
|
575
520
|
return void 0;
|
|
@@ -585,39 +530,34 @@ var ClassExtractor = class {
|
|
|
585
530
|
* - The member is marked as internal via JSDoc.
|
|
586
531
|
*/
|
|
587
532
|
isMemberExcluded(member) {
|
|
588
|
-
if (
|
|
533
|
+
if (ts5.isConstructorDeclaration(member)) {
|
|
589
534
|
return false;
|
|
590
535
|
}
|
|
591
|
-
return !member.name || !this.isDocumentableMember(member) || !
|
|
536
|
+
return !member.name || !this.isDocumentableMember(member) || !ts5.isCallSignatureDeclaration(member) && member.modifiers?.some((mod) => mod.kind === ts5.SyntaxKind.PrivateKeyword) || member.name.getText() === "prototype" || isAngularPrivateName(member.name.getText()) || isInternal(member);
|
|
592
537
|
}
|
|
593
538
|
/** Gets whether a class member is a method, property, or accessor. */
|
|
594
539
|
isDocumentableMember(member) {
|
|
595
|
-
return this.isMethod(member) || this.isProperty(member) ||
|
|
596
|
-
|
|
540
|
+
return this.isMethod(member) || this.isProperty(member) || ts5.isAccessor(member) || ts5.isConstructorDeclaration(member) || // Signatures are documentable if they are part of an interface.
|
|
541
|
+
ts5.isCallSignatureDeclaration(member);
|
|
597
542
|
}
|
|
598
543
|
/** Check if the parameter is a constructor parameter with a public modifier */
|
|
599
544
|
isPublicConstructorParameterProperty(node) {
|
|
600
|
-
if (
|
|
601
|
-
return node.modifiers.some((modifier) => modifier.kind ===
|
|
545
|
+
if (ts5.isParameterPropertyDeclaration(node, node.parent) && node.modifiers) {
|
|
546
|
+
return node.modifiers.some((modifier) => modifier.kind === ts5.SyntaxKind.PublicKeyword);
|
|
602
547
|
}
|
|
603
548
|
return false;
|
|
604
549
|
}
|
|
605
550
|
/** Gets whether a member is a property. */
|
|
606
551
|
isProperty(member) {
|
|
607
|
-
return
|
|
552
|
+
return ts5.isPropertyDeclaration(member) || ts5.isPropertySignature(member) || this.isPublicConstructorParameterProperty(member);
|
|
608
553
|
}
|
|
609
554
|
/** Gets whether a member is a method. */
|
|
610
555
|
isMethod(member) {
|
|
611
|
-
return
|
|
556
|
+
return ts5.isMethodDeclaration(member) || ts5.isMethodSignature(member);
|
|
612
557
|
}
|
|
613
558
|
/** Gets whether the given signature declaration is documentable. */
|
|
614
559
|
isDocumentableSignature(signature) {
|
|
615
|
-
return
|
|
616
|
-
}
|
|
617
|
-
/** Gets whether the declaration for this extractor is abstract. */
|
|
618
|
-
isAbstract() {
|
|
619
|
-
const modifiers = this.declaration.modifiers ?? [];
|
|
620
|
-
return modifiers.some((mod) => mod.kind === ts6.SyntaxKind.AbstractKeyword);
|
|
560
|
+
return ts5.isConstructSignatureDeclaration(signature) || ts5.isCallSignatureDeclaration(signature);
|
|
621
561
|
}
|
|
622
562
|
/**
|
|
623
563
|
* Check wether a member has a private computed property name like [ɵWRITABLE_SIGNAL]
|
|
@@ -625,7 +565,48 @@ var ClassExtractor = class {
|
|
|
625
565
|
* This will prevent exposing private computed properties in the docs.
|
|
626
566
|
*/
|
|
627
567
|
hasPrivateComputedProperty(property) {
|
|
628
|
-
return
|
|
568
|
+
return ts5.isComputedPropertyName(property.name) && property.name.expression.getText().startsWith("\u0275");
|
|
569
|
+
}
|
|
570
|
+
};
|
|
571
|
+
|
|
572
|
+
// packages/compiler-cli/src/ngtsc/docs/src/class_extractor.js
|
|
573
|
+
var ClassExtractor = class extends PropertiesExtractor {
|
|
574
|
+
constructor(declaration, typeChecker) {
|
|
575
|
+
super(declaration, typeChecker);
|
|
576
|
+
}
|
|
577
|
+
/** Extract docs info specific to classes. */
|
|
578
|
+
extract() {
|
|
579
|
+
return {
|
|
580
|
+
name: this.declaration.name.text,
|
|
581
|
+
isAbstract: this.isAbstract(),
|
|
582
|
+
entryType: EntryType.UndecoratedClass,
|
|
583
|
+
...super.extract(),
|
|
584
|
+
description: extractJsDocDescription(this.declaration),
|
|
585
|
+
jsdocTags: extractJsDocTags(this.declaration),
|
|
586
|
+
rawComment: extractRawJsDoc(this.declaration),
|
|
587
|
+
extends: this.extractInheritance(this.declaration),
|
|
588
|
+
implements: this.extractInterfaceConformance(this.declaration)
|
|
589
|
+
};
|
|
590
|
+
}
|
|
591
|
+
/** Gets whether the declaration for this extractor is abstract. */
|
|
592
|
+
isAbstract() {
|
|
593
|
+
const modifiers = this.declaration.modifiers ?? [];
|
|
594
|
+
return modifiers.some((mod) => mod.kind === ts6.SyntaxKind.AbstractKeyword);
|
|
595
|
+
}
|
|
596
|
+
extractInheritance(declaration) {
|
|
597
|
+
if (!declaration.heritageClauses) {
|
|
598
|
+
return void 0;
|
|
599
|
+
}
|
|
600
|
+
for (const clause of declaration.heritageClauses) {
|
|
601
|
+
if (clause.token === ts6.SyntaxKind.ExtendsKeyword) {
|
|
602
|
+
const types = clause.types;
|
|
603
|
+
if (types.length > 0) {
|
|
604
|
+
const baseClass = types[0];
|
|
605
|
+
return baseClass.getText();
|
|
606
|
+
}
|
|
607
|
+
}
|
|
608
|
+
}
|
|
609
|
+
return void 0;
|
|
629
610
|
}
|
|
630
611
|
};
|
|
631
612
|
var DirectiveExtractor = class extends ClassExtractor {
|
|
@@ -724,10 +705,6 @@ function extractClass(classDeclaration, metadataReader, typeChecker) {
|
|
|
724
705
|
}
|
|
725
706
|
return extractor.extract();
|
|
726
707
|
}
|
|
727
|
-
function extractInterface(declaration, typeChecker) {
|
|
728
|
-
const extractor = new ClassExtractor(declaration, typeChecker);
|
|
729
|
-
return extractor.extract();
|
|
730
|
-
}
|
|
731
708
|
function extractPipeSyntax(metadata, classDeclaration) {
|
|
732
709
|
const transformParams = classDeclaration.members.find((member) => {
|
|
733
710
|
return ts6.isMethodDeclaration(member) && member.name && ts6.isIdentifier(member.name) && member.name.getText() === "transform";
|
|
@@ -797,7 +774,48 @@ function extractLiteralPropertiesAsEnumMembers(declaration) {
|
|
|
797
774
|
}
|
|
798
775
|
|
|
799
776
|
// packages/compiler-cli/src/ngtsc/docs/src/decorator_extractor.js
|
|
777
|
+
import ts9 from "typescript";
|
|
778
|
+
|
|
779
|
+
// packages/compiler-cli/src/ngtsc/docs/src/interface_extractor.js
|
|
800
780
|
import ts8 from "typescript";
|
|
781
|
+
var InterfaceExtractor = class extends PropertiesExtractor {
|
|
782
|
+
constructor(declaration, typeChecker) {
|
|
783
|
+
super(declaration, typeChecker);
|
|
784
|
+
}
|
|
785
|
+
/** Extract docs info specific to classes. */
|
|
786
|
+
extract() {
|
|
787
|
+
return {
|
|
788
|
+
name: this.declaration.name.text,
|
|
789
|
+
entryType: EntryType.Interface,
|
|
790
|
+
...super.extract(),
|
|
791
|
+
description: extractJsDocDescription(this.declaration),
|
|
792
|
+
jsdocTags: extractJsDocTags(this.declaration),
|
|
793
|
+
rawComment: extractRawJsDoc(this.declaration),
|
|
794
|
+
extends: this.extractInheritance(this.declaration),
|
|
795
|
+
implements: this.extractInterfaceConformance(this.declaration)
|
|
796
|
+
};
|
|
797
|
+
}
|
|
798
|
+
extractInheritance(declaration) {
|
|
799
|
+
if (!declaration.heritageClauses) {
|
|
800
|
+
return [];
|
|
801
|
+
}
|
|
802
|
+
for (const clause of declaration.heritageClauses) {
|
|
803
|
+
if (clause.token === ts8.SyntaxKind.ExtendsKeyword) {
|
|
804
|
+
const types = clause.types;
|
|
805
|
+
if (types.length > 0) {
|
|
806
|
+
return types.map((t) => t.getText());
|
|
807
|
+
}
|
|
808
|
+
}
|
|
809
|
+
}
|
|
810
|
+
return [];
|
|
811
|
+
}
|
|
812
|
+
};
|
|
813
|
+
function extractInterface(declaration, typeChecker) {
|
|
814
|
+
const extractor = new InterfaceExtractor(declaration, typeChecker);
|
|
815
|
+
return extractor.extract();
|
|
816
|
+
}
|
|
817
|
+
|
|
818
|
+
// packages/compiler-cli/src/ngtsc/docs/src/decorator_extractor.js
|
|
801
819
|
function extractorDecorator(declaration, typeChecker) {
|
|
802
820
|
const documentedNode = getDecoratorJsDocNode(declaration, typeChecker);
|
|
803
821
|
const decoratorType = getDecoratorType(declaration);
|
|
@@ -808,7 +826,7 @@ function extractorDecorator(declaration, typeChecker) {
|
|
|
808
826
|
let signatures = [];
|
|
809
827
|
if (!members) {
|
|
810
828
|
const decoratorInterface = getDecoratorDeclaration(declaration, typeChecker);
|
|
811
|
-
const callSignatures = decoratorInterface.members.filter(
|
|
829
|
+
const callSignatures = decoratorInterface.members.filter(ts9.isCallSignatureDeclaration);
|
|
812
830
|
signatures = getDecoratorSignatures(callSignatures, typeChecker);
|
|
813
831
|
}
|
|
814
832
|
return {
|
|
@@ -826,7 +844,7 @@ function isDecoratorDeclaration(declaration) {
|
|
|
826
844
|
return !!getDecoratorType(declaration);
|
|
827
845
|
}
|
|
828
846
|
function isDecoratorOptionsInterface(declaration) {
|
|
829
|
-
return declaration.getSourceFile().statements.some((s) =>
|
|
847
|
+
return declaration.getSourceFile().statements.some((s) => ts9.isVariableStatement(s) && s.declarationList.declarations.some((d) => isDecoratorDeclaration(d) && d.name.getText() === declaration.name.getText()));
|
|
830
848
|
}
|
|
831
849
|
function getDecoratorType(declaration) {
|
|
832
850
|
const initializer = declaration.initializer?.getFullText() ?? "";
|
|
@@ -844,7 +862,7 @@ function getDecoratorDeclaration(declaration, typeChecker) {
|
|
|
844
862
|
const decoratorType = typeChecker.getTypeAtLocation(decoratorDeclaration);
|
|
845
863
|
const aliasDeclaration = decoratorType.getSymbol().getDeclarations()[0];
|
|
846
864
|
const decoratorInterface = aliasDeclaration;
|
|
847
|
-
if (!decoratorInterface || !
|
|
865
|
+
if (!decoratorInterface || !ts9.isInterfaceDeclaration(decoratorInterface)) {
|
|
848
866
|
throw new Error(`No decorator interface found for "${decoratorName}".`);
|
|
849
867
|
}
|
|
850
868
|
return decoratorInterface;
|
|
@@ -855,12 +873,12 @@ function getDecoratorProperties(declaration, typeChecker) {
|
|
|
855
873
|
const firstParamType = typeChecker.getTypeAtLocation(decoratorFirstParam);
|
|
856
874
|
let firstParamTypeDecl;
|
|
857
875
|
if (firstParamType.isUnion()) {
|
|
858
|
-
const firstParamTypeUnion = firstParamType.types.find((t) => (t.flags &
|
|
876
|
+
const firstParamTypeUnion = firstParamType.types.find((t) => (t.flags & ts9.TypeFlags.Undefined) === 0);
|
|
859
877
|
firstParamTypeDecl = firstParamTypeUnion?.getSymbol()?.getDeclarations()[0];
|
|
860
878
|
} else {
|
|
861
879
|
firstParamTypeDecl = firstParamType.getSymbol()?.getDeclarations()[0];
|
|
862
880
|
}
|
|
863
|
-
if (!firstParamTypeDecl || !
|
|
881
|
+
if (!firstParamTypeDecl || !ts9.isInterfaceDeclaration(firstParamTypeDecl)) {
|
|
864
882
|
return null;
|
|
865
883
|
}
|
|
866
884
|
const interfaceDeclaration = firstParamTypeDecl;
|
|
@@ -888,7 +906,7 @@ function getDecoratorInterface(declaration, typeChecker) {
|
|
|
888
906
|
const symbol = typeChecker.getSymbolAtLocation(declaration.name);
|
|
889
907
|
const decoratorType = typeChecker.getTypeOfSymbolAtLocation(symbol, symbol.valueDeclaration);
|
|
890
908
|
const decoratorInterface = decoratorType.getSymbol()?.getDeclarations()[0];
|
|
891
|
-
if (!decoratorInterface || !
|
|
909
|
+
if (!decoratorInterface || !ts9.isInterfaceDeclaration(decoratorInterface)) {
|
|
892
910
|
throw new Error(`No decorator interface found for "${name}".`);
|
|
893
911
|
}
|
|
894
912
|
return decoratorInterface;
|
|
@@ -897,22 +915,22 @@ function getDecoratorJsDocNode(declaration, typeChecker) {
|
|
|
897
915
|
const name = declaration.name.getText();
|
|
898
916
|
const decoratorInterface = getDecoratorInterface(declaration, typeChecker);
|
|
899
917
|
const callSignature = decoratorInterface.members.filter((node) => {
|
|
900
|
-
return
|
|
918
|
+
return ts9.isCallSignatureDeclaration(node) && extractRawJsDoc(node);
|
|
901
919
|
}).at(-1);
|
|
902
|
-
if (!callSignature || !
|
|
920
|
+
if (!callSignature || !ts9.isCallSignatureDeclaration(callSignature)) {
|
|
903
921
|
throw new Error(`No call signature with JsDoc on "${name}Decorator"`);
|
|
904
922
|
}
|
|
905
923
|
return callSignature;
|
|
906
924
|
}
|
|
907
925
|
function getParamTypeString(paramNode, typeChecker) {
|
|
908
926
|
const type = typeChecker.getTypeAtLocation(paramNode);
|
|
909
|
-
const printer =
|
|
927
|
+
const printer = ts9.createPrinter({ removeComments: true });
|
|
910
928
|
const sourceFile = paramNode.getSourceFile();
|
|
911
929
|
const replace = [];
|
|
912
930
|
if (type.isUnion()) {
|
|
913
931
|
for (const subType of type.types) {
|
|
914
932
|
const decl = subType.getSymbol()?.getDeclarations()?.[0];
|
|
915
|
-
if (decl &&
|
|
933
|
+
if (decl && ts9.isInterfaceDeclaration(decl) && decl.name.text !== "Function") {
|
|
916
934
|
replace.push({
|
|
917
935
|
initial: subType.symbol.name,
|
|
918
936
|
replacedWith: expandType(decl, sourceFile, printer)
|
|
@@ -920,19 +938,19 @@ function getParamTypeString(paramNode, typeChecker) {
|
|
|
920
938
|
}
|
|
921
939
|
}
|
|
922
940
|
}
|
|
923
|
-
let result = printer.printNode(
|
|
941
|
+
let result = printer.printNode(ts9.EmitHint.Unspecified, paramNode, sourceFile).replace(new RegExp(`${paramNode.name.getText()}\\??: `), "").replaceAll(/\s+/g, " ");
|
|
924
942
|
for (const { initial, replacedWith } of replace) {
|
|
925
943
|
result = result.replace(initial, replacedWith);
|
|
926
944
|
}
|
|
927
945
|
return result;
|
|
928
946
|
}
|
|
929
947
|
function expandType(decl, sourceFile, printer) {
|
|
930
|
-
const props = decl.members.map((member) => printer.printNode(
|
|
948
|
+
const props = decl.members.map((member) => printer.printNode(ts9.EmitHint.Unspecified, member, sourceFile)).join(" ").replaceAll(/\s+/g, " ");
|
|
931
949
|
return `{${props}}`;
|
|
932
950
|
}
|
|
933
951
|
|
|
934
952
|
// packages/compiler-cli/src/ngtsc/docs/src/enum_extractor.js
|
|
935
|
-
import
|
|
953
|
+
import ts10 from "typescript";
|
|
936
954
|
function extractEnum(declaration, typeChecker) {
|
|
937
955
|
return {
|
|
938
956
|
name: declaration.name.getText(),
|
|
@@ -956,36 +974,36 @@ function extractEnumMembers(declaration, checker) {
|
|
|
956
974
|
}
|
|
957
975
|
function getEnumMemberValue(memberNode) {
|
|
958
976
|
const literal = memberNode.getChildren().find((n) => {
|
|
959
|
-
return
|
|
977
|
+
return ts10.isNumericLiteral(n) || ts10.isStringLiteral(n) || ts10.isPrefixUnaryExpression(n) && n.operator === ts10.SyntaxKind.MinusToken && ts10.isNumericLiteral(n.operand);
|
|
960
978
|
});
|
|
961
979
|
return literal?.getText() ?? "";
|
|
962
980
|
}
|
|
963
981
|
|
|
964
982
|
// packages/compiler-cli/src/ngtsc/docs/src/initializer_api_function_extractor.js
|
|
965
|
-
import
|
|
983
|
+
import ts11 from "typescript";
|
|
966
984
|
var initializerApiTag = "initializerApiFunction";
|
|
967
985
|
function isInitializerApiFunction(node, typeChecker) {
|
|
968
|
-
if (
|
|
986
|
+
if (ts11.isFunctionDeclaration(node) && node.name !== void 0 && node.body === void 0) {
|
|
969
987
|
const implementation = findImplementationOfFunction(node, typeChecker);
|
|
970
988
|
if (implementation !== void 0) {
|
|
971
989
|
node = implementation;
|
|
972
990
|
}
|
|
973
991
|
}
|
|
974
|
-
if (!
|
|
992
|
+
if (!ts11.isFunctionDeclaration(node) && !ts11.isVariableDeclaration(node)) {
|
|
975
993
|
return false;
|
|
976
994
|
}
|
|
977
|
-
let tagContainer =
|
|
995
|
+
let tagContainer = ts11.isFunctionDeclaration(node) ? node : getContainerVariableStatement(node);
|
|
978
996
|
if (tagContainer === null) {
|
|
979
997
|
return false;
|
|
980
998
|
}
|
|
981
|
-
const tags =
|
|
999
|
+
const tags = ts11.getJSDocTags(tagContainer);
|
|
982
1000
|
return tags.some((t) => t.tagName.text === initializerApiTag);
|
|
983
1001
|
}
|
|
984
1002
|
function extractInitializerApiFunction(node, typeChecker) {
|
|
985
|
-
if (node.name === void 0 || !
|
|
1003
|
+
if (node.name === void 0 || !ts11.isIdentifier(node.name)) {
|
|
986
1004
|
throw new Error(`Initializer API: Expected literal variable name.`);
|
|
987
1005
|
}
|
|
988
|
-
const container =
|
|
1006
|
+
const container = ts11.isFunctionDeclaration(node) ? node : getContainerVariableStatement(node);
|
|
989
1007
|
if (container === null) {
|
|
990
1008
|
throw new Error("Initializer API: Could not find container AST node of variable.");
|
|
991
1009
|
}
|
|
@@ -996,7 +1014,7 @@ function extractInitializerApiFunction(node, typeChecker) {
|
|
|
996
1014
|
for (const property of type.getProperties()) {
|
|
997
1015
|
const subName = property.getName();
|
|
998
1016
|
const subDecl = property.getDeclarations()?.[0];
|
|
999
|
-
if (subDecl === void 0 || !
|
|
1017
|
+
if (subDecl === void 0 || !ts11.isPropertySignature(subDecl)) {
|
|
1000
1018
|
throw new Error(`Initializer API: Could not resolve declaration of sub-property: ${name}.${subName}`);
|
|
1001
1019
|
}
|
|
1002
1020
|
const subType = typeChecker.getTypeAtLocation(subDecl);
|
|
@@ -1005,7 +1023,7 @@ function extractInitializerApiFunction(node, typeChecker) {
|
|
|
1005
1023
|
let jsdocTags;
|
|
1006
1024
|
let description;
|
|
1007
1025
|
let rawComment;
|
|
1008
|
-
if (
|
|
1026
|
+
if (ts11.isFunctionDeclaration(node)) {
|
|
1009
1027
|
const implementation = findImplementationOfFunction(node, typeChecker);
|
|
1010
1028
|
if (implementation === void 0) {
|
|
1011
1029
|
throw new Error(`Initializer API: Could not find implementation of function: ${name}`);
|
|
@@ -1053,10 +1071,10 @@ function extractInitializerApiFunction(node, typeChecker) {
|
|
|
1053
1071
|
};
|
|
1054
1072
|
}
|
|
1055
1073
|
function getContainerVariableStatement(node) {
|
|
1056
|
-
if (!
|
|
1074
|
+
if (!ts11.isVariableDeclarationList(node.parent)) {
|
|
1057
1075
|
return null;
|
|
1058
1076
|
}
|
|
1059
|
-
if (!
|
|
1077
|
+
if (!ts11.isVariableStatement(node.parent.parent)) {
|
|
1060
1078
|
return null;
|
|
1061
1079
|
}
|
|
1062
1080
|
return node.parent.parent;
|
|
@@ -1084,15 +1102,15 @@ function extractTypeAlias(declaration) {
|
|
|
1084
1102
|
}
|
|
1085
1103
|
|
|
1086
1104
|
// packages/compiler-cli/src/ngtsc/docs/src/import_extractor.js
|
|
1087
|
-
import
|
|
1105
|
+
import ts12 from "typescript";
|
|
1088
1106
|
function getImportedSymbols(sourceFile) {
|
|
1089
1107
|
const importSpecifiers = /* @__PURE__ */ new Map();
|
|
1090
1108
|
function visit(node) {
|
|
1091
|
-
if (
|
|
1109
|
+
if (ts12.isImportDeclaration(node)) {
|
|
1092
1110
|
let moduleSpecifier = node.moduleSpecifier.getText(sourceFile).replace(/['"]/g, "");
|
|
1093
1111
|
if (moduleSpecifier.startsWith("@angular/")) {
|
|
1094
1112
|
const namedBindings = node.importClause?.namedBindings;
|
|
1095
|
-
if (namedBindings &&
|
|
1113
|
+
if (namedBindings && ts12.isNamedImports(namedBindings)) {
|
|
1096
1114
|
namedBindings.elements.forEach((importSpecifier) => {
|
|
1097
1115
|
const importName = importSpecifier.name.text;
|
|
1098
1116
|
const importAlias = importSpecifier.propertyName ? importSpecifier.propertyName.text : void 0;
|
|
@@ -1101,7 +1119,7 @@ function getImportedSymbols(sourceFile) {
|
|
|
1101
1119
|
}
|
|
1102
1120
|
}
|
|
1103
1121
|
}
|
|
1104
|
-
|
|
1122
|
+
ts12.forEachChild(node, visit);
|
|
1105
1123
|
}
|
|
1106
1124
|
visit(sourceFile);
|
|
1107
1125
|
return importSpecifiers;
|
|
@@ -1145,8 +1163,8 @@ var DocsExtractor = class {
|
|
|
1145
1163
|
entry.source = {
|
|
1146
1164
|
filePath: getRelativeFilePath(realSourceFile, rootDir),
|
|
1147
1165
|
// Start & End are off by 1
|
|
1148
|
-
startLine:
|
|
1149
|
-
endLine:
|
|
1166
|
+
startLine: ts13.getLineAndCharacterOfPosition(realSourceFile, node.getStart()).line + 1,
|
|
1167
|
+
endLine: ts13.getLineAndCharacterOfPosition(realSourceFile, node.getEnd()).line + 1
|
|
1150
1168
|
};
|
|
1151
1169
|
entries.push({ ...entry, name: exportName });
|
|
1152
1170
|
}
|
|
@@ -1161,20 +1179,20 @@ var DocsExtractor = class {
|
|
|
1161
1179
|
if (isInitializerApiFunction(node, this.typeChecker)) {
|
|
1162
1180
|
return extractInitializerApiFunction(node, this.typeChecker);
|
|
1163
1181
|
}
|
|
1164
|
-
if (
|
|
1182
|
+
if (ts13.isInterfaceDeclaration(node) && !isIgnoredInterface(node)) {
|
|
1165
1183
|
return extractInterface(node, this.typeChecker);
|
|
1166
1184
|
}
|
|
1167
|
-
if (
|
|
1185
|
+
if (ts13.isFunctionDeclaration(node)) {
|
|
1168
1186
|
const functionExtractor = new FunctionExtractor(node.name.getText(), node, this.typeChecker);
|
|
1169
1187
|
return functionExtractor.extract();
|
|
1170
1188
|
}
|
|
1171
|
-
if (
|
|
1189
|
+
if (ts13.isVariableDeclaration(node) && !isSyntheticAngularConstant(node)) {
|
|
1172
1190
|
return isDecoratorDeclaration(node) ? extractorDecorator(node, this.typeChecker) : extractConstant(node, this.typeChecker);
|
|
1173
1191
|
}
|
|
1174
|
-
if (
|
|
1192
|
+
if (ts13.isTypeAliasDeclaration(node)) {
|
|
1175
1193
|
return extractTypeAlias(node);
|
|
1176
1194
|
}
|
|
1177
|
-
if (
|
|
1195
|
+
if (ts13.isEnumDeclaration(node)) {
|
|
1178
1196
|
return extractEnum(node, this.typeChecker);
|
|
1179
1197
|
}
|
|
1180
1198
|
return null;
|
|
@@ -1203,111 +1221,13 @@ function getRelativeFilePath(sourceFile, rootDir) {
|
|
|
1203
1221
|
return relativePath;
|
|
1204
1222
|
}
|
|
1205
1223
|
|
|
1206
|
-
// packages/compiler-cli/src/ngtsc/
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
function i18nGetExtension(formatName) {
|
|
1214
|
-
const format = formatName.toLowerCase();
|
|
1215
|
-
switch (format) {
|
|
1216
|
-
case "xmb":
|
|
1217
|
-
return "xmb";
|
|
1218
|
-
case "xlf":
|
|
1219
|
-
case "xlif":
|
|
1220
|
-
case "xliff":
|
|
1221
|
-
case "xlf2":
|
|
1222
|
-
case "xliff2":
|
|
1223
|
-
return "xlf";
|
|
1224
|
-
}
|
|
1225
|
-
throw new Error(`Unsupported format "${formatName}"`);
|
|
1226
|
-
}
|
|
1227
|
-
function i18nExtract(formatName, outFile, host, options, bundle, pathResolve = path.resolve) {
|
|
1228
|
-
formatName = formatName || "xlf";
|
|
1229
|
-
const ext = i18nGetExtension(formatName);
|
|
1230
|
-
const content = i18nSerialize(bundle, formatName, options);
|
|
1231
|
-
const dstFile = outFile || `messages.${ext}`;
|
|
1232
|
-
const dstPath = pathResolve(options.outDir || options.basePath, dstFile);
|
|
1233
|
-
host.writeFile(dstPath, content, false, void 0, []);
|
|
1234
|
-
return [dstPath];
|
|
1235
|
-
}
|
|
1236
|
-
function i18nSerialize(bundle, formatName, options) {
|
|
1237
|
-
const format = formatName.toLowerCase();
|
|
1238
|
-
let serializer;
|
|
1239
|
-
switch (format) {
|
|
1240
|
-
case "xmb":
|
|
1241
|
-
serializer = new Xmb();
|
|
1242
|
-
break;
|
|
1243
|
-
case "xliff2":
|
|
1244
|
-
case "xlf2":
|
|
1245
|
-
serializer = new Xliff2();
|
|
1246
|
-
break;
|
|
1247
|
-
case "xlf":
|
|
1248
|
-
case "xliff":
|
|
1249
|
-
default:
|
|
1250
|
-
serializer = new Xliff();
|
|
1251
|
-
}
|
|
1252
|
-
return bundle.write(serializer, getPathNormalizer(options.basePath));
|
|
1253
|
-
}
|
|
1254
|
-
function getPathNormalizer(basePath) {
|
|
1255
|
-
return (sourcePath) => {
|
|
1256
|
-
sourcePath = basePath ? path.relative(basePath, sourcePath) : sourcePath;
|
|
1257
|
-
return sourcePath.split(path.sep).join("/");
|
|
1258
|
-
};
|
|
1259
|
-
}
|
|
1260
|
-
|
|
1261
|
-
// packages/compiler-cli/src/typescript_support.js
|
|
1262
|
-
import ts13 from "typescript";
|
|
1263
|
-
|
|
1264
|
-
// packages/compiler-cli/src/version_helpers.js
|
|
1265
|
-
function toNumbers(value) {
|
|
1266
|
-
const suffixIndex = value.lastIndexOf("-");
|
|
1267
|
-
return value.slice(0, suffixIndex === -1 ? value.length : suffixIndex).split(".").map((segment) => {
|
|
1268
|
-
const parsed = parseInt(segment, 10);
|
|
1269
|
-
if (isNaN(parsed)) {
|
|
1270
|
-
throw Error(`Unable to parse version string ${value}.`);
|
|
1271
|
-
}
|
|
1272
|
-
return parsed;
|
|
1273
|
-
});
|
|
1274
|
-
}
|
|
1275
|
-
function compareNumbers(a, b) {
|
|
1276
|
-
const max = Math.max(a.length, b.length);
|
|
1277
|
-
const min = Math.min(a.length, b.length);
|
|
1278
|
-
for (let i = 0; i < min; i++) {
|
|
1279
|
-
if (a[i] > b[i])
|
|
1280
|
-
return 1;
|
|
1281
|
-
if (a[i] < b[i])
|
|
1282
|
-
return -1;
|
|
1283
|
-
}
|
|
1284
|
-
if (min !== max) {
|
|
1285
|
-
const longestArray = a.length === max ? a : b;
|
|
1286
|
-
const comparisonResult = a.length === max ? 1 : -1;
|
|
1287
|
-
for (let i = min; i < max; i++) {
|
|
1288
|
-
if (longestArray[i] > 0) {
|
|
1289
|
-
return comparisonResult;
|
|
1290
|
-
}
|
|
1291
|
-
}
|
|
1292
|
-
}
|
|
1293
|
-
return 0;
|
|
1294
|
-
}
|
|
1295
|
-
function compareVersions(v1, v2) {
|
|
1296
|
-
return compareNumbers(toNumbers(v1), toNumbers(v2));
|
|
1297
|
-
}
|
|
1298
|
-
|
|
1299
|
-
// packages/compiler-cli/src/typescript_support.js
|
|
1300
|
-
var MIN_TS_VERSION = "5.9.0";
|
|
1301
|
-
var MAX_TS_VERSION = "6.0.0";
|
|
1302
|
-
var tsVersion = ts13.version;
|
|
1303
|
-
function checkVersion(version, minVersion, maxVersion) {
|
|
1304
|
-
if (compareVersions(version, minVersion) < 0 || compareVersions(version, maxVersion) >= 0) {
|
|
1305
|
-
throw new Error(`The Angular Compiler requires TypeScript >=${minVersion} and <${maxVersion} but ${version} was found instead.`);
|
|
1306
|
-
}
|
|
1307
|
-
}
|
|
1308
|
-
function verifySupportedTypeScriptVersion() {
|
|
1309
|
-
checkVersion(tsVersion, MIN_TS_VERSION, MAX_TS_VERSION);
|
|
1310
|
-
}
|
|
1224
|
+
// packages/compiler-cli/src/ngtsc/core/api/src/public_options.js
|
|
1225
|
+
var DiagnosticCategoryLabel;
|
|
1226
|
+
(function(DiagnosticCategoryLabel2) {
|
|
1227
|
+
DiagnosticCategoryLabel2["Warning"] = "warning";
|
|
1228
|
+
DiagnosticCategoryLabel2["Error"] = "error";
|
|
1229
|
+
DiagnosticCategoryLabel2["Suppress"] = "suppress";
|
|
1230
|
+
})(DiagnosticCategoryLabel || (DiagnosticCategoryLabel = {}));
|
|
1311
1231
|
|
|
1312
1232
|
// packages/compiler-cli/src/ngtsc/core/src/compiler.js
|
|
1313
1233
|
import ts26 from "typescript";
|
|
@@ -3077,7 +2997,9 @@ var KNOWN_CONTROL_FLOW_DIRECTIVES2 = /* @__PURE__ */ new Set([
|
|
|
3077
2997
|
"ngForOf",
|
|
3078
2998
|
"ngForTrackBy",
|
|
3079
2999
|
"ngSwitchCase",
|
|
3080
|
-
"ngSwitchDefault"
|
|
3000
|
+
"ngSwitchDefault",
|
|
3001
|
+
"ngIfThen",
|
|
3002
|
+
"ngIfElse"
|
|
3081
3003
|
]);
|
|
3082
3004
|
var MissingStructuralDirectiveCheck = class extends TemplateCheckWithVisitor {
|
|
3083
3005
|
code = ErrorCode.MISSING_STRUCTURAL_DIRECTIVE;
|
|
@@ -3095,9 +3017,9 @@ var MissingStructuralDirectiveCheck = class extends TemplateCheckWithVisitor {
|
|
|
3095
3017
|
if (!customStructuralDirective)
|
|
3096
3018
|
return [];
|
|
3097
3019
|
const symbol = ctx.templateTypeChecker.getSymbolOfNode(node, component);
|
|
3098
|
-
|
|
3020
|
+
const hasStructuralDirective = symbol?.directives.some((dir) => dir.selector?.includes(`[${customStructuralDirective.name}]`));
|
|
3021
|
+
if (hasStructuralDirective)
|
|
3099
3022
|
return [];
|
|
3100
|
-
}
|
|
3101
3023
|
const sourceSpan = customStructuralDirective.keySpan || customStructuralDirective.sourceSpan;
|
|
3102
3024
|
const errorMessage = `A structural directive \`${customStructuralDirective.name}\` was used in the template without a corresponding import in the component. Make sure that the directive is included in the \`@Component.imports\` array of this component.`;
|
|
3103
3025
|
return [ctx.makeTemplateDiagnostic(sourceSpan, errorMessage)];
|
|
@@ -3544,16 +3466,6 @@ var factory16 = {
|
|
|
3544
3466
|
|
|
3545
3467
|
// packages/compiler-cli/src/ngtsc/typecheck/extended/src/extended_template_checker.js
|
|
3546
3468
|
import ts21 from "typescript";
|
|
3547
|
-
|
|
3548
|
-
// packages/compiler-cli/src/ngtsc/core/api/src/public_options.js
|
|
3549
|
-
var DiagnosticCategoryLabel;
|
|
3550
|
-
(function(DiagnosticCategoryLabel2) {
|
|
3551
|
-
DiagnosticCategoryLabel2["Warning"] = "warning";
|
|
3552
|
-
DiagnosticCategoryLabel2["Error"] = "error";
|
|
3553
|
-
DiagnosticCategoryLabel2["Suppress"] = "suppress";
|
|
3554
|
-
})(DiagnosticCategoryLabel || (DiagnosticCategoryLabel = {}));
|
|
3555
|
-
|
|
3556
|
-
// packages/compiler-cli/src/ngtsc/typecheck/extended/src/extended_template_checker.js
|
|
3557
3469
|
var ExtendedTemplateCheckerImpl = class {
|
|
3558
3470
|
partialCtx;
|
|
3559
3471
|
templateChecks;
|
|
@@ -5250,491 +5162,21 @@ var NgCompilerHost = class _NgCompilerHost extends DelegatingCompilerHost {
|
|
|
5250
5162
|
}
|
|
5251
5163
|
};
|
|
5252
5164
|
|
|
5253
|
-
// packages/compiler-cli/src/ngtsc/program.js
|
|
5254
|
-
var NgtscProgram = class {
|
|
5255
|
-
options;
|
|
5256
|
-
compiler;
|
|
5257
|
-
/**
|
|
5258
|
-
* The primary TypeScript program, which is used for analysis and emit.
|
|
5259
|
-
*/
|
|
5260
|
-
tsProgram;
|
|
5261
|
-
host;
|
|
5262
|
-
incrementalStrategy;
|
|
5263
|
-
constructor(rootNames, options, delegateHost, oldProgram) {
|
|
5264
|
-
this.options = options;
|
|
5265
|
-
const perfRecorder = ActivePerfRecorder.zeroedToNow();
|
|
5266
|
-
perfRecorder.phase(PerfPhase.Setup);
|
|
5267
|
-
if (!options.disableTypeScriptVersionCheck) {
|
|
5268
|
-
verifySupportedTypeScriptVersion();
|
|
5269
|
-
}
|
|
5270
|
-
if (options.compilationMode === "experimental-local") {
|
|
5271
|
-
options.noEmitOnError = false;
|
|
5272
|
-
}
|
|
5273
|
-
const reuseProgram = oldProgram?.compiler.getCurrentProgram();
|
|
5274
|
-
this.host = NgCompilerHost.wrap(delegateHost, rootNames, options, reuseProgram ?? null);
|
|
5275
|
-
if (reuseProgram !== void 0) {
|
|
5276
|
-
retagAllTsFiles(reuseProgram);
|
|
5277
|
-
}
|
|
5278
|
-
this.tsProgram = perfRecorder.inPhase(PerfPhase.TypeScriptProgramCreate, () => ts28.createProgram(this.host.inputFiles, options, this.host, reuseProgram));
|
|
5279
|
-
perfRecorder.phase(PerfPhase.Unaccounted);
|
|
5280
|
-
perfRecorder.memory(PerfCheckpoint.TypeScriptProgramCreate);
|
|
5281
|
-
this.host.postProgramCreationCleanup();
|
|
5282
|
-
const programDriver = new TsCreateProgramDriver(this.tsProgram, this.host, this.options, this.host.shimExtensionPrefixes);
|
|
5283
|
-
this.incrementalStrategy = oldProgram !== void 0 ? oldProgram.incrementalStrategy.toNextBuildStrategy() : new TrackedIncrementalBuildStrategy();
|
|
5284
|
-
const modifiedResourceFiles = /* @__PURE__ */ new Set();
|
|
5285
|
-
if (this.host.getModifiedResourceFiles !== void 0) {
|
|
5286
|
-
const strings = this.host.getModifiedResourceFiles();
|
|
5287
|
-
if (strings !== void 0) {
|
|
5288
|
-
for (const fileString of strings) {
|
|
5289
|
-
modifiedResourceFiles.add(absoluteFrom(fileString));
|
|
5290
|
-
}
|
|
5291
|
-
}
|
|
5292
|
-
}
|
|
5293
|
-
let ticket;
|
|
5294
|
-
if (oldProgram === void 0) {
|
|
5295
|
-
ticket = freshCompilationTicket(
|
|
5296
|
-
this.tsProgram,
|
|
5297
|
-
options,
|
|
5298
|
-
this.incrementalStrategy,
|
|
5299
|
-
programDriver,
|
|
5300
|
-
perfRecorder,
|
|
5301
|
-
/* enableTemplateTypeChecker */
|
|
5302
|
-
false,
|
|
5303
|
-
/* usePoisonedData */
|
|
5304
|
-
false
|
|
5305
|
-
);
|
|
5306
|
-
} else {
|
|
5307
|
-
ticket = incrementalFromCompilerTicket(oldProgram.compiler, this.tsProgram, this.incrementalStrategy, programDriver, modifiedResourceFiles, perfRecorder);
|
|
5308
|
-
}
|
|
5309
|
-
this.compiler = NgCompiler.fromTicket(ticket, this.host);
|
|
5310
|
-
}
|
|
5311
|
-
getTsProgram() {
|
|
5312
|
-
return this.tsProgram;
|
|
5313
|
-
}
|
|
5314
|
-
getReuseTsProgram() {
|
|
5315
|
-
return this.compiler.getCurrentProgram();
|
|
5316
|
-
}
|
|
5317
|
-
getTsOptionDiagnostics(cancellationToken) {
|
|
5318
|
-
return this.compiler.perfRecorder.inPhase(PerfPhase.TypeScriptDiagnostics, () => this.tsProgram.getOptionsDiagnostics(cancellationToken));
|
|
5319
|
-
}
|
|
5320
|
-
getTsSyntacticDiagnostics(sourceFile, cancellationToken) {
|
|
5321
|
-
return this.compiler.perfRecorder.inPhase(PerfPhase.TypeScriptDiagnostics, () => {
|
|
5322
|
-
const ignoredFiles = this.compiler.ignoreForDiagnostics;
|
|
5323
|
-
let res;
|
|
5324
|
-
if (sourceFile !== void 0) {
|
|
5325
|
-
if (ignoredFiles.has(sourceFile)) {
|
|
5326
|
-
return [];
|
|
5327
|
-
}
|
|
5328
|
-
res = this.tsProgram.getSyntacticDiagnostics(sourceFile, cancellationToken);
|
|
5329
|
-
} else {
|
|
5330
|
-
const diagnostics = [];
|
|
5331
|
-
for (const sf of this.tsProgram.getSourceFiles()) {
|
|
5332
|
-
if (!ignoredFiles.has(sf)) {
|
|
5333
|
-
diagnostics.push(...this.tsProgram.getSyntacticDiagnostics(sf, cancellationToken));
|
|
5334
|
-
}
|
|
5335
|
-
}
|
|
5336
|
-
res = diagnostics;
|
|
5337
|
-
}
|
|
5338
|
-
return res;
|
|
5339
|
-
});
|
|
5340
|
-
}
|
|
5341
|
-
getTsSemanticDiagnostics(sourceFile, cancellationToken) {
|
|
5342
|
-
if (this.options.compilationMode === "experimental-local") {
|
|
5343
|
-
return [];
|
|
5344
|
-
}
|
|
5345
|
-
return this.compiler.perfRecorder.inPhase(PerfPhase.TypeScriptDiagnostics, () => {
|
|
5346
|
-
const ignoredFiles = this.compiler.ignoreForDiagnostics;
|
|
5347
|
-
let res;
|
|
5348
|
-
if (sourceFile !== void 0) {
|
|
5349
|
-
if (ignoredFiles.has(sourceFile)) {
|
|
5350
|
-
return [];
|
|
5351
|
-
}
|
|
5352
|
-
res = this.tsProgram.getSemanticDiagnostics(sourceFile, cancellationToken);
|
|
5353
|
-
} else {
|
|
5354
|
-
const diagnostics = [];
|
|
5355
|
-
for (const sf of this.tsProgram.getSourceFiles()) {
|
|
5356
|
-
if (!ignoredFiles.has(sf)) {
|
|
5357
|
-
diagnostics.push(...this.tsProgram.getSemanticDiagnostics(sf, cancellationToken));
|
|
5358
|
-
}
|
|
5359
|
-
}
|
|
5360
|
-
res = diagnostics;
|
|
5361
|
-
}
|
|
5362
|
-
return res;
|
|
5363
|
-
});
|
|
5364
|
-
}
|
|
5365
|
-
getNgOptionDiagnostics(cancellationToken) {
|
|
5366
|
-
return this.compiler.getOptionDiagnostics();
|
|
5367
|
-
}
|
|
5368
|
-
getNgStructuralDiagnostics(cancellationToken) {
|
|
5369
|
-
return [];
|
|
5370
|
-
}
|
|
5371
|
-
getNgSemanticDiagnostics(fileName, cancellationToken) {
|
|
5372
|
-
let sf = void 0;
|
|
5373
|
-
if (fileName !== void 0) {
|
|
5374
|
-
sf = this.tsProgram.getSourceFile(fileName);
|
|
5375
|
-
if (sf === void 0) {
|
|
5376
|
-
return [];
|
|
5377
|
-
}
|
|
5378
|
-
}
|
|
5379
|
-
if (sf === void 0) {
|
|
5380
|
-
return this.compiler.getDiagnostics();
|
|
5381
|
-
} else {
|
|
5382
|
-
return this.compiler.getDiagnosticsForFile(sf, OptimizeFor.WholeProgram);
|
|
5383
|
-
}
|
|
5384
|
-
}
|
|
5385
|
-
/**
|
|
5386
|
-
* Ensure that the `NgCompiler` has properly analyzed the program, and allow for the asynchronous
|
|
5387
|
-
* loading of any resources during the process.
|
|
5388
|
-
*
|
|
5389
|
-
* This is used by the Angular CLI to allow for spawning (async) child compilations for things
|
|
5390
|
-
* like SASS files used in `styleUrls`.
|
|
5391
|
-
*/
|
|
5392
|
-
loadNgStructureAsync() {
|
|
5393
|
-
return this.compiler.analyzeAsync();
|
|
5394
|
-
}
|
|
5395
|
-
listLazyRoutes(entryRoute) {
|
|
5396
|
-
return [];
|
|
5397
|
-
}
|
|
5398
|
-
emitXi18n() {
|
|
5399
|
-
const ctx = new MessageBundle(new HtmlParser(), [], {}, this.options.i18nOutLocale ?? null, this.options.i18nPreserveWhitespaceForLegacyExtraction);
|
|
5400
|
-
this.compiler.xi18n(ctx);
|
|
5401
|
-
i18nExtract(this.options.i18nOutFormat ?? null, this.options.i18nOutFile ?? null, this.host, this.options, ctx, resolve);
|
|
5402
|
-
}
|
|
5403
|
-
emit(opts) {
|
|
5404
|
-
if (opts !== void 0 && opts.emitFlags !== void 0 && opts.emitFlags & EmitFlags.I18nBundle) {
|
|
5405
|
-
this.emitXi18n();
|
|
5406
|
-
if (!(opts.emitFlags & EmitFlags.JS)) {
|
|
5407
|
-
return {
|
|
5408
|
-
diagnostics: [],
|
|
5409
|
-
emitSkipped: true,
|
|
5410
|
-
emittedFiles: []
|
|
5411
|
-
};
|
|
5412
|
-
}
|
|
5413
|
-
}
|
|
5414
|
-
const forceEmit = opts?.forceEmit ?? false;
|
|
5415
|
-
this.compiler.perfRecorder.memory(PerfCheckpoint.PreEmit);
|
|
5416
|
-
const res = this.compiler.perfRecorder.inPhase(PerfPhase.TypeScriptEmit, () => {
|
|
5417
|
-
const { transformers } = this.compiler.prepareEmit();
|
|
5418
|
-
const ignoreFiles = this.compiler.ignoreForEmit;
|
|
5419
|
-
const emitCallback = opts?.emitCallback ?? defaultEmitCallback;
|
|
5420
|
-
const writeFile = (fileName, data, writeByteOrderMark, onError, sourceFiles) => {
|
|
5421
|
-
if (sourceFiles !== void 0) {
|
|
5422
|
-
for (const writtenSf of sourceFiles) {
|
|
5423
|
-
if (writtenSf.isDeclarationFile) {
|
|
5424
|
-
continue;
|
|
5425
|
-
}
|
|
5426
|
-
this.compiler.incrementalCompilation.recordSuccessfulEmit(writtenSf);
|
|
5427
|
-
}
|
|
5428
|
-
}
|
|
5429
|
-
this.host.writeFile(fileName, data, writeByteOrderMark, onError, sourceFiles);
|
|
5430
|
-
};
|
|
5431
|
-
const customTransforms = opts && opts.customTransformers;
|
|
5432
|
-
const beforeTransforms = transformers.before || [];
|
|
5433
|
-
const afterDeclarationsTransforms = transformers.afterDeclarations;
|
|
5434
|
-
if (customTransforms !== void 0 && customTransforms.beforeTs !== void 0) {
|
|
5435
|
-
beforeTransforms.push(...customTransforms.beforeTs);
|
|
5436
|
-
}
|
|
5437
|
-
const emitResults = [];
|
|
5438
|
-
for (const targetSourceFile of this.tsProgram.getSourceFiles()) {
|
|
5439
|
-
if (targetSourceFile.isDeclarationFile || ignoreFiles.has(targetSourceFile)) {
|
|
5440
|
-
continue;
|
|
5441
|
-
}
|
|
5442
|
-
if (!forceEmit && this.compiler.incrementalCompilation.safeToSkipEmit(targetSourceFile)) {
|
|
5443
|
-
this.compiler.perfRecorder.eventCount(PerfEvent.EmitSkipSourceFile);
|
|
5444
|
-
continue;
|
|
5445
|
-
}
|
|
5446
|
-
this.compiler.perfRecorder.eventCount(PerfEvent.EmitSourceFile);
|
|
5447
|
-
emitResults.push(emitCallback({
|
|
5448
|
-
targetSourceFile,
|
|
5449
|
-
program: this.tsProgram,
|
|
5450
|
-
host: this.host,
|
|
5451
|
-
options: this.options,
|
|
5452
|
-
emitOnlyDtsFiles: false,
|
|
5453
|
-
writeFile,
|
|
5454
|
-
customTransformers: {
|
|
5455
|
-
before: beforeTransforms,
|
|
5456
|
-
after: customTransforms && customTransforms.afterTs,
|
|
5457
|
-
afterDeclarations: afterDeclarationsTransforms
|
|
5458
|
-
}
|
|
5459
|
-
}));
|
|
5460
|
-
}
|
|
5461
|
-
this.compiler.perfRecorder.memory(PerfCheckpoint.Emit);
|
|
5462
|
-
return (opts && opts.mergeEmitResultsCallback || mergeEmitResults)(emitResults);
|
|
5463
|
-
});
|
|
5464
|
-
if (this.options.tracePerformance !== void 0) {
|
|
5465
|
-
const perf = this.compiler.perfRecorder.finalize();
|
|
5466
|
-
getFileSystem().writeFile(getFileSystem().resolve(this.options.tracePerformance), JSON.stringify(perf, null, 2));
|
|
5467
|
-
}
|
|
5468
|
-
return res;
|
|
5469
|
-
}
|
|
5470
|
-
getIndexedComponents() {
|
|
5471
|
-
return this.compiler.getIndexedComponents();
|
|
5472
|
-
}
|
|
5473
|
-
/**
|
|
5474
|
-
* Gets information for the current program that may be used to generate API
|
|
5475
|
-
* reference documentation. This includes Angular-specific information, such
|
|
5476
|
-
* as component inputs and outputs.
|
|
5477
|
-
*
|
|
5478
|
-
* @param entryPoint Path to the entry point for the package for which API
|
|
5479
|
-
* docs should be extracted.
|
|
5480
|
-
*/
|
|
5481
|
-
getApiDocumentation(entryPoint, privateModules) {
|
|
5482
|
-
return this.compiler.getApiDocumentation(entryPoint, privateModules);
|
|
5483
|
-
}
|
|
5484
|
-
getEmittedSourceFiles() {
|
|
5485
|
-
throw new Error("Method not implemented.");
|
|
5486
|
-
}
|
|
5487
|
-
};
|
|
5488
|
-
var defaultEmitCallback = ({ program, targetSourceFile, writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers }) => program.emit(targetSourceFile, writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers);
|
|
5489
|
-
function mergeEmitResults(emitResults) {
|
|
5490
|
-
const diagnostics = [];
|
|
5491
|
-
let emitSkipped = false;
|
|
5492
|
-
const emittedFiles = [];
|
|
5493
|
-
for (const er of emitResults) {
|
|
5494
|
-
diagnostics.push(...er.diagnostics);
|
|
5495
|
-
emitSkipped = emitSkipped || er.emitSkipped;
|
|
5496
|
-
emittedFiles.push(...er.emittedFiles || []);
|
|
5497
|
-
}
|
|
5498
|
-
return { diagnostics, emitSkipped, emittedFiles };
|
|
5499
|
-
}
|
|
5500
|
-
|
|
5501
|
-
// packages/compiler-cli/src/transformers/program.js
|
|
5502
|
-
function createProgram({ rootNames, options, host, oldProgram }) {
|
|
5503
|
-
return new NgtscProgram(rootNames, options, host, oldProgram);
|
|
5504
|
-
}
|
|
5505
|
-
|
|
5506
|
-
// packages/compiler-cli/src/perform_compile.js
|
|
5507
|
-
import ts30 from "typescript";
|
|
5508
|
-
|
|
5509
|
-
// packages/compiler-cli/src/transformers/util.js
|
|
5510
|
-
import ts29 from "typescript";
|
|
5511
|
-
function createMessageDiagnostic(messageText) {
|
|
5512
|
-
return {
|
|
5513
|
-
file: void 0,
|
|
5514
|
-
start: void 0,
|
|
5515
|
-
length: void 0,
|
|
5516
|
-
category: ts29.DiagnosticCategory.Message,
|
|
5517
|
-
messageText,
|
|
5518
|
-
code: DEFAULT_ERROR_CODE,
|
|
5519
|
-
source: SOURCE
|
|
5520
|
-
};
|
|
5521
|
-
}
|
|
5522
|
-
|
|
5523
|
-
// packages/compiler-cli/src/perform_compile.js
|
|
5524
|
-
var defaultFormatHost = {
|
|
5525
|
-
getCurrentDirectory: () => ts30.sys.getCurrentDirectory(),
|
|
5526
|
-
getCanonicalFileName: (fileName) => fileName,
|
|
5527
|
-
getNewLine: () => ts30.sys.newLine
|
|
5528
|
-
};
|
|
5529
|
-
function formatDiagnostics(diags, host = defaultFormatHost) {
|
|
5530
|
-
if (diags && diags.length) {
|
|
5531
|
-
return diags.map((diagnostic) => replaceTsWithNgInErrors(ts30.formatDiagnosticsWithColorAndContext([diagnostic], host))).join("");
|
|
5532
|
-
} else {
|
|
5533
|
-
return "";
|
|
5534
|
-
}
|
|
5535
|
-
}
|
|
5536
|
-
function calcProjectFileAndBasePath(project, host = getFileSystem()) {
|
|
5537
|
-
const absProject = host.resolve(project);
|
|
5538
|
-
const projectIsDir = host.lstat(absProject).isDirectory();
|
|
5539
|
-
const projectFile = projectIsDir ? host.join(absProject, "tsconfig.json") : absProject;
|
|
5540
|
-
const projectDir = projectIsDir ? absProject : host.dirname(absProject);
|
|
5541
|
-
const basePath = host.resolve(projectDir);
|
|
5542
|
-
return { projectFile, basePath };
|
|
5543
|
-
}
|
|
5544
|
-
function readConfiguration(project, existingOptions, host = getFileSystem()) {
|
|
5545
|
-
try {
|
|
5546
|
-
const fs = getFileSystem();
|
|
5547
|
-
const readConfigFile = (configFile) => ts30.readConfigFile(configFile, (file) => host.readFile(host.resolve(file)));
|
|
5548
|
-
const readAngularCompilerOptions = (configFile, parentOptions = {}) => {
|
|
5549
|
-
const { config: config2, error: error2 } = readConfigFile(configFile);
|
|
5550
|
-
if (error2) {
|
|
5551
|
-
return parentOptions;
|
|
5552
|
-
}
|
|
5553
|
-
const angularCompilerOptions = config2.angularCompilerOptions ?? config2.bazelOptions?.angularCompilerOptions;
|
|
5554
|
-
let existingNgCompilerOptions = { ...angularCompilerOptions, ...parentOptions };
|
|
5555
|
-
if (!config2.extends) {
|
|
5556
|
-
return existingNgCompilerOptions;
|
|
5557
|
-
}
|
|
5558
|
-
const extendsPaths = typeof config2.extends === "string" ? [config2.extends] : config2.extends;
|
|
5559
|
-
return [...extendsPaths].reverse().reduce((prevOptions, extendsPath) => {
|
|
5560
|
-
const extendedConfigPath = getExtendedConfigPath(configFile, extendsPath, host, fs);
|
|
5561
|
-
return extendedConfigPath === null ? prevOptions : readAngularCompilerOptions(extendedConfigPath, prevOptions);
|
|
5562
|
-
}, existingNgCompilerOptions);
|
|
5563
|
-
};
|
|
5564
|
-
const { projectFile, basePath } = calcProjectFileAndBasePath(project, host);
|
|
5565
|
-
const configFileName = host.resolve(host.pwd(), projectFile);
|
|
5566
|
-
const { config, error } = readConfigFile(projectFile);
|
|
5567
|
-
if (error) {
|
|
5568
|
-
return {
|
|
5569
|
-
project,
|
|
5570
|
-
errors: [error],
|
|
5571
|
-
rootNames: [],
|
|
5572
|
-
options: {},
|
|
5573
|
-
emitFlags: EmitFlags.Default
|
|
5574
|
-
};
|
|
5575
|
-
}
|
|
5576
|
-
const existingCompilerOptions = {
|
|
5577
|
-
genDir: basePath,
|
|
5578
|
-
basePath,
|
|
5579
|
-
...readAngularCompilerOptions(configFileName),
|
|
5580
|
-
...existingOptions
|
|
5581
|
-
};
|
|
5582
|
-
const parseConfigHost = createParseConfigHost(host, fs);
|
|
5583
|
-
const { options, errors, fileNames: rootNames, projectReferences } = ts30.parseJsonConfigFileContent(config, parseConfigHost, basePath, existingCompilerOptions, configFileName);
|
|
5584
|
-
let emitFlags = EmitFlags.Default;
|
|
5585
|
-
if (!(options["skipMetadataEmit"] || options["flatModuleOutFile"])) {
|
|
5586
|
-
emitFlags |= EmitFlags.Metadata;
|
|
5587
|
-
}
|
|
5588
|
-
if (options["skipTemplateCodegen"]) {
|
|
5589
|
-
emitFlags = emitFlags & ~EmitFlags.Codegen;
|
|
5590
|
-
}
|
|
5591
|
-
return { project: projectFile, rootNames, projectReferences, options, errors, emitFlags };
|
|
5592
|
-
} catch (e) {
|
|
5593
|
-
const errors = [
|
|
5594
|
-
{
|
|
5595
|
-
category: ts30.DiagnosticCategory.Error,
|
|
5596
|
-
messageText: e.stack ?? e.message,
|
|
5597
|
-
file: void 0,
|
|
5598
|
-
start: void 0,
|
|
5599
|
-
length: void 0,
|
|
5600
|
-
source: "angular",
|
|
5601
|
-
code: UNKNOWN_ERROR_CODE
|
|
5602
|
-
}
|
|
5603
|
-
];
|
|
5604
|
-
return { project: "", errors, rootNames: [], options: {}, emitFlags: EmitFlags.Default };
|
|
5605
|
-
}
|
|
5606
|
-
}
|
|
5607
|
-
function createParseConfigHost(host, fs = getFileSystem()) {
|
|
5608
|
-
return {
|
|
5609
|
-
fileExists: host.exists.bind(host),
|
|
5610
|
-
readDirectory: createFileSystemTsReadDirectoryFn(fs),
|
|
5611
|
-
readFile: host.readFile.bind(host),
|
|
5612
|
-
useCaseSensitiveFileNames: fs.isCaseSensitive()
|
|
5613
|
-
};
|
|
5614
|
-
}
|
|
5615
|
-
function getExtendedConfigPath(configFile, extendsValue, host, fs) {
|
|
5616
|
-
const result = getExtendedConfigPathWorker(configFile, extendsValue, host, fs);
|
|
5617
|
-
if (result !== null) {
|
|
5618
|
-
return result;
|
|
5619
|
-
}
|
|
5620
|
-
return getExtendedConfigPathWorker(configFile, `${extendsValue}.json`, host, fs);
|
|
5621
|
-
}
|
|
5622
|
-
function getExtendedConfigPathWorker(configFile, extendsValue, host, fs) {
|
|
5623
|
-
if (extendsValue.startsWith(".") || fs.isRooted(extendsValue)) {
|
|
5624
|
-
const extendedConfigPath = host.resolve(host.dirname(configFile), extendsValue);
|
|
5625
|
-
if (host.exists(extendedConfigPath)) {
|
|
5626
|
-
return extendedConfigPath;
|
|
5627
|
-
}
|
|
5628
|
-
} else {
|
|
5629
|
-
const parseConfigHost = createParseConfigHost(host, fs);
|
|
5630
|
-
const { resolvedModule } = ts30.nodeModuleNameResolver(extendsValue, configFile, { moduleResolution: ts30.ModuleResolutionKind.Node10, resolveJsonModule: true }, parseConfigHost);
|
|
5631
|
-
if (resolvedModule) {
|
|
5632
|
-
return absoluteFrom(resolvedModule.resolvedFileName);
|
|
5633
|
-
}
|
|
5634
|
-
}
|
|
5635
|
-
return null;
|
|
5636
|
-
}
|
|
5637
|
-
function exitCodeFromResult(diags) {
|
|
5638
|
-
if (!diags)
|
|
5639
|
-
return 0;
|
|
5640
|
-
if (diags.every((diag) => diag.category !== ts30.DiagnosticCategory.Error)) {
|
|
5641
|
-
return 0;
|
|
5642
|
-
}
|
|
5643
|
-
return diags.some((d) => d.source === "angular" && d.code === UNKNOWN_ERROR_CODE) ? 2 : 1;
|
|
5644
|
-
}
|
|
5645
|
-
function performCompilation({ rootNames, options, host, oldProgram, emitCallback, mergeEmitResultsCallback, gatherDiagnostics = defaultGatherDiagnostics, customTransformers, emitFlags = EmitFlags.Default, forceEmit = false, modifiedResourceFiles = null }) {
|
|
5646
|
-
let program;
|
|
5647
|
-
let emitResult;
|
|
5648
|
-
let allDiagnostics = [];
|
|
5649
|
-
try {
|
|
5650
|
-
if (!host) {
|
|
5651
|
-
host = createCompilerHost({ options });
|
|
5652
|
-
}
|
|
5653
|
-
if (modifiedResourceFiles) {
|
|
5654
|
-
host.getModifiedResourceFiles = () => modifiedResourceFiles;
|
|
5655
|
-
}
|
|
5656
|
-
program = createProgram({ rootNames, host, options, oldProgram });
|
|
5657
|
-
const beforeDiags = Date.now();
|
|
5658
|
-
allDiagnostics.push(...gatherDiagnostics(program));
|
|
5659
|
-
if (options.diagnostics) {
|
|
5660
|
-
const afterDiags = Date.now();
|
|
5661
|
-
allDiagnostics.push(createMessageDiagnostic(`Time for diagnostics: ${afterDiags - beforeDiags}ms.`));
|
|
5662
|
-
}
|
|
5663
|
-
if (!hasErrors(allDiagnostics)) {
|
|
5664
|
-
emitResult = program.emit({
|
|
5665
|
-
emitCallback,
|
|
5666
|
-
mergeEmitResultsCallback,
|
|
5667
|
-
customTransformers,
|
|
5668
|
-
emitFlags,
|
|
5669
|
-
forceEmit
|
|
5670
|
-
});
|
|
5671
|
-
allDiagnostics.push(...emitResult.diagnostics);
|
|
5672
|
-
return { diagnostics: allDiagnostics, program, emitResult };
|
|
5673
|
-
}
|
|
5674
|
-
return { diagnostics: allDiagnostics, program };
|
|
5675
|
-
} catch (e) {
|
|
5676
|
-
program = void 0;
|
|
5677
|
-
allDiagnostics.push({
|
|
5678
|
-
category: ts30.DiagnosticCategory.Error,
|
|
5679
|
-
messageText: e.stack ?? e.message,
|
|
5680
|
-
code: UNKNOWN_ERROR_CODE,
|
|
5681
|
-
file: void 0,
|
|
5682
|
-
start: void 0,
|
|
5683
|
-
length: void 0
|
|
5684
|
-
});
|
|
5685
|
-
return { diagnostics: allDiagnostics, program };
|
|
5686
|
-
}
|
|
5687
|
-
}
|
|
5688
|
-
function defaultGatherDiagnostics(program) {
|
|
5689
|
-
const allDiagnostics = [];
|
|
5690
|
-
function checkDiagnostics(diags) {
|
|
5691
|
-
if (diags) {
|
|
5692
|
-
allDiagnostics.push(...diags);
|
|
5693
|
-
return !hasErrors(diags);
|
|
5694
|
-
}
|
|
5695
|
-
return true;
|
|
5696
|
-
}
|
|
5697
|
-
let checkOtherDiagnostics = true;
|
|
5698
|
-
checkOtherDiagnostics = checkOtherDiagnostics && checkDiagnostics([...program.getTsOptionDiagnostics(), ...program.getNgOptionDiagnostics()]);
|
|
5699
|
-
checkOtherDiagnostics = checkOtherDiagnostics && checkDiagnostics(program.getTsSyntacticDiagnostics());
|
|
5700
|
-
checkOtherDiagnostics = checkOtherDiagnostics && checkDiagnostics([
|
|
5701
|
-
...program.getTsSemanticDiagnostics(),
|
|
5702
|
-
...program.getNgStructuralDiagnostics()
|
|
5703
|
-
]);
|
|
5704
|
-
checkOtherDiagnostics = checkOtherDiagnostics && checkDiagnostics(program.getNgSemanticDiagnostics());
|
|
5705
|
-
return allDiagnostics;
|
|
5706
|
-
}
|
|
5707
|
-
function hasErrors(diags) {
|
|
5708
|
-
return diags.some((d) => d.category === ts30.DiagnosticCategory.Error);
|
|
5709
|
-
}
|
|
5710
|
-
|
|
5711
5165
|
export {
|
|
5712
|
-
DEFAULT_ERROR_CODE,
|
|
5713
|
-
UNKNOWN_ERROR_CODE,
|
|
5714
|
-
SOURCE,
|
|
5715
|
-
isTsDiagnostic,
|
|
5716
|
-
EmitFlags,
|
|
5717
|
-
createCompilerHost,
|
|
5718
5166
|
EntryType,
|
|
5719
5167
|
MemberType,
|
|
5720
5168
|
DecoratorType,
|
|
5721
5169
|
MemberTags,
|
|
5722
5170
|
isDocEntryWithSourceInfo,
|
|
5723
5171
|
DocsExtractor,
|
|
5172
|
+
TrackedIncrementalBuildStrategy,
|
|
5724
5173
|
PatchedProgramIncrementalBuildStrategy,
|
|
5174
|
+
DiagnosticCategoryLabel,
|
|
5725
5175
|
freshCompilationTicket,
|
|
5176
|
+
incrementalFromCompilerTicket,
|
|
5726
5177
|
incrementalFromStateTicket,
|
|
5727
5178
|
NgCompiler,
|
|
5728
|
-
NgCompilerHost
|
|
5729
|
-
NgtscProgram,
|
|
5730
|
-
createProgram,
|
|
5731
|
-
createMessageDiagnostic,
|
|
5732
|
-
formatDiagnostics,
|
|
5733
|
-
calcProjectFileAndBasePath,
|
|
5734
|
-
readConfiguration,
|
|
5735
|
-
exitCodeFromResult,
|
|
5736
|
-
performCompilation,
|
|
5737
|
-
defaultGatherDiagnostics
|
|
5179
|
+
NgCompilerHost
|
|
5738
5180
|
};
|
|
5739
5181
|
/**
|
|
5740
5182
|
* @license
|