| 666 | } |
| 667 | |
| 668 | function formatInterfaces(interfaces, allInterfaces) { |
| 669 | return allInterfaces.map(name => { |
| 670 | let interfaceO = interfaces[name]; |
| 671 | if (interfaceO && interfaceO !== 'UNTYPED') { |
| 672 | let output = `${name}`; |
| 673 | if (interfaceO.typeParameters) { |
| 674 | output += ` ${interfaceO.typeParameters}`; |
| 675 | delete interfaceO.typeParameters; |
| 676 | } |
| 677 | if (interfaceO.extend) { |
| 678 | output += ` ${interfaceO.extend}`; |
| 679 | delete interfaceO.extend; |
| 680 | } |
| 681 | // include extra newline so that the names of the interface are always compared |
| 682 | output += ' {\n\n'; |
| 683 | output += interfaces[name].isType |
| 684 | ? formatProp(name, interfaceO) |
| 685 | : Object.entries(interfaceO).map(formatProp).join('\n'); |
| 686 | return `${output}\n}\n`; |
| 687 | } else if (interfaceO === 'UNTYPED') { |
| 688 | // include extra newline so that the names of the interface are always compared |
| 689 | return `${name} {\n\n UNTYPED\n}\n`; |
| 690 | } else { |
| 691 | return '\n'; |
| 692 | } |
| 693 | }); |
| 694 | } |