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

Function ObjectTypeAnnotation

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

Source from the content-addressed store, hash-verified

602}
603
604export 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
659export function ObjectTypeInternalSlot(
660 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