| 
1 | 1 | const DEBUG = true // Set to false to disable debug logs  | 
2 | 2 | 
 
  | 
3 |  | -function logDebug(...messages: any[]): void {  | 
 | 3 | +function logDebug(...messages: unknown[]): void {  | 
4 | 4 |   if (DEBUG) {  | 
5 | 5 |     console.log(...messages)  | 
6 | 6 |   }  | 
@@ -103,6 +103,9 @@ function processDeclaration(declaration: string): string {  | 
103 | 103 |   else if (declaration.startsWith('interface')) {  | 
104 | 104 |     return processInterfaceDeclaration(declaration)  | 
105 | 105 |   }  | 
 | 106 | +  else if (declaration.startsWith('export type {')) {  | 
 | 107 | +    return processTypeOnlyExport(declaration)  | 
 | 108 | +  }  | 
106 | 109 |   else if (declaration.startsWith('export type')) {  | 
107 | 110 |     return processTypeDeclaration(declaration)  | 
108 | 111 |   }  | 
@@ -176,12 +179,18 @@ function processInterfaceDeclaration(declaration: string): string {  | 
176 | 179 |   return result  | 
177 | 180 | }  | 
178 | 181 | 
 
  | 
 | 182 | +function processTypeOnlyExport(declaration: string): string {  | 
 | 183 | +  logDebug(`Processing type-only export: ${declaration}`)  | 
 | 184 | +  return declaration.replace('export type', 'export declare type')  | 
 | 185 | +}  | 
 | 186 | + | 
179 | 187 | function processTypeDeclaration(declaration: string): string {  | 
180 | 188 |   logDebug(`Processing type declaration: ${declaration}`)  | 
181 | 189 |   const lines = declaration.split('\n')  | 
182 |  | -  const typeName = lines[0].split('type')[1].split('=')[0].trim()  | 
183 |  | -  const typeBody = lines.slice(1).join('\n').trim().replace(/;$/, '')  | 
184 |  | -  const result = `export declare type ${typeName} = ${typeBody}`  | 
 | 190 | +  const firstLine = lines[0]  | 
 | 191 | +  const typeName = firstLine.split('type')[1].split('=')[0].trim()  | 
 | 192 | +  const typeBody = firstLine.split('=')[1]?.trim() || lines.slice(1).join('\n').trim().replace(/;$/, '')  | 
 | 193 | +  const result = `export declare type ${typeName} = ${typeBody};`  | 
185 | 194 |   logDebug(`Processed type declaration: ${result}`)  | 
186 | 195 |   return result  | 
187 | 196 | }  | 
 | 
0 commit comments