Skip to content

Commit

Permalink
chore: wip
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisbbreuer committed Oct 21, 2024
1 parent 6cdeeab commit c44e042
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/extract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export function generateDtsTypes(sourceCode: string): string {
continue
}

if (line.trim().startsWith('export') && !line.includes('{')) {
if (line.trim().startsWith('export') && (line.includes('{') || line.includes('*'))) {
exports.push(line)
continue
}
Expand Down Expand Up @@ -215,7 +215,7 @@ function preserveValueType(value: string): string {
return value // Keep string literals as is
}
else {
return 'any' // Default to any for other cases
return 'string' // Default to string for other cases
}
}

Expand All @@ -224,5 +224,7 @@ function cleanOutput(output: string): string {
.replace(/\{\s*\}/g, '{}') // Replace empty objects with {}
.replace(/\s*;\s*(?=\}|$)/g, ';') // Clean up semicolons before closing braces or end of string
.replace(/\n+/g, '\n') // Remove multiple consecutive newlines
.replace(/;\n\}/g, ';\n }') // Add indentation to closing brace of object literals
.replace(/\{;/g, '{') // Remove unnecessary semicolons after opening braces
.trim()
}

0 comments on commit c44e042

Please sign in to comment.