Skip to content

Commit

Permalink
chore: wip
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisbbreuer committed Oct 26, 2024
1 parent 9cd4e4e commit 64e8811
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 2 additions & 0 deletions fixtures/output/example-0001.d.ts
Original file line number Diff line number Diff line change
@@ -85,7 +85,9 @@ export declare function loadConfig<T extends Record<string, unknown>>({ name, cw
declare const dtsConfig: DtsGenerationConfig;

export { generate, dtsConfig }

export type { DtsGenerationOption }

export declare interface ComplexGeneric<T extends Record<string, unknown>, K extends keyof T> {
data: T
key: K
7 changes: 5 additions & 2 deletions src/extract.ts
Original file line number Diff line number Diff line change
@@ -2133,7 +2133,8 @@ function formatOutput(state: ProcessingState): string {
// Process imports
const imports = state.imports.join('\n').trim()
if (imports) {
sections.push(`${imports}\n`) // Add extra newline after imports
sections.push(imports)
sections.push('') // Add empty line after imports
}

// Process declarations with proper spacing
@@ -2145,10 +2146,12 @@ function formatOutput(state: ProcessingState): string {
.reduce((acc: string[], line: string) => {
if (line.trim()) {
acc.push(line)
// Add newline after declaration statements
// Add newline after declaration statements and direct exports
if (
line.match(/^export\s+declare\s+(const|interface|function|type|class|enum|namespace|module|global|abstract\s+class)/)
|| line.match(/^declare\s+(const|interface|function|type|class|enum|namespace|module|global|abstract\s+class)/)
|| line.match(/^export\s+\{/) // Match direct exports like "export { generate, dtsConfig }"
|| line.match(/^export\s+type\s+\{/) // Match type exports like "export type { DtsGenerationOption }"
) {
acc.push('')
}

0 comments on commit 64e8811

Please # to comment.