(childStringProp: "expression" | "description")
| 127 | |
| 128 | const createStructuralWriter = |
| 129 | (childStringProp: "expression" | "description") => (node: StructureNode) => { |
| 130 | if (node.props.length || node.index) { |
| 131 | const parts = node.index?.map(index => index[childStringProp]) ?? [] |
| 132 | for (const prop of node.props) parts.push(prop[childStringProp]) |
| 133 | |
| 134 | if (node.undeclared) parts.push(`+ (undeclared): ${node.undeclared}`) |
| 135 | |
| 136 | const objectLiteralDescription = `{ ${parts.join(", ")} }` |
| 137 | return node.sequence ? |
| 138 | `${objectLiteralDescription} & ${node.sequence.description}` |
| 139 | : objectLiteralDescription |
| 140 | } |
| 141 | return node.sequence?.description ?? "{}" |
| 142 | } |
| 143 | |
| 144 | const structuralDescription = createStructuralWriter("description") |
| 145 | const structuralExpression = createStructuralWriter("expression") |
no test coverage detected