| 606 | } |
| 607 | |
| 608 | export function ObjectTypeAnnotation( |
| 609 | this: Printer, |
| 610 | node: t.ObjectTypeAnnotation, |
| 611 | ) { |
| 612 | if (node.exact) { |
| 613 | this.token("{|"); |
| 614 | } else { |
| 615 | this.token("{"); |
| 616 | } |
| 617 | |
| 618 | // TODO: remove the array fallbacks and instead enforce the types to require an array |
| 619 | const props = [ |
| 620 | ...node.properties, |
| 621 | ...(node.callProperties || []), |
| 622 | ...(node.indexers || []), |
| 623 | ...(node.internalSlots || []), |
| 624 | ]; |
| 625 | |
| 626 | if (props.length) { |
| 627 | this.newline(); |
| 628 | |
| 629 | this.space(); |
| 630 | |
| 631 | this.printJoin( |
| 632 | props, |
| 633 | true, |
| 634 | true, |
| 635 | () => { |
| 636 | if (props.length !== 1 || node.inexact) { |
| 637 | this.token(","); |
| 638 | this.space(); |
| 639 | } |
| 640 | }, |
| 641 | true, |
| 642 | ); |
| 643 | |
| 644 | this.space(); |
| 645 | } |
| 646 | |
| 647 | if (node.inexact) { |
| 648 | this.indent(); |
| 649 | this.token("..."); |
| 650 | if (props.length) { |
| 651 | this.newline(); |
| 652 | } |
| 653 | this.dedent(); |
| 654 | } |
| 655 | |
| 656 | if (node.exact) { |
| 657 | this.token("|}"); |
| 658 | } else { |
| 659 | this.token("}"); |
| 660 | } |
| 661 | } |
| 662 | |
| 663 | export function ObjectTypeInternalSlot( |
| 664 | this: Printer, |