@typespec/compiler 0.54.0-dev.13 → 0.54.0-dev.15
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/dist/manifest.js +2 -2
- package/dist/src/core/checker.d.ts.map +1 -1
- package/dist/src/core/checker.js +5 -0
- package/dist/src/core/checker.js.map +1 -1
- package/dist/src/formatter/print/needs-parens.d.ts.map +1 -1
- package/dist/src/formatter/print/needs-parens.js +1 -2
- package/dist/src/formatter/print/needs-parens.js.map +1 -1
- package/dist/src/formatter/print/printer.d.ts.map +1 -1
- package/dist/src/formatter/print/printer.js +51 -51
- package/dist/src/formatter/print/printer.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"needs-parens.d.ts","sourceRoot":"","sources":["../../../../src/formatter/print/needs-parens.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AACxC,OAAO,EAAE,IAAI,EAAc,MAAM,qBAAqB,CAAC;AACvD,OAAO,EAAE,uBAAuB,EAAE,MAAM,YAAY,CAAC;AAErD;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,OAAO,CAAC,IAAI,CAAC,EAAE,OAAO,EAAE,uBAAuB,GAAG,OAAO,
|
|
1
|
+
{"version":3,"file":"needs-parens.d.ts","sourceRoot":"","sources":["../../../../src/formatter/print/needs-parens.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AACxC,OAAO,EAAE,IAAI,EAAc,MAAM,qBAAqB,CAAC;AACvD,OAAO,EAAE,uBAAuB,EAAE,MAAM,YAAY,CAAC;AAErD;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,OAAO,CAAC,IAAI,CAAC,EAAE,OAAO,EAAE,uBAAuB,GAAG,OAAO,CA8B1F"}
|
|
@@ -9,8 +9,7 @@ export function needsParens(path, options) {
|
|
|
9
9
|
if (!parent) {
|
|
10
10
|
return false;
|
|
11
11
|
}
|
|
12
|
-
|
|
13
|
-
const node = path.getValue();
|
|
12
|
+
const node = path.node;
|
|
14
13
|
switch (node.kind) {
|
|
15
14
|
case SyntaxKind.ValueOfExpression:
|
|
16
15
|
return (parent.kind === SyntaxKind.UnionExpression ||
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"needs-parens.js","sourceRoot":"","sources":["../../../../src/formatter/print/needs-parens.ts"],"names":[],"mappings":"AACA,OAAO,EAAQ,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAGvD;;;;GAIG;AACH,MAAM,UAAU,WAAW,CAAC,IAAmB,EAAE,OAAgC;IAC/E,MAAM,MAAM,GAAG,IAAI,CAAC,aAAa,EAAE,CAAC;IACpC,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,OAAO,KAAK,CAAC;IACf,CAAC;IAED,
|
|
1
|
+
{"version":3,"file":"needs-parens.js","sourceRoot":"","sources":["../../../../src/formatter/print/needs-parens.ts"],"names":[],"mappings":"AACA,OAAO,EAAQ,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAGvD;;;;GAIG;AACH,MAAM,UAAU,WAAW,CAAC,IAAmB,EAAE,OAAgC;IAC/E,MAAM,MAAM,GAAG,IAAI,CAAC,aAAa,EAAE,CAAC;IACpC,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,OAAO,KAAK,CAAC;IACf,CAAC;IAED,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC;IACvB,QAAQ,IAAI,CAAC,IAAI,EAAE,CAAC;QAClB,KAAK,UAAU,CAAC,iBAAiB;YAC/B,OAAO,CACL,MAAM,CAAC,IAAI,KAAK,UAAU,CAAC,eAAe;gBAC1C,MAAM,CAAC,IAAI,KAAK,UAAU,CAAC,eAAe;gBAC1C,MAAM,CAAC,IAAI,KAAK,UAAU,CAAC,sBAAsB,CAClD,CAAC;QACJ,KAAK,UAAU,CAAC,sBAAsB;YACpC,OAAO,CACL,MAAM,CAAC,IAAI,KAAK,UAAU,CAAC,eAAe,IAAI,MAAM,CAAC,IAAI,KAAK,UAAU,CAAC,eAAe,CACzF,CAAC;QACJ,KAAK,UAAU,CAAC,eAAe;YAC7B,OAAO,CACL,MAAM,CAAC,IAAI,KAAK,UAAU,CAAC,sBAAsB;gBACjD,MAAM,CAAC,IAAI,KAAK,UAAU,CAAC,eAAe,CAC3C,CAAC;QACJ,KAAK,UAAU,CAAC,2BAA2B;YACzC,OAAO,MAAM,CAAC,IAAI,KAAK,UAAU,CAAC,2BAA2B,CAAC;QAChE,KAAK,UAAU,CAAC,8BAA8B;YAC5C,OAAO,MAAM,CAAC,IAAI,KAAK,UAAU,CAAC,8BAA8B,CAAC;QACnE;YACE,OAAO,KAAK,CAAC;IACjB,CAAC;AACH,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"printer.d.ts","sourceRoot":"","sources":["../../../../src/formatter/print/printer.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"printer.d.ts","sourceRoot":"","sources":["../../../../src/formatter/print/printer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AACtD,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAIxC,OAAO,EACL,kBAAkB,EAClB,mBAAmB,EACnB,6BAA6B,EAG7B,OAAO,EACP,iCAAiC,EACjC,uBAAuB,EACvB,uBAAuB,EAEvB,cAAc,EAEd,iBAAiB,EACjB,gCAAgC,EAGhC,sBAAsB,EACtB,0BAA0B,EAE1B,oBAAoB,EACpB,mBAAmB,EACnB,iBAAiB,EAEjB,kBAAkB,EAClB,IAAI,EAGJ,iCAAiC,EACjC,+BAA+B,EAC/B,sBAAsB,EACtB,kCAAkC,EAClC,6BAA6B,EAC7B,4BAA4B,EAE5B,gCAAgC,EAGhC,8BAA8B,EAC9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AAO,CAAC,6BAA6B,CAAC,EAC5C,OAAO,EAAE,uBAAuB,EAChC,KAAK,EAAE,kBAAkB,kBAG1B;AAED,wBAAgB,6BAA6B,CAC3C,IAAI,EAAE,OAAO,CAAC,4BAA4B,CAAC,EAC3C,OAAO,EAAE,uBAAuB,EAChC,KAAK,EAAE,kBAAkB,kBAW1B;AAED,wBAAgB,+BAA+B,CAC7C,IAAI,EAAE,OAAO,CAAC,8BAA8B,CAAC,EAC7C,OAAO,EAAE,uBAAuB,EAChC,KAAK,EAAE,kBAAkB,kBAS1B;AAED,wBAAgB,yCAAyC,CACvD,IAAI,EAAE,OAAO,CAAC,wCAAwC,CAAC,EACvD,OAAO,EAAE,uBAAuB,EAChC,KAAK,EAAE,kBAAkB,gBAG1B;AAED,wBAAgB,qBAAqB,CACnC,IAAI,EAAE,OAAO,CAAC,oBAAoB,CAAC,EACnC,OAAO,EAAE,uBAAuB,EAChC,KAAK,EAAE,kBAAkB,kBAG1B;AAED,wBAAgB,6BAA6B,CAC3C,IAAI,EAAE,OAAO,CAAC,4BAA4B,CAAC,EAC3C,OAAO,EAAE,uBAAuB,EAChC,KAAK,EAAE,kBAAkB,iCAW1B"}
|
|
@@ -26,7 +26,7 @@ export const typespecPrinter = {
|
|
|
26
26
|
export function printTypeSpec(
|
|
27
27
|
// Path to the AST node to print
|
|
28
28
|
path, options, print) {
|
|
29
|
-
const node = path.
|
|
29
|
+
const node = path.node;
|
|
30
30
|
const docs = printDocComments(path, options, print);
|
|
31
31
|
const directives = shouldPrintDirective(node) ? printDirectives(path, options, print) : "";
|
|
32
32
|
const printedNode = printNode(path, options, print);
|
|
@@ -47,7 +47,7 @@ function shouldPrintDirective(node) {
|
|
|
47
47
|
export function printNode(
|
|
48
48
|
// Path to the AST node to print
|
|
49
49
|
path, options, print) {
|
|
50
|
-
const node = path.
|
|
50
|
+
const node = path.node;
|
|
51
51
|
switch (node.kind) {
|
|
52
52
|
// Root
|
|
53
53
|
case SyntaxKind.TypeSpecScript:
|
|
@@ -223,7 +223,7 @@ path, options, print) {
|
|
|
223
223
|
}
|
|
224
224
|
}
|
|
225
225
|
export function printTypeSpecScript(path, options, print) {
|
|
226
|
-
const node = path.
|
|
226
|
+
const node = path.node;
|
|
227
227
|
const nodeHasComments = hasComments(node, CommentCheckFlags.Dangling);
|
|
228
228
|
const body = [];
|
|
229
229
|
if (nodeHasComments) {
|
|
@@ -238,7 +238,7 @@ export function printAliasStatement(path, options, print) {
|
|
|
238
238
|
return ["alias ", id, template, " = ", path.call(print, "value"), ";"];
|
|
239
239
|
}
|
|
240
240
|
function printTemplateParameters(path, options, print, propertyName) {
|
|
241
|
-
const node = path.
|
|
241
|
+
const node = path.node;
|
|
242
242
|
const args = node[propertyName];
|
|
243
243
|
if (args.length === 0) {
|
|
244
244
|
return "";
|
|
@@ -266,7 +266,7 @@ export function canAttachComment(node) {
|
|
|
266
266
|
!(node.flags & 8 /* NodeFlags.Synthetic */));
|
|
267
267
|
}
|
|
268
268
|
export function printComment(commentPath, options) {
|
|
269
|
-
const comment = commentPath.
|
|
269
|
+
const comment = commentPath.node;
|
|
270
270
|
comment.printed = true;
|
|
271
271
|
switch (comment.kind) {
|
|
272
272
|
case SyntaxKind.BlockComment:
|
|
@@ -278,7 +278,7 @@ export function printComment(commentPath, options) {
|
|
|
278
278
|
}
|
|
279
279
|
}
|
|
280
280
|
function printBlockComment(commentPath, options) {
|
|
281
|
-
const comment = commentPath.
|
|
281
|
+
const comment = commentPath.node;
|
|
282
282
|
const rawComment = options.originalText.slice(comment.pos + 2, comment.end - 2);
|
|
283
283
|
const printed = isIndentableBlockComment(rawComment)
|
|
284
284
|
? printIndentableBlockCommentContent(rawComment)
|
|
@@ -303,7 +303,7 @@ function printIndentableBlockCommentContent(rawComment) {
|
|
|
303
303
|
}
|
|
304
304
|
/** Print a doc comment. */
|
|
305
305
|
function printDoc(path, options, print) {
|
|
306
|
-
const node = path.
|
|
306
|
+
const node = path.node;
|
|
307
307
|
const rawComment = options.originalText.slice(node.pos + 3, node.end - 2);
|
|
308
308
|
const printed = isIndentableBlockComment(rawComment)
|
|
309
309
|
? printIndentableBlockCommentContent(rawComment)
|
|
@@ -313,7 +313,7 @@ function printDoc(path, options, print) {
|
|
|
313
313
|
return ["/**", printed, "*/"];
|
|
314
314
|
}
|
|
315
315
|
export function printDecorators(path, options, print, { tryInline }) {
|
|
316
|
-
const node = path.
|
|
316
|
+
const node = path.node;
|
|
317
317
|
if (node.decorators.length === 0) {
|
|
318
318
|
return { decorators: "", multiline: false };
|
|
319
319
|
}
|
|
@@ -326,7 +326,7 @@ export function printDecorators(path, options, print, { tryInline }) {
|
|
|
326
326
|
}
|
|
327
327
|
/** Check if the decorators of the given node should be broken in sparate line */
|
|
328
328
|
function shouldDecoratorBreakLine(path, options, { tryInline }) {
|
|
329
|
-
const node = path.
|
|
329
|
+
const node = path.node;
|
|
330
330
|
return (!tryInline || node.decorators.length >= 3 || hasNewlineBetweenOrAfterDecorators(node, options));
|
|
331
331
|
}
|
|
332
332
|
/**
|
|
@@ -357,7 +357,7 @@ function printAugmentDecoratorArgs(path, options, print) {
|
|
|
357
357
|
];
|
|
358
358
|
}
|
|
359
359
|
export function printDocComments(path, options, print) {
|
|
360
|
-
const node = path.
|
|
360
|
+
const node = path.node;
|
|
361
361
|
if (node.docs === undefined || node.docs.length === 0) {
|
|
362
362
|
return "";
|
|
363
363
|
}
|
|
@@ -365,7 +365,7 @@ export function printDocComments(path, options, print) {
|
|
|
365
365
|
return group([...docs, breakParent]);
|
|
366
366
|
}
|
|
367
367
|
export function printDirectives(path, options, print) {
|
|
368
|
-
const node = path.
|
|
368
|
+
const node = path.node;
|
|
369
369
|
if (node.directives === undefined || node.directives.length === 0) {
|
|
370
370
|
return "";
|
|
371
371
|
}
|
|
@@ -377,7 +377,7 @@ export function printDirective(path, options, print) {
|
|
|
377
377
|
return ["#", path.call(print, "target"), " ", args];
|
|
378
378
|
}
|
|
379
379
|
function printDecoratorArgs(path, options, print) {
|
|
380
|
-
const node = path.
|
|
380
|
+
const node = path.node;
|
|
381
381
|
if (node.arguments.length === 0) {
|
|
382
382
|
return "";
|
|
383
383
|
}
|
|
@@ -405,7 +405,7 @@ function printDecoratorArgs(path, options, print) {
|
|
|
405
405
|
];
|
|
406
406
|
}
|
|
407
407
|
export function printDirectiveArgs(path, options, print) {
|
|
408
|
-
const node = path.
|
|
408
|
+
const node = path.node;
|
|
409
409
|
if (node.arguments.length === 0) {
|
|
410
410
|
return "";
|
|
411
411
|
}
|
|
@@ -417,7 +417,7 @@ export function printEnumStatement(path, options, print) {
|
|
|
417
417
|
return [decorators, "enum ", id, " ", printEnumBlock(path, options, print)];
|
|
418
418
|
}
|
|
419
419
|
function printEnumBlock(path, options, print) {
|
|
420
|
-
const node = path.
|
|
420
|
+
const node = path.node;
|
|
421
421
|
if (node.members.length === 0) {
|
|
422
422
|
return "{}";
|
|
423
423
|
}
|
|
@@ -425,7 +425,7 @@ function printEnumBlock(path, options, print) {
|
|
|
425
425
|
return group(["{", indent(body), hardline, "}"]);
|
|
426
426
|
}
|
|
427
427
|
export function printEnumMember(path, options, print) {
|
|
428
|
-
const node = path.
|
|
428
|
+
const node = path.node;
|
|
429
429
|
const id = path.call(print, "id");
|
|
430
430
|
const value = node.value ? [": ", path.call(print, "value")] : "";
|
|
431
431
|
const { decorators } = printDecorators(path, options, print, {
|
|
@@ -443,7 +443,7 @@ export function printUnionStatement(path, options, print) {
|
|
|
443
443
|
return [decorators, "union ", id, generic, " ", printUnionVariantsBlock(path, options, print)];
|
|
444
444
|
}
|
|
445
445
|
export function printUnionVariantsBlock(path, options, print) {
|
|
446
|
-
const node = path.
|
|
446
|
+
const node = path.node;
|
|
447
447
|
if (node.options.length === 0) {
|
|
448
448
|
return "{}";
|
|
449
449
|
}
|
|
@@ -473,7 +473,7 @@ export function printInterfaceStatement(path, options, print) {
|
|
|
473
473
|
];
|
|
474
474
|
}
|
|
475
475
|
function printInterfaceExtends(path, options, print) {
|
|
476
|
-
const node = path.
|
|
476
|
+
const node = path.node;
|
|
477
477
|
if (node.extends.length === 0) {
|
|
478
478
|
return "";
|
|
479
479
|
}
|
|
@@ -481,7 +481,7 @@ function printInterfaceExtends(path, options, print) {
|
|
|
481
481
|
return [group(indent([line, keyword, indent(join([",", line], path.map(print, "extends")))]))];
|
|
482
482
|
}
|
|
483
483
|
export function printInterfaceMembers(path, options, print) {
|
|
484
|
-
const node = path.
|
|
484
|
+
const node = path.node;
|
|
485
485
|
const hasOperations = node.operations.length > 0;
|
|
486
486
|
const nodeHasComments = hasComments(node, CommentCheckFlags.Dangling);
|
|
487
487
|
if (!hasOperations && !nodeHasComments) {
|
|
@@ -490,7 +490,7 @@ export function printInterfaceMembers(path, options, print) {
|
|
|
490
490
|
const lastOperation = node.operations[node.operations.length - 1];
|
|
491
491
|
const parts = [];
|
|
492
492
|
path.each((operationPath) => {
|
|
493
|
-
const node = operationPath.
|
|
493
|
+
const node = operationPath.node;
|
|
494
494
|
const printed = print(operationPath);
|
|
495
495
|
parts.push(printed);
|
|
496
496
|
if (node !== lastOperation) {
|
|
@@ -507,13 +507,13 @@ export function printInterfaceMembers(path, options, print) {
|
|
|
507
507
|
return group(["{", indent(body), hardline, "}"]);
|
|
508
508
|
}
|
|
509
509
|
function printDanglingComments(path, options, { sameIndent }) {
|
|
510
|
-
const node = path.
|
|
510
|
+
const node = path.node;
|
|
511
511
|
const parts = [];
|
|
512
512
|
if (!node || !node.comments) {
|
|
513
513
|
return "";
|
|
514
514
|
}
|
|
515
515
|
path.each((commentPath) => {
|
|
516
|
-
const comment = commentPath.
|
|
516
|
+
const comment = commentPath.node;
|
|
517
517
|
if (!comment.leading && !comment.trailing) {
|
|
518
518
|
parts.push(printComment(path, options));
|
|
519
519
|
}
|
|
@@ -536,7 +536,7 @@ function printDanglingComments(path, options, { sameIndent }) {
|
|
|
536
536
|
* @returns Prettier document.
|
|
537
537
|
*/
|
|
538
538
|
export function printIntersection(path, options, print) {
|
|
539
|
-
const node = path.
|
|
539
|
+
const node = path.node;
|
|
540
540
|
const types = path.map(print, "options");
|
|
541
541
|
const result = [];
|
|
542
542
|
let wasIndented = false;
|
|
@@ -577,12 +577,12 @@ export function printTuple(path, options, print) {
|
|
|
577
577
|
]);
|
|
578
578
|
}
|
|
579
579
|
export function printMemberExpression(path, options, print) {
|
|
580
|
-
const node = path.
|
|
580
|
+
const node = path.node;
|
|
581
581
|
return [node.base ? [path.call(print, "base"), node.selector] : "", path.call(print, "id")];
|
|
582
582
|
}
|
|
583
583
|
export function printModelExpression(path, options, print) {
|
|
584
584
|
const inBlock = isModelExpressionInBlock(path);
|
|
585
|
-
const node = path.
|
|
585
|
+
const node = path.node;
|
|
586
586
|
if (inBlock) {
|
|
587
587
|
return group(printModelPropertiesBlock(path, options, print));
|
|
588
588
|
}
|
|
@@ -594,7 +594,7 @@ export function printModelExpression(path, options, print) {
|
|
|
594
594
|
}
|
|
595
595
|
}
|
|
596
596
|
export function printModelStatement(path, options, print) {
|
|
597
|
-
const node = path.
|
|
597
|
+
const node = path.node;
|
|
598
598
|
const id = path.call(print, "id");
|
|
599
599
|
const heritage = node.extends
|
|
600
600
|
? [ifBreak(line, " "), "extends ", path.call(print, "extends")]
|
|
@@ -615,7 +615,7 @@ export function printModelStatement(path, options, print) {
|
|
|
615
615
|
}
|
|
616
616
|
function printModelPropertiesBlock(path, options, print) {
|
|
617
617
|
var _a;
|
|
618
|
-
const node = path.
|
|
618
|
+
const node = path.node;
|
|
619
619
|
const hasProperties = node.properties && node.properties.length > 0;
|
|
620
620
|
const nodeHasComments = hasComments(node, CommentCheckFlags.Dangling);
|
|
621
621
|
if (!hasProperties && !nodeHasComments) {
|
|
@@ -641,7 +641,7 @@ function printModelPropertiesBlock(path, options, print) {
|
|
|
641
641
|
*/
|
|
642
642
|
function joinMembersInBlock(path, member, options, print, separator, regularLine = hardline) {
|
|
643
643
|
const doc = [regularLine];
|
|
644
|
-
const propertyContainerNode = path.
|
|
644
|
+
const propertyContainerNode = path.node;
|
|
645
645
|
let newLineBeforeNextProp = false;
|
|
646
646
|
path.each((item, propertyIndex) => {
|
|
647
647
|
const isFirst = propertyIndex === 0;
|
|
@@ -673,7 +673,7 @@ function joinMembersInBlock(path, member, options, print, separator, regularLine
|
|
|
673
673
|
*/
|
|
674
674
|
function shouldWrapMemberInNewLines(path, options) {
|
|
675
675
|
var _a;
|
|
676
|
-
const node = path.
|
|
676
|
+
const node = path.node;
|
|
677
677
|
return ((node.kind !== SyntaxKind.ModelSpreadProperty &&
|
|
678
678
|
node.kind !== SyntaxKind.ProjectionModelSpreadProperty &&
|
|
679
679
|
node.kind !== SyntaxKind.EnumSpreadMember &&
|
|
@@ -689,7 +689,7 @@ function shouldWrapMemberInNewLines(path, options) {
|
|
|
689
689
|
*/
|
|
690
690
|
function isModelAValue(path) {
|
|
691
691
|
let count = 0;
|
|
692
|
-
let node = path.
|
|
692
|
+
let node = path.node;
|
|
693
693
|
do {
|
|
694
694
|
switch (node.kind) {
|
|
695
695
|
case SyntaxKind.ModelStatement:
|
|
@@ -703,7 +703,7 @@ function isModelAValue(path) {
|
|
|
703
703
|
return true;
|
|
704
704
|
}
|
|
705
705
|
export function printModelProperty(path, options, print) {
|
|
706
|
-
const node = path.
|
|
706
|
+
const node = path.node;
|
|
707
707
|
const { decorators } = printDecorators(path, options, print, {
|
|
708
708
|
tryInline: DecoratorsTryInline.modelProperty,
|
|
709
709
|
});
|
|
@@ -761,7 +761,7 @@ function isModelExpressionInBlock(path) {
|
|
|
761
761
|
}
|
|
762
762
|
}
|
|
763
763
|
export function printScalarStatement(path, options, print) {
|
|
764
|
-
const node = path.
|
|
764
|
+
const node = path.node;
|
|
765
765
|
const id = path.call(print, "id");
|
|
766
766
|
const template = printTemplateParameters(path, options, print, "templateParameters");
|
|
767
767
|
const heritage = node.extends
|
|
@@ -813,11 +813,11 @@ export function printOperationStatement(path, options, print) {
|
|
|
813
813
|
];
|
|
814
814
|
}
|
|
815
815
|
export function printStatementSequence(path, options, print, property) {
|
|
816
|
-
const node = path.
|
|
816
|
+
const node = path.node;
|
|
817
817
|
const parts = [];
|
|
818
818
|
const lastStatement = getLastStatement(node[property]);
|
|
819
819
|
path.each((statementPath) => {
|
|
820
|
-
const node = path.
|
|
820
|
+
const node = path.node;
|
|
821
821
|
if (node.kind === SyntaxKind.EmptyStatement) {
|
|
822
822
|
return;
|
|
823
823
|
}
|
|
@@ -842,7 +842,7 @@ function getLastStatement(statements) {
|
|
|
842
842
|
return undefined;
|
|
843
843
|
}
|
|
844
844
|
export function printUnion(path, options, print) {
|
|
845
|
-
const node = path.
|
|
845
|
+
const node = path.node;
|
|
846
846
|
const shouldHug = shouldHugType(node);
|
|
847
847
|
const types = path.map((typePath) => {
|
|
848
848
|
let printedType = print(typePath);
|
|
@@ -870,7 +870,7 @@ export function printTypeReference(path, options, print) {
|
|
|
870
870
|
return [type, template];
|
|
871
871
|
}
|
|
872
872
|
export function printTemplateArgument(path, _options, print) {
|
|
873
|
-
if (path.
|
|
873
|
+
if (path.node.name !== undefined) {
|
|
874
874
|
const name = path.call(print, "name");
|
|
875
875
|
const argument = path.call(print, "argument");
|
|
876
876
|
return group([name, " = ", argument]);
|
|
@@ -884,7 +884,7 @@ export function printValueOfExpression(path, options, print) {
|
|
|
884
884
|
return ["valueof ", type];
|
|
885
885
|
}
|
|
886
886
|
function printTemplateParameterDeclaration(path, options, print) {
|
|
887
|
-
const node = path.
|
|
887
|
+
const node = path.node;
|
|
888
888
|
return [
|
|
889
889
|
path.call(print, "id"),
|
|
890
890
|
node.constraint ? [" extends ", path.call(print, "constraint")] : "",
|
|
@@ -908,7 +908,7 @@ function printDecoratorDeclarationStatement(path, options, print) {
|
|
|
908
908
|
return [printModifiers(path, options, print), "dec ", id, "(", parameters, ")", ";"];
|
|
909
909
|
}
|
|
910
910
|
function printFunctionDeclarationStatement(path, options, print) {
|
|
911
|
-
const node = path.
|
|
911
|
+
const node = path.node;
|
|
912
912
|
const id = path.call(print, "id");
|
|
913
913
|
const parameters = [
|
|
914
914
|
group([
|
|
@@ -920,7 +920,7 @@ function printFunctionDeclarationStatement(path, options, print) {
|
|
|
920
920
|
return [printModifiers(path, options, print), "fn ", id, "(", parameters, ")", returnType, ";"];
|
|
921
921
|
}
|
|
922
922
|
function printFunctionParameterDeclaration(path, options, print) {
|
|
923
|
-
const node = path.
|
|
923
|
+
const node = path.node;
|
|
924
924
|
const id = path.call(print, "id");
|
|
925
925
|
const type = node.type ? [": ", path.call(print, "type")] : "";
|
|
926
926
|
return [
|
|
@@ -932,22 +932,22 @@ function printFunctionParameterDeclaration(path, options, print) {
|
|
|
932
932
|
];
|
|
933
933
|
}
|
|
934
934
|
export function printModifiers(path, options, print) {
|
|
935
|
-
const node = path.
|
|
935
|
+
const node = path.node;
|
|
936
936
|
if (node.modifiers.length === 0) {
|
|
937
937
|
return "";
|
|
938
938
|
}
|
|
939
939
|
return path.map((x) => [print(x), " "], "modifiers");
|
|
940
940
|
}
|
|
941
941
|
function printStringLiteral(path, options) {
|
|
942
|
-
const node = path.
|
|
942
|
+
const node = path.node;
|
|
943
943
|
return getRawText(node, options);
|
|
944
944
|
}
|
|
945
945
|
function printNumberLiteral(path, options) {
|
|
946
|
-
const node = path.
|
|
946
|
+
const node = path.node;
|
|
947
947
|
return getRawText(node, options);
|
|
948
948
|
}
|
|
949
949
|
function printBooleanLiteral(path, options) {
|
|
950
|
-
const node = path.
|
|
950
|
+
const node = path.node;
|
|
951
951
|
return node.value ? "true" : "false";
|
|
952
952
|
}
|
|
953
953
|
function printProjectionStatement(path, options, print) {
|
|
@@ -966,7 +966,7 @@ function printProjectionStatement(path, options, print) {
|
|
|
966
966
|
];
|
|
967
967
|
}
|
|
968
968
|
function printProjection(path, options, print) {
|
|
969
|
-
const node = path.
|
|
969
|
+
const node = path.node;
|
|
970
970
|
const params = printProjectionParameters(path, options, print);
|
|
971
971
|
const body = printProjectionExpressionStatements(path, options, print, "body");
|
|
972
972
|
return [
|
|
@@ -980,7 +980,7 @@ function printProjection(path, options, print) {
|
|
|
980
980
|
];
|
|
981
981
|
}
|
|
982
982
|
function printProjectionParameters(path, options, print) {
|
|
983
|
-
const node = path.
|
|
983
|
+
const node = path.node;
|
|
984
984
|
const params = node.parameters;
|
|
985
985
|
if (params.length === 0) {
|
|
986
986
|
return "";
|
|
@@ -996,9 +996,9 @@ function printProjectionParameters(path, options, print) {
|
|
|
996
996
|
}
|
|
997
997
|
function printProjectionExpressionStatements(path, options, print, key) {
|
|
998
998
|
const parts = [hardline];
|
|
999
|
-
const lastIndex = path.
|
|
999
|
+
const lastIndex = path.node[key].length - 1;
|
|
1000
1000
|
path.each((statementPath, index) => {
|
|
1001
|
-
const node = path.
|
|
1001
|
+
const node = path.node;
|
|
1002
1002
|
if (node.kind === SyntaxKind.EmptyStatement) {
|
|
1003
1003
|
return;
|
|
1004
1004
|
}
|
|
@@ -1021,14 +1021,14 @@ function printProjectionExpressionStatement(path, options, print) {
|
|
|
1021
1021
|
return path.call(print, "expr");
|
|
1022
1022
|
}
|
|
1023
1023
|
function printProjectionIfExpressionNode(path, options, print) {
|
|
1024
|
-
const node = path.
|
|
1024
|
+
const node = path.node;
|
|
1025
1025
|
const test = path.call(print, "test");
|
|
1026
1026
|
const consequent = path.call(print, "consequent");
|
|
1027
1027
|
const alternate = node.alternate ? [" else ", path.call(print, "alternate")] : "";
|
|
1028
1028
|
return ["if ", test, " ", consequent, alternate];
|
|
1029
1029
|
}
|
|
1030
1030
|
export function printProjectionBlockExpressionNode(path, options, print) {
|
|
1031
|
-
const node = path.
|
|
1031
|
+
const node = path.node;
|
|
1032
1032
|
if (node.statements.length === 0) {
|
|
1033
1033
|
return "{}";
|
|
1034
1034
|
}
|
|
@@ -1040,18 +1040,18 @@ export function printProjectionBlockExpressionNode(path, options, print) {
|
|
|
1040
1040
|
];
|
|
1041
1041
|
}
|
|
1042
1042
|
export function printProjectionMemberExpression(path, options, print) {
|
|
1043
|
-
const node = path.
|
|
1043
|
+
const node = path.node;
|
|
1044
1044
|
return [path.call(print, "base"), node.selector, path.call(print, "id")];
|
|
1045
1045
|
}
|
|
1046
1046
|
export function printProjectionLeftRightExpression(path, options, print) {
|
|
1047
|
-
const node = path.
|
|
1047
|
+
const node = path.node;
|
|
1048
1048
|
return [path.call(print, "left"), " ", node.op, " ", path.call(print, "right")];
|
|
1049
1049
|
}
|
|
1050
1050
|
export function printProjectionUnaryExpression(path, options, print) {
|
|
1051
1051
|
return ["!", path.call(print, "target")];
|
|
1052
1052
|
}
|
|
1053
1053
|
export function printProjectionCallExpression(path, options, print) {
|
|
1054
|
-
const node = path.
|
|
1054
|
+
const node = path.node;
|
|
1055
1055
|
const target = path.call(print, "target");
|
|
1056
1056
|
const params = printItemList(path, options, print, "arguments");
|
|
1057
1057
|
if (node.callKind === "method") {
|