MCPcopy Create free account
hub / github.com/babel/babel / ObjectTypeAnnotation

Function ObjectTypeAnnotation

packages/babel-generator/src/generators/flow.ts:608–661  ·  view source on GitHub ↗
(
  this: Printer,
  node: t.ObjectTypeAnnotation,
)

Source from the content-addressed store, hash-verified

606}
607
608export 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
663export function ObjectTypeInternalSlot(
664 this: Printer,

Callers

nothing calls this directly

Calls 6

tokenMethod · 0.45
newlineMethod · 0.45
spaceMethod · 0.45
printJoinMethod · 0.45
indentMethod · 0.45
dedentMethod · 0.45

Tested by

no test coverage detected