@angular/compiler-cli 17.0.0-rc.1 → 17.0.0-rc.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bundles/{chunk-47YFDVF5.js → chunk-2I2I3FLR.js} +84 -80
- package/bundles/{chunk-47YFDVF5.js.map → chunk-2I2I3FLR.js.map} +1 -1
- package/bundles/{chunk-W22VYY2W.js → chunk-BV3ZUD7T.js} +5 -5
- package/bundles/{chunk-OULZQUKT.js → chunk-EKTJ7622.js} +7 -7
- package/bundles/{chunk-IB7D76E2.js → chunk-ELZXPNCU.js} +224 -154
- package/bundles/chunk-ELZXPNCU.js.map +6 -0
- package/bundles/{chunk-3O3O4L34.js → chunk-JZC4T2RR.js} +1 -1
- package/bundles/{chunk-CF2CT7RQ.js → chunk-LYJKWJUC.js} +3 -3
- package/bundles/{chunk-L2LBTQAL.js → chunk-MHTLEXGT.js} +4 -4
- package/bundles/{chunk-BBHDYHY4.js → chunk-N7FTHCOD.js} +5 -5
- package/bundles/{chunk-NATK4QBU.js → chunk-OTTOC3WQ.js} +27 -27
- package/bundles/{chunk-W653LDC7.js → chunk-PCMLSPQF.js} +7 -7
- package/bundles/{chunk-UN5ELNTU.js → chunk-SKLJR6LO.js} +396 -352
- package/bundles/chunk-SKLJR6LO.js.map +6 -0
- package/bundles/{chunk-YSUF4ELW.js → chunk-Z4QM3XT4.js} +30 -30
- package/bundles/index.js +15 -13
- package/bundles/index.js.map +1 -1
- package/bundles/linker/babel/index.js +13 -13
- package/bundles/linker/index.js +5 -5
- package/bundles/ngcc/index.js +1 -1
- package/bundles/private/bazel.js +1 -1
- package/bundles/private/localize.js +3 -3
- package/bundles/private/migrations.js +6 -6
- package/bundles/private/tooling.js +4 -4
- package/bundles/src/bin/ng_xi18n.js +11 -11
- package/bundles/src/bin/ngc.js +9 -9
- package/bundles_metadata.json +1 -1
- package/linker/src/file_linker/partial_linkers/util.d.ts +1 -1
- package/package.json +3 -3
- package/src/ngtsc/docs/src/decorator_extractor.d.ts +15 -0
- package/src/ngtsc/docs/src/entities.d.ts +13 -2
- package/src/ngtsc/docs/src/jsdoc_extractor.d.ts +2 -2
- package/src/ngtsc/metadata/src/api.d.ts +1 -1
- package/src/ngtsc/translator/index.d.ts +1 -0
- package/src/ngtsc/typecheck/src/environment.d.ts +2 -2
- package/bundles/chunk-IB7D76E2.js.map +0 -6
- package/bundles/chunk-UN5ELNTU.js.map +0 -6
- /package/bundles/{chunk-W22VYY2W.js.map → chunk-BV3ZUD7T.js.map} +0 -0
- /package/bundles/{chunk-OULZQUKT.js.map → chunk-EKTJ7622.js.map} +0 -0
- /package/bundles/{chunk-3O3O4L34.js.map → chunk-JZC4T2RR.js.map} +0 -0
- /package/bundles/{chunk-CF2CT7RQ.js.map → chunk-LYJKWJUC.js.map} +0 -0
- /package/bundles/{chunk-L2LBTQAL.js.map → chunk-MHTLEXGT.js.map} +0 -0
- /package/bundles/{chunk-BBHDYHY4.js.map → chunk-N7FTHCOD.js.map} +0 -0
- /package/bundles/{chunk-NATK4QBU.js.map → chunk-OTTOC3WQ.js.map} +0 -0
- /package/bundles/{chunk-W653LDC7.js.map → chunk-PCMLSPQF.js.map} +0 -0
- /package/bundles/{chunk-YSUF4ELW.js.map → chunk-Z4QM3XT4.js.map} +0 -0
- /package/src/ngtsc/{typecheck → translator}/src/type_emitter.d.ts +0 -0
|
@@ -7,9 +7,9 @@ import {
|
|
|
7
7
|
NoopImportRewriter,
|
|
8
8
|
Reference,
|
|
9
9
|
assertSuccessfulReferenceEmit
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-OTTOC3WQ.js";
|
|
11
11
|
|
|
12
|
-
// bazel-out/
|
|
12
|
+
// bazel-out/k8-fastbuild/bin/packages/compiler-cli/src/ngtsc/translator/src/context.mjs
|
|
13
13
|
var Context = class {
|
|
14
14
|
constructor(isStatement) {
|
|
15
15
|
this.isStatement = isStatement;
|
|
@@ -22,7 +22,7 @@ var Context = class {
|
|
|
22
22
|
}
|
|
23
23
|
};
|
|
24
24
|
|
|
25
|
-
// bazel-out/
|
|
25
|
+
// bazel-out/k8-fastbuild/bin/packages/compiler-cli/src/ngtsc/translator/src/translator.mjs
|
|
26
26
|
import * as o from "@angular/compiler";
|
|
27
27
|
var UNARY_OPERATORS = /* @__PURE__ */ new Map([
|
|
28
28
|
[o.UnaryOperator.Minus, "-"],
|
|
@@ -260,7 +260,7 @@ function createRange(span) {
|
|
|
260
260
|
};
|
|
261
261
|
}
|
|
262
262
|
|
|
263
|
-
// bazel-out/
|
|
263
|
+
// bazel-out/k8-fastbuild/bin/packages/compiler-cli/src/ngtsc/translator/src/import_manager.mjs
|
|
264
264
|
import ts from "typescript";
|
|
265
265
|
var ImportManager = class {
|
|
266
266
|
constructor(rewriter = new NoopImportRewriter(), prefix = "i") {
|
|
@@ -296,9 +296,84 @@ var ImportManager = class {
|
|
|
296
296
|
}
|
|
297
297
|
};
|
|
298
298
|
|
|
299
|
-
// bazel-out/
|
|
300
|
-
import * as o2 from "@angular/compiler";
|
|
299
|
+
// bazel-out/k8-fastbuild/bin/packages/compiler-cli/src/ngtsc/translator/src/type_emitter.mjs
|
|
301
300
|
import ts2 from "typescript";
|
|
301
|
+
var INELIGIBLE = {};
|
|
302
|
+
function canEmitType(type, canEmit) {
|
|
303
|
+
return canEmitTypeWorker(type);
|
|
304
|
+
function canEmitTypeWorker(type2) {
|
|
305
|
+
return visitNode(type2) !== INELIGIBLE;
|
|
306
|
+
}
|
|
307
|
+
function visitNode(node) {
|
|
308
|
+
if (ts2.isImportTypeNode(node)) {
|
|
309
|
+
return INELIGIBLE;
|
|
310
|
+
}
|
|
311
|
+
if (ts2.isTypeReferenceNode(node) && !canEmitTypeReference(node)) {
|
|
312
|
+
return INELIGIBLE;
|
|
313
|
+
} else {
|
|
314
|
+
return ts2.forEachChild(node, visitNode);
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
function canEmitTypeReference(type2) {
|
|
318
|
+
if (!canEmit(type2)) {
|
|
319
|
+
return false;
|
|
320
|
+
}
|
|
321
|
+
return type2.typeArguments === void 0 || type2.typeArguments.every(canEmitTypeWorker);
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
var TypeEmitter = class {
|
|
325
|
+
constructor(translator) {
|
|
326
|
+
this.translator = translator;
|
|
327
|
+
}
|
|
328
|
+
emitType(type) {
|
|
329
|
+
const typeReferenceTransformer = (context) => {
|
|
330
|
+
const visitNode = (node) => {
|
|
331
|
+
if (ts2.isImportTypeNode(node)) {
|
|
332
|
+
throw new Error("Unable to emit import type");
|
|
333
|
+
}
|
|
334
|
+
if (ts2.isTypeReferenceNode(node)) {
|
|
335
|
+
return this.emitTypeReference(node);
|
|
336
|
+
} else if (ts2.isLiteralExpression(node)) {
|
|
337
|
+
let clone;
|
|
338
|
+
if (ts2.isStringLiteral(node)) {
|
|
339
|
+
clone = ts2.factory.createStringLiteral(node.text);
|
|
340
|
+
} else if (ts2.isNumericLiteral(node)) {
|
|
341
|
+
clone = ts2.factory.createNumericLiteral(node.text);
|
|
342
|
+
} else if (ts2.isBigIntLiteral(node)) {
|
|
343
|
+
clone = ts2.factory.createBigIntLiteral(node.text);
|
|
344
|
+
} else if (ts2.isNoSubstitutionTemplateLiteral(node)) {
|
|
345
|
+
clone = ts2.factory.createNoSubstitutionTemplateLiteral(node.text, node.rawText);
|
|
346
|
+
} else if (ts2.isRegularExpressionLiteral(node)) {
|
|
347
|
+
clone = ts2.factory.createRegularExpressionLiteral(node.text);
|
|
348
|
+
} else {
|
|
349
|
+
throw new Error(`Unsupported literal kind ${ts2.SyntaxKind[node.kind]}`);
|
|
350
|
+
}
|
|
351
|
+
ts2.setTextRange(clone, { pos: -1, end: -1 });
|
|
352
|
+
return clone;
|
|
353
|
+
} else {
|
|
354
|
+
return ts2.visitEachChild(node, visitNode, context);
|
|
355
|
+
}
|
|
356
|
+
};
|
|
357
|
+
return (node) => ts2.visitNode(node, visitNode, ts2.isTypeNode);
|
|
358
|
+
};
|
|
359
|
+
return ts2.transform(type, [typeReferenceTransformer]).transformed[0];
|
|
360
|
+
}
|
|
361
|
+
emitTypeReference(type) {
|
|
362
|
+
const translatedType = this.translator(type);
|
|
363
|
+
if (translatedType === null) {
|
|
364
|
+
throw new Error("Unable to emit an unresolved reference");
|
|
365
|
+
}
|
|
366
|
+
let typeArguments = void 0;
|
|
367
|
+
if (type.typeArguments !== void 0) {
|
|
368
|
+
typeArguments = ts2.factory.createNodeArray(type.typeArguments.map((typeArg) => this.emitType(typeArg)));
|
|
369
|
+
}
|
|
370
|
+
return ts2.factory.updateTypeReferenceNode(type, translatedType.typeName, typeArguments);
|
|
371
|
+
}
|
|
372
|
+
};
|
|
373
|
+
|
|
374
|
+
// bazel-out/k8-fastbuild/bin/packages/compiler-cli/src/ngtsc/translator/src/type_translator.mjs
|
|
375
|
+
import * as o2 from "@angular/compiler";
|
|
376
|
+
import ts3 from "typescript";
|
|
302
377
|
function translateType(type, contextFile, reflector, refEmitter, imports) {
|
|
303
378
|
return type.visitType(new TypeTranslatorVisitor(imports, contextFile, reflector, refEmitter), new Context(false));
|
|
304
379
|
}
|
|
@@ -312,16 +387,16 @@ var TypeTranslatorVisitor = class {
|
|
|
312
387
|
visitBuiltinType(type, context) {
|
|
313
388
|
switch (type.name) {
|
|
314
389
|
case o2.BuiltinTypeName.Bool:
|
|
315
|
-
return
|
|
390
|
+
return ts3.factory.createKeywordTypeNode(ts3.SyntaxKind.BooleanKeyword);
|
|
316
391
|
case o2.BuiltinTypeName.Dynamic:
|
|
317
|
-
return
|
|
392
|
+
return ts3.factory.createKeywordTypeNode(ts3.SyntaxKind.AnyKeyword);
|
|
318
393
|
case o2.BuiltinTypeName.Int:
|
|
319
394
|
case o2.BuiltinTypeName.Number:
|
|
320
|
-
return
|
|
395
|
+
return ts3.factory.createKeywordTypeNode(ts3.SyntaxKind.NumberKeyword);
|
|
321
396
|
case o2.BuiltinTypeName.String:
|
|
322
|
-
return
|
|
397
|
+
return ts3.factory.createKeywordTypeNode(ts3.SyntaxKind.StringKeyword);
|
|
323
398
|
case o2.BuiltinTypeName.None:
|
|
324
|
-
return
|
|
399
|
+
return ts3.factory.createKeywordTypeNode(ts3.SyntaxKind.NeverKeyword);
|
|
325
400
|
default:
|
|
326
401
|
throw new Error(`Unsupported builtin type: ${o2.BuiltinTypeName[type.name]}`);
|
|
327
402
|
}
|
|
@@ -331,34 +406,37 @@ var TypeTranslatorVisitor = class {
|
|
|
331
406
|
if (type.typeParams === null) {
|
|
332
407
|
return typeNode;
|
|
333
408
|
}
|
|
334
|
-
if (!
|
|
409
|
+
if (!ts3.isTypeReferenceNode(typeNode)) {
|
|
335
410
|
throw new Error("An ExpressionType with type arguments must translate into a TypeReferenceNode");
|
|
336
411
|
} else if (typeNode.typeArguments !== void 0) {
|
|
337
412
|
throw new Error(`An ExpressionType with type arguments cannot have multiple levels of type arguments`);
|
|
338
413
|
}
|
|
339
414
|
const typeArgs = type.typeParams.map((param) => this.translateType(param, context));
|
|
340
|
-
return
|
|
415
|
+
return ts3.factory.createTypeReferenceNode(typeNode.typeName, typeArgs);
|
|
341
416
|
}
|
|
342
417
|
visitArrayType(type, context) {
|
|
343
|
-
return
|
|
418
|
+
return ts3.factory.createArrayTypeNode(this.translateType(type.of, context));
|
|
344
419
|
}
|
|
345
420
|
visitMapType(type, context) {
|
|
346
|
-
const parameter =
|
|
347
|
-
const typeArgs = type.valueType !== null ? this.translateType(type.valueType, context) :
|
|
348
|
-
const indexSignature =
|
|
349
|
-
return
|
|
421
|
+
const parameter = ts3.factory.createParameterDeclaration(void 0, void 0, "key", void 0, ts3.factory.createKeywordTypeNode(ts3.SyntaxKind.StringKeyword));
|
|
422
|
+
const typeArgs = type.valueType !== null ? this.translateType(type.valueType, context) : ts3.factory.createKeywordTypeNode(ts3.SyntaxKind.UnknownKeyword);
|
|
423
|
+
const indexSignature = ts3.factory.createIndexSignature(void 0, [parameter], typeArgs);
|
|
424
|
+
return ts3.factory.createTypeLiteralNode([indexSignature]);
|
|
350
425
|
}
|
|
351
426
|
visitTransplantedType(ast, context) {
|
|
352
|
-
|
|
427
|
+
const node = ast.type instanceof Reference ? ast.type.node : ast.type;
|
|
428
|
+
if (!ts3.isTypeNode(node)) {
|
|
353
429
|
throw new Error(`A TransplantedType must wrap a TypeNode`);
|
|
354
430
|
}
|
|
355
|
-
|
|
431
|
+
const viaModule = ast.type instanceof Reference ? ast.type.bestGuessOwningModule : null;
|
|
432
|
+
const emitter = new TypeEmitter((typeRef) => this.translateTypeReference(typeRef, context, viaModule));
|
|
433
|
+
return emitter.emitType(node);
|
|
356
434
|
}
|
|
357
435
|
visitReadVarExpr(ast, context) {
|
|
358
436
|
if (ast.name === null) {
|
|
359
437
|
throw new Error(`ReadVarExpr with no variable name in type`);
|
|
360
438
|
}
|
|
361
|
-
return
|
|
439
|
+
return ts3.factory.createTypeQueryNode(ts3.factory.createIdentifier(ast.name));
|
|
362
440
|
}
|
|
363
441
|
visitWriteVarExpr(expr, context) {
|
|
364
442
|
throw new Error("Method not implemented.");
|
|
@@ -380,15 +458,15 @@ var TypeTranslatorVisitor = class {
|
|
|
380
458
|
}
|
|
381
459
|
visitLiteralExpr(ast, context) {
|
|
382
460
|
if (ast.value === null) {
|
|
383
|
-
return
|
|
461
|
+
return ts3.factory.createLiteralTypeNode(ts3.factory.createNull());
|
|
384
462
|
} else if (ast.value === void 0) {
|
|
385
|
-
return
|
|
463
|
+
return ts3.factory.createKeywordTypeNode(ts3.SyntaxKind.UndefinedKeyword);
|
|
386
464
|
} else if (typeof ast.value === "boolean") {
|
|
387
|
-
return
|
|
465
|
+
return ts3.factory.createLiteralTypeNode(ast.value ? ts3.factory.createTrue() : ts3.factory.createFalse());
|
|
388
466
|
} else if (typeof ast.value === "number") {
|
|
389
|
-
return
|
|
467
|
+
return ts3.factory.createLiteralTypeNode(ts3.factory.createNumericLiteral(ast.value));
|
|
390
468
|
} else {
|
|
391
|
-
return
|
|
469
|
+
return ts3.factory.createLiteralTypeNode(ts3.factory.createStringLiteral(ast.value));
|
|
392
470
|
}
|
|
393
471
|
}
|
|
394
472
|
visitLocalizedString(ast, context) {
|
|
@@ -399,10 +477,10 @@ var TypeTranslatorVisitor = class {
|
|
|
399
477
|
throw new Error(`Import unknown module or symbol`);
|
|
400
478
|
}
|
|
401
479
|
const { moduleImport, symbol } = this.imports.generateNamedImport(ast.value.moduleName, ast.value.name);
|
|
402
|
-
const symbolIdentifier =
|
|
403
|
-
const typeName = moduleImport ?
|
|
480
|
+
const symbolIdentifier = ts3.factory.createIdentifier(symbol);
|
|
481
|
+
const typeName = moduleImport ? ts3.factory.createQualifiedName(moduleImport, symbolIdentifier) : symbolIdentifier;
|
|
404
482
|
const typeArguments = ast.typeParams !== null ? ast.typeParams.map((type) => this.translateType(type, context)) : void 0;
|
|
405
|
-
return
|
|
483
|
+
return ts3.factory.createTypeReferenceNode(typeName, typeArguments);
|
|
406
484
|
}
|
|
407
485
|
visitConditionalExpr(ast, context) {
|
|
408
486
|
throw new Error("Method not implemented.");
|
|
@@ -433,157 +511,147 @@ var TypeTranslatorVisitor = class {
|
|
|
433
511
|
}
|
|
434
512
|
visitLiteralArrayExpr(ast, context) {
|
|
435
513
|
const values = ast.entries.map((expr) => this.translateExpression(expr, context));
|
|
436
|
-
return
|
|
514
|
+
return ts3.factory.createTupleTypeNode(values);
|
|
437
515
|
}
|
|
438
516
|
visitLiteralMapExpr(ast, context) {
|
|
439
517
|
const entries = ast.entries.map((entry) => {
|
|
440
518
|
const { key, quoted } = entry;
|
|
441
519
|
const type = this.translateExpression(entry.value, context);
|
|
442
|
-
return
|
|
520
|
+
return ts3.factory.createPropertySignature(
|
|
443
521
|
void 0,
|
|
444
|
-
quoted ?
|
|
522
|
+
quoted ? ts3.factory.createStringLiteral(key) : key,
|
|
445
523
|
void 0,
|
|
446
524
|
type
|
|
447
525
|
);
|
|
448
526
|
});
|
|
449
|
-
return
|
|
527
|
+
return ts3.factory.createTypeLiteralNode(entries);
|
|
450
528
|
}
|
|
451
529
|
visitCommaExpr(ast, context) {
|
|
452
530
|
throw new Error("Method not implemented.");
|
|
453
531
|
}
|
|
454
532
|
visitWrappedNodeExpr(ast, context) {
|
|
455
533
|
const node = ast.node;
|
|
456
|
-
if (
|
|
457
|
-
return
|
|
458
|
-
} else if (
|
|
534
|
+
if (ts3.isEntityName(node)) {
|
|
535
|
+
return ts3.factory.createTypeReferenceNode(node, void 0);
|
|
536
|
+
} else if (ts3.isTypeNode(node)) {
|
|
459
537
|
return node;
|
|
460
|
-
} else if (
|
|
461
|
-
return
|
|
538
|
+
} else if (ts3.isLiteralExpression(node)) {
|
|
539
|
+
return ts3.factory.createLiteralTypeNode(node);
|
|
462
540
|
} else {
|
|
463
|
-
throw new Error(`Unsupported WrappedNodeExpr in TypeTranslatorVisitor: ${
|
|
541
|
+
throw new Error(`Unsupported WrappedNodeExpr in TypeTranslatorVisitor: ${ts3.SyntaxKind[node.kind]}`);
|
|
464
542
|
}
|
|
465
543
|
}
|
|
466
544
|
visitTypeofExpr(ast, context) {
|
|
467
545
|
const typeNode = this.translateExpression(ast.expr, context);
|
|
468
|
-
if (!
|
|
546
|
+
if (!ts3.isTypeReferenceNode(typeNode)) {
|
|
469
547
|
throw new Error(`The target of a typeof expression must be a type reference, but it was
|
|
470
|
-
${
|
|
548
|
+
${ts3.SyntaxKind[typeNode.kind]}`);
|
|
471
549
|
}
|
|
472
|
-
return
|
|
550
|
+
return ts3.factory.createTypeQueryNode(typeNode.typeName);
|
|
473
551
|
}
|
|
474
552
|
translateType(type, context) {
|
|
475
553
|
const typeNode = type.visitType(this, context);
|
|
476
|
-
if (!
|
|
477
|
-
throw new Error(`A Type must translate to a TypeNode, but was ${
|
|
554
|
+
if (!ts3.isTypeNode(typeNode)) {
|
|
555
|
+
throw new Error(`A Type must translate to a TypeNode, but was ${ts3.SyntaxKind[typeNode.kind]}`);
|
|
478
556
|
}
|
|
479
557
|
return typeNode;
|
|
480
558
|
}
|
|
481
559
|
translateExpression(expr, context) {
|
|
482
560
|
const typeNode = expr.visitExpression(this, context);
|
|
483
|
-
if (!
|
|
484
|
-
throw new Error(`An Expression must translate to a TypeNode, but was ${
|
|
561
|
+
if (!ts3.isTypeNode(typeNode)) {
|
|
562
|
+
throw new Error(`An Expression must translate to a TypeNode, but was ${ts3.SyntaxKind[typeNode.kind]}`);
|
|
485
563
|
}
|
|
486
564
|
return typeNode;
|
|
487
565
|
}
|
|
488
|
-
|
|
489
|
-
const
|
|
566
|
+
translateTypeReference(type, context, viaModule) {
|
|
567
|
+
const target = ts3.isIdentifier(type.typeName) ? type.typeName : type.typeName.right;
|
|
568
|
+
const declaration = this.reflector.getDeclarationOfIdentifier(target);
|
|
490
569
|
if (declaration === null) {
|
|
491
|
-
throw new Error(`Unable to statically determine the declaration file of type node ${
|
|
492
|
-
}
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
}
|
|
499
|
-
if (node.typeArguments === void 0 || node.typeArguments.length === 0) {
|
|
500
|
-
return result;
|
|
501
|
-
}
|
|
502
|
-
const translatedArgs = node.typeArguments.map((arg) => this.translateTransplantedTypeNode(arg, context));
|
|
503
|
-
return ts2.factory.updateTypeReferenceNode(result, result.typeName, ts2.factory.createNodeArray(translatedArgs));
|
|
504
|
-
}
|
|
505
|
-
translateTransplantedTypeNode(rootNode, context) {
|
|
506
|
-
const factory = (transformContext) => (root) => {
|
|
507
|
-
const walk = (node) => {
|
|
508
|
-
if (ts2.isTypeReferenceNode(node) && ts2.isIdentifier(node.typeName)) {
|
|
509
|
-
const translated = this.translateTransplantedTypeReferenceNode(node, context);
|
|
510
|
-
if (translated !== node) {
|
|
511
|
-
return translated;
|
|
512
|
-
}
|
|
513
|
-
}
|
|
514
|
-
return ts2.visitEachChild(node, walk, transformContext);
|
|
570
|
+
throw new Error(`Unable to statically determine the declaration file of type node ${target.text}`);
|
|
571
|
+
}
|
|
572
|
+
let owningModule = viaModule;
|
|
573
|
+
if (declaration.viaModule !== null) {
|
|
574
|
+
owningModule = {
|
|
575
|
+
specifier: declaration.viaModule,
|
|
576
|
+
resolutionContext: type.getSourceFile().fileName
|
|
515
577
|
};
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
578
|
+
}
|
|
579
|
+
const reference = new Reference(declaration.node, owningModule);
|
|
580
|
+
const emittedType = this.refEmitter.emit(reference, this.contextFile, ImportFlags.NoAliasing | ImportFlags.AllowTypeImports);
|
|
581
|
+
assertSuccessfulReferenceEmit(emittedType, target, "type");
|
|
582
|
+
const typeNode = this.translateExpression(emittedType.expression, context);
|
|
583
|
+
if (!ts3.isTypeReferenceNode(typeNode)) {
|
|
584
|
+
throw new Error(`Expected TypeReferenceNode for emitted reference, got ${ts3.SyntaxKind[typeNode.kind]}.`);
|
|
585
|
+
}
|
|
586
|
+
return typeNode;
|
|
519
587
|
}
|
|
520
588
|
};
|
|
521
589
|
|
|
522
|
-
// bazel-out/
|
|
523
|
-
import
|
|
590
|
+
// bazel-out/k8-fastbuild/bin/packages/compiler-cli/src/ngtsc/translator/src/typescript_ast_factory.mjs
|
|
591
|
+
import ts4 from "typescript";
|
|
524
592
|
var PureAnnotation;
|
|
525
593
|
(function(PureAnnotation2) {
|
|
526
594
|
PureAnnotation2["CLOSURE"] = "* @pureOrBreakMyCode ";
|
|
527
595
|
PureAnnotation2["TERSER"] = "@__PURE__";
|
|
528
596
|
})(PureAnnotation || (PureAnnotation = {}));
|
|
529
597
|
var UNARY_OPERATORS2 = {
|
|
530
|
-
"+":
|
|
531
|
-
"-":
|
|
532
|
-
"!":
|
|
598
|
+
"+": ts4.SyntaxKind.PlusToken,
|
|
599
|
+
"-": ts4.SyntaxKind.MinusToken,
|
|
600
|
+
"!": ts4.SyntaxKind.ExclamationToken
|
|
533
601
|
};
|
|
534
602
|
var BINARY_OPERATORS2 = {
|
|
535
|
-
"&&":
|
|
536
|
-
">":
|
|
537
|
-
">=":
|
|
538
|
-
"&":
|
|
539
|
-
"/":
|
|
540
|
-
"==":
|
|
541
|
-
"===":
|
|
542
|
-
"<":
|
|
543
|
-
"<=":
|
|
544
|
-
"-":
|
|
545
|
-
"%":
|
|
546
|
-
"*":
|
|
547
|
-
"!=":
|
|
548
|
-
"!==":
|
|
549
|
-
"||":
|
|
550
|
-
"+":
|
|
551
|
-
"??":
|
|
603
|
+
"&&": ts4.SyntaxKind.AmpersandAmpersandToken,
|
|
604
|
+
">": ts4.SyntaxKind.GreaterThanToken,
|
|
605
|
+
">=": ts4.SyntaxKind.GreaterThanEqualsToken,
|
|
606
|
+
"&": ts4.SyntaxKind.AmpersandToken,
|
|
607
|
+
"/": ts4.SyntaxKind.SlashToken,
|
|
608
|
+
"==": ts4.SyntaxKind.EqualsEqualsToken,
|
|
609
|
+
"===": ts4.SyntaxKind.EqualsEqualsEqualsToken,
|
|
610
|
+
"<": ts4.SyntaxKind.LessThanToken,
|
|
611
|
+
"<=": ts4.SyntaxKind.LessThanEqualsToken,
|
|
612
|
+
"-": ts4.SyntaxKind.MinusToken,
|
|
613
|
+
"%": ts4.SyntaxKind.PercentToken,
|
|
614
|
+
"*": ts4.SyntaxKind.AsteriskToken,
|
|
615
|
+
"!=": ts4.SyntaxKind.ExclamationEqualsToken,
|
|
616
|
+
"!==": ts4.SyntaxKind.ExclamationEqualsEqualsToken,
|
|
617
|
+
"||": ts4.SyntaxKind.BarBarToken,
|
|
618
|
+
"+": ts4.SyntaxKind.PlusToken,
|
|
619
|
+
"??": ts4.SyntaxKind.QuestionQuestionToken
|
|
552
620
|
};
|
|
553
621
|
var VAR_TYPES = {
|
|
554
|
-
"const":
|
|
555
|
-
"let":
|
|
556
|
-
"var":
|
|
622
|
+
"const": ts4.NodeFlags.Const,
|
|
623
|
+
"let": ts4.NodeFlags.Let,
|
|
624
|
+
"var": ts4.NodeFlags.None
|
|
557
625
|
};
|
|
558
626
|
var TypeScriptAstFactory = class {
|
|
559
627
|
constructor(annotateForClosureCompiler) {
|
|
560
628
|
this.annotateForClosureCompiler = annotateForClosureCompiler;
|
|
561
629
|
this.externalSourceFiles = /* @__PURE__ */ new Map();
|
|
562
630
|
this.attachComments = attachComments;
|
|
563
|
-
this.createArrayLiteral =
|
|
564
|
-
this.createElementAccess =
|
|
565
|
-
this.createExpressionStatement =
|
|
566
|
-
this.createIdentifier =
|
|
567
|
-
this.createParenthesizedExpression =
|
|
568
|
-
this.createPropertyAccess =
|
|
569
|
-
this.createThrowStatement =
|
|
570
|
-
this.createTypeOfExpression =
|
|
631
|
+
this.createArrayLiteral = ts4.factory.createArrayLiteralExpression;
|
|
632
|
+
this.createElementAccess = ts4.factory.createElementAccessExpression;
|
|
633
|
+
this.createExpressionStatement = ts4.factory.createExpressionStatement;
|
|
634
|
+
this.createIdentifier = ts4.factory.createIdentifier;
|
|
635
|
+
this.createParenthesizedExpression = ts4.factory.createParenthesizedExpression;
|
|
636
|
+
this.createPropertyAccess = ts4.factory.createPropertyAccessExpression;
|
|
637
|
+
this.createThrowStatement = ts4.factory.createThrowStatement;
|
|
638
|
+
this.createTypeOfExpression = ts4.factory.createTypeOfExpression;
|
|
571
639
|
}
|
|
572
640
|
createAssignment(target, value) {
|
|
573
|
-
return
|
|
641
|
+
return ts4.factory.createBinaryExpression(target, ts4.SyntaxKind.EqualsToken, value);
|
|
574
642
|
}
|
|
575
643
|
createBinaryExpression(leftOperand, operator, rightOperand) {
|
|
576
|
-
return
|
|
644
|
+
return ts4.factory.createBinaryExpression(leftOperand, BINARY_OPERATORS2[operator], rightOperand);
|
|
577
645
|
}
|
|
578
646
|
createBlock(body) {
|
|
579
|
-
return
|
|
647
|
+
return ts4.factory.createBlock(body);
|
|
580
648
|
}
|
|
581
649
|
createCallExpression(callee, args, pure) {
|
|
582
|
-
const call =
|
|
650
|
+
const call = ts4.factory.createCallExpression(callee, void 0, args);
|
|
583
651
|
if (pure) {
|
|
584
|
-
|
|
652
|
+
ts4.addSyntheticLeadingComment(
|
|
585
653
|
call,
|
|
586
|
-
|
|
654
|
+
ts4.SyntaxKind.MultiLineCommentTrivia,
|
|
587
655
|
this.annotateForClosureCompiler ? PureAnnotation.CLOSURE : PureAnnotation.TERSER,
|
|
588
656
|
false
|
|
589
657
|
);
|
|
@@ -591,64 +659,64 @@ var TypeScriptAstFactory = class {
|
|
|
591
659
|
return call;
|
|
592
660
|
}
|
|
593
661
|
createConditional(condition, whenTrue, whenFalse) {
|
|
594
|
-
return
|
|
662
|
+
return ts4.factory.createConditionalExpression(condition, void 0, whenTrue, void 0, whenFalse);
|
|
595
663
|
}
|
|
596
664
|
createDynamicImport(url) {
|
|
597
|
-
return
|
|
598
|
-
|
|
665
|
+
return ts4.factory.createCallExpression(
|
|
666
|
+
ts4.factory.createToken(ts4.SyntaxKind.ImportKeyword),
|
|
599
667
|
void 0,
|
|
600
|
-
[
|
|
668
|
+
[ts4.factory.createStringLiteral(url)]
|
|
601
669
|
);
|
|
602
670
|
}
|
|
603
671
|
createFunctionDeclaration(functionName, parameters, body) {
|
|
604
|
-
if (!
|
|
605
|
-
throw new Error(`Invalid syntax, expected a block, but got ${
|
|
672
|
+
if (!ts4.isBlock(body)) {
|
|
673
|
+
throw new Error(`Invalid syntax, expected a block, but got ${ts4.SyntaxKind[body.kind]}.`);
|
|
606
674
|
}
|
|
607
|
-
return
|
|
675
|
+
return ts4.factory.createFunctionDeclaration(void 0, void 0, functionName, void 0, parameters.map((param) => ts4.factory.createParameterDeclaration(void 0, void 0, param)), void 0, body);
|
|
608
676
|
}
|
|
609
677
|
createFunctionExpression(functionName, parameters, body) {
|
|
610
|
-
if (!
|
|
611
|
-
throw new Error(`Invalid syntax, expected a block, but got ${
|
|
678
|
+
if (!ts4.isBlock(body)) {
|
|
679
|
+
throw new Error(`Invalid syntax, expected a block, but got ${ts4.SyntaxKind[body.kind]}.`);
|
|
612
680
|
}
|
|
613
|
-
return
|
|
681
|
+
return ts4.factory.createFunctionExpression(void 0, void 0, functionName != null ? functionName : void 0, void 0, parameters.map((param) => ts4.factory.createParameterDeclaration(void 0, void 0, param)), void 0, body);
|
|
614
682
|
}
|
|
615
683
|
createArrowFunctionExpression(parameters, body) {
|
|
616
|
-
if (
|
|
617
|
-
throw new Error(`Invalid syntax, expected a block, but got ${
|
|
684
|
+
if (ts4.isStatement(body) && !ts4.isBlock(body)) {
|
|
685
|
+
throw new Error(`Invalid syntax, expected a block, but got ${ts4.SyntaxKind[body.kind]}.`);
|
|
618
686
|
}
|
|
619
|
-
return
|
|
687
|
+
return ts4.factory.createArrowFunction(void 0, void 0, parameters.map((param) => ts4.factory.createParameterDeclaration(void 0, void 0, param)), void 0, void 0, body);
|
|
620
688
|
}
|
|
621
689
|
createIfStatement(condition, thenStatement, elseStatement) {
|
|
622
|
-
return
|
|
690
|
+
return ts4.factory.createIfStatement(condition, thenStatement, elseStatement != null ? elseStatement : void 0);
|
|
623
691
|
}
|
|
624
692
|
createLiteral(value) {
|
|
625
693
|
if (value === void 0) {
|
|
626
|
-
return
|
|
694
|
+
return ts4.factory.createIdentifier("undefined");
|
|
627
695
|
} else if (value === null) {
|
|
628
|
-
return
|
|
696
|
+
return ts4.factory.createNull();
|
|
629
697
|
} else if (typeof value === "boolean") {
|
|
630
|
-
return value ?
|
|
698
|
+
return value ? ts4.factory.createTrue() : ts4.factory.createFalse();
|
|
631
699
|
} else if (typeof value === "number") {
|
|
632
|
-
return
|
|
700
|
+
return ts4.factory.createNumericLiteral(value);
|
|
633
701
|
} else {
|
|
634
|
-
return
|
|
702
|
+
return ts4.factory.createStringLiteral(value);
|
|
635
703
|
}
|
|
636
704
|
}
|
|
637
705
|
createNewExpression(expression, args) {
|
|
638
|
-
return
|
|
706
|
+
return ts4.factory.createNewExpression(expression, void 0, args);
|
|
639
707
|
}
|
|
640
708
|
createObjectLiteral(properties) {
|
|
641
|
-
return
|
|
709
|
+
return ts4.factory.createObjectLiteralExpression(properties.map((prop) => ts4.factory.createPropertyAssignment(prop.quoted ? ts4.factory.createStringLiteral(prop.propertyName) : ts4.factory.createIdentifier(prop.propertyName), prop.value)));
|
|
642
710
|
}
|
|
643
711
|
createReturnStatement(expression) {
|
|
644
|
-
return
|
|
712
|
+
return ts4.factory.createReturnStatement(expression != null ? expression : void 0);
|
|
645
713
|
}
|
|
646
714
|
createTaggedTemplate(tag, template) {
|
|
647
715
|
let templateLiteral;
|
|
648
716
|
const length = template.elements.length;
|
|
649
717
|
const head = template.elements[0];
|
|
650
718
|
if (length === 1) {
|
|
651
|
-
templateLiteral =
|
|
719
|
+
templateLiteral = ts4.factory.createNoSubstitutionTemplateLiteral(head.cooked, head.raw);
|
|
652
720
|
} else {
|
|
653
721
|
const spans = [];
|
|
654
722
|
for (let i = 1; i < length - 1; i++) {
|
|
@@ -657,7 +725,7 @@ var TypeScriptAstFactory = class {
|
|
|
657
725
|
if (range !== null) {
|
|
658
726
|
this.setSourceMapRange(middle, range);
|
|
659
727
|
}
|
|
660
|
-
spans.push(
|
|
728
|
+
spans.push(ts4.factory.createTemplateSpan(template.expressions[i - 1], middle));
|
|
661
729
|
}
|
|
662
730
|
const resolvedExpression = template.expressions[length - 2];
|
|
663
731
|
const templatePart = template.elements[length - 1];
|
|
@@ -665,19 +733,19 @@ var TypeScriptAstFactory = class {
|
|
|
665
733
|
if (templatePart.range !== null) {
|
|
666
734
|
this.setSourceMapRange(templateTail, templatePart.range);
|
|
667
735
|
}
|
|
668
|
-
spans.push(
|
|
669
|
-
templateLiteral =
|
|
736
|
+
spans.push(ts4.factory.createTemplateSpan(resolvedExpression, templateTail));
|
|
737
|
+
templateLiteral = ts4.factory.createTemplateExpression(ts4.factory.createTemplateHead(head.cooked, head.raw), spans);
|
|
670
738
|
}
|
|
671
739
|
if (head.range !== null) {
|
|
672
740
|
this.setSourceMapRange(templateLiteral, head.range);
|
|
673
741
|
}
|
|
674
|
-
return
|
|
742
|
+
return ts4.factory.createTaggedTemplateExpression(tag, void 0, templateLiteral);
|
|
675
743
|
}
|
|
676
744
|
createUnaryExpression(operator, operand) {
|
|
677
|
-
return
|
|
745
|
+
return ts4.factory.createPrefixUnaryExpression(UNARY_OPERATORS2[operator], operand);
|
|
678
746
|
}
|
|
679
747
|
createVariableDeclaration(variableName, initializer, type) {
|
|
680
|
-
return
|
|
748
|
+
return ts4.factory.createVariableStatement(void 0, ts4.factory.createVariableDeclarationList([ts4.factory.createVariableDeclaration(variableName, void 0, void 0, initializer != null ? initializer : void 0)], VAR_TYPES[type]));
|
|
681
749
|
}
|
|
682
750
|
setSourceMapRange(node, sourceMapRange) {
|
|
683
751
|
if (sourceMapRange === null) {
|
|
@@ -685,37 +753,37 @@ var TypeScriptAstFactory = class {
|
|
|
685
753
|
}
|
|
686
754
|
const url = sourceMapRange.url;
|
|
687
755
|
if (!this.externalSourceFiles.has(url)) {
|
|
688
|
-
this.externalSourceFiles.set(url,
|
|
756
|
+
this.externalSourceFiles.set(url, ts4.createSourceMapSource(url, sourceMapRange.content, (pos) => pos));
|
|
689
757
|
}
|
|
690
758
|
const source = this.externalSourceFiles.get(url);
|
|
691
|
-
|
|
759
|
+
ts4.setSourceMapRange(node, { pos: sourceMapRange.start.offset, end: sourceMapRange.end.offset, source });
|
|
692
760
|
return node;
|
|
693
761
|
}
|
|
694
762
|
};
|
|
695
763
|
function createTemplateMiddle(cooked, raw) {
|
|
696
|
-
const node =
|
|
697
|
-
node.kind =
|
|
764
|
+
const node = ts4.factory.createTemplateHead(cooked, raw);
|
|
765
|
+
node.kind = ts4.SyntaxKind.TemplateMiddle;
|
|
698
766
|
return node;
|
|
699
767
|
}
|
|
700
768
|
function createTemplateTail(cooked, raw) {
|
|
701
|
-
const node =
|
|
702
|
-
node.kind =
|
|
769
|
+
const node = ts4.factory.createTemplateHead(cooked, raw);
|
|
770
|
+
node.kind = ts4.SyntaxKind.TemplateTail;
|
|
703
771
|
return node;
|
|
704
772
|
}
|
|
705
773
|
function attachComments(statement, leadingComments) {
|
|
706
774
|
for (const comment of leadingComments) {
|
|
707
|
-
const commentKind = comment.multiline ?
|
|
775
|
+
const commentKind = comment.multiline ? ts4.SyntaxKind.MultiLineCommentTrivia : ts4.SyntaxKind.SingleLineCommentTrivia;
|
|
708
776
|
if (comment.multiline) {
|
|
709
|
-
|
|
777
|
+
ts4.addSyntheticLeadingComment(statement, commentKind, comment.toString(), comment.trailingNewline);
|
|
710
778
|
} else {
|
|
711
779
|
for (const line of comment.toString().split("\n")) {
|
|
712
|
-
|
|
780
|
+
ts4.addSyntheticLeadingComment(statement, commentKind, line, comment.trailingNewline);
|
|
713
781
|
}
|
|
714
782
|
}
|
|
715
783
|
}
|
|
716
784
|
}
|
|
717
785
|
|
|
718
|
-
// bazel-out/
|
|
786
|
+
// bazel-out/k8-fastbuild/bin/packages/compiler-cli/src/ngtsc/translator/src/typescript_translator.mjs
|
|
719
787
|
function translateExpression(expression, imports, options = {}) {
|
|
720
788
|
return expression.visitExpression(new ExpressionTranslatorVisitor(new TypeScriptAstFactory(options.annotateForClosureCompiler === true), imports, options), new Context(false));
|
|
721
789
|
}
|
|
@@ -727,6 +795,8 @@ export {
|
|
|
727
795
|
Context,
|
|
728
796
|
ImportManager,
|
|
729
797
|
ExpressionTranslatorVisitor,
|
|
798
|
+
canEmitType,
|
|
799
|
+
TypeEmitter,
|
|
730
800
|
translateType,
|
|
731
801
|
translateExpression,
|
|
732
802
|
translateStatement
|
|
@@ -738,4 +808,4 @@ export {
|
|
|
738
808
|
* Use of this source code is governed by an MIT-style license that can be
|
|
739
809
|
* found in the LICENSE file at https://angular.io/license
|
|
740
810
|
*/
|
|
741
|
-
//# sourceMappingURL=chunk-
|
|
811
|
+
//# sourceMappingURL=chunk-ELZXPNCU.js.map
|