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