Skip to content

Commit bd0940d

Browse files
committed
chore: wip
1 parent 14dada6 commit bd0940d

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/extract.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
/* eslint-disable no-console */
21
const DEBUG = true // Set to false to disable debug logs
32

43
export async function extract(filePath: string): Promise<string> {
@@ -79,10 +78,12 @@ function generateDtsTypes(sourceCode: string): string {
7978
}
8079
}
8180

82-
const result = cleanOutput([...imports, '', ...dtsLines, '', ...exports, defaultExport].filter(Boolean).join('\n'))
81+
const result = cleanOutput([...imports, '', ...dtsLines, '', ...exports].filter(Boolean).join('\n'))
82+
const finalResult = defaultExport ? `${result}\n${defaultExport}` : result
83+
8384
if (DEBUG)
84-
console.log('Final result:', result)
85-
return result
85+
console.log('Final result:', finalResult)
86+
return finalResult
8687
}
8788

8889
function processImport(importLine: string): string {
@@ -185,7 +186,7 @@ function processTypeDeclaration(declaration: string): string {
185186
console.log(`Processing type declaration: ${declaration}`)
186187
const lines = declaration.split('\n')
187188
const typeName = lines[0].split('type')[1].split('=')[0].trim()
188-
const typeBody = lines.slice(1).map(line => ` ${line.trim()}`).join('\n')
189+
const typeBody = lines.slice(1).join('\n').trim()
189190
const result = `export declare type ${typeName} = ${typeBody}`
190191
if (DEBUG)
191192
console.log(`Processed type declaration: ${result}`)

0 commit comments

Comments
 (0)