(output: string[], compiled: string, seenBlocks: Map<string, string>)
| 154 | } |
| 155 | |
| 156 | function appendUniqueExportBlocks(output: string[], compiled: string, seenBlocks: Map<string, string>): void { |
| 157 | for (const block of splitExportBlocks(compiled)) { |
| 158 | const nameMatch = /^export\s+(?:interface|type)\s+(\w+)/m.exec(block); |
| 159 | if (!nameMatch) { |
| 160 | output.push(block); |
| 161 | continue; |
| 162 | } |
| 163 | |
| 164 | const name = nameMatch[1]; |
| 165 | const normalizedBlock = normalizeExportBlock(block); |
| 166 | const existing = seenBlocks.get(name); |
| 167 | if (existing) { |
| 168 | if (existing !== normalizedBlock) { |
| 169 | throw new Error(`Duplicate generated TypeScript declaration for "${name}" with different content.`); |
| 170 | } |
| 171 | continue; |
| 172 | } |
| 173 | |
| 174 | seenBlocks.set(name, normalizedBlock); |
| 175 | output.push(block); |
| 176 | } |
| 177 | } |
| 178 | |
| 179 | function splitExportBlocks(compiled: string): string[] { |
| 180 | const normalizedCompiled = compiled |
nothing calls this directly
no test coverage detected
searching dependent graphs…