@@ -86,7 +86,7 @@ export async function extractTypeFromSource(filePath: string): Promise<string> {
86
86
declarations += `${ pendingComment } \n`
87
87
pendingComment = ''
88
88
}
89
- declarations += `export declare const ${ constName } : {\n${ formattedValue } \n}\n\n `
89
+ declarations += `export declare const ${ constName } : {\n${ formattedValue } \n}\n`
90
90
}
91
91
else {
92
92
// Handle constants initialized with function calls
@@ -97,15 +97,15 @@ export async function extractTypeFromSource(filePath: string): Promise<string> {
97
97
declarations += `${ pendingComment } \n`
98
98
pendingComment = ''
99
99
}
100
- declarations += `export declare const ${ constName } : ${ constType . trim ( ) } \n\n `
100
+ declarations += `export declare const ${ constName } : ${ constType . trim ( ) } \n`
101
101
}
102
102
else {
103
103
// Fallback to the original declaration if parsing fails
104
104
if ( pendingComment ) {
105
105
declarations += `${ pendingComment } \n`
106
106
pendingComment = ''
107
107
}
108
- declarations += `export declare ${ declaration . replace ( / e x p o r t \s + / , '' ) . trim ( ) } \n\n `
108
+ declarations += `export declare ${ declaration . replace ( / e x p o r t \s + / , '' ) . trim ( ) } \n`
109
109
}
110
110
}
111
111
}
@@ -114,7 +114,7 @@ export async function extractTypeFromSource(filePath: string): Promise<string> {
114
114
declarations += `${ pendingComment } \n`
115
115
pendingComment = ''
116
116
}
117
- declarations += `${ declaration . trim ( ) } \n\n `
117
+ declarations += `${ declaration . trim ( ) } \n`
118
118
}
119
119
else if ( declType === 'function' || declType === 'async function' ) {
120
120
if ( pendingComment ) {
@@ -126,7 +126,7 @@ export async function extractTypeFromSource(filePath: string): Promise<string> {
126
126
127
127
if ( funcSignatureMatch ) {
128
128
const [ , isAsync , funcName , params , returnType ] = funcSignatureMatch
129
- declarations += `export declare ${ isAsync || '' } function ${ funcName } (${ params . trim ( ) } ): ${ returnType . trim ( ) } \n\n `
129
+ declarations += `export declare ${ isAsync || '' } function ${ funcName } (${ params . trim ( ) } ): ${ returnType . trim ( ) } \n`
130
130
}
131
131
else {
132
132
// If we can't match the full signature, let's try to extract what we can
@@ -140,12 +140,12 @@ export async function extractTypeFromSource(filePath: string): Promise<string> {
140
140
const returnTypeMatch = declaration . match ( returnTypeRegex )
141
141
const returnType = returnTypeMatch ? returnTypeMatch [ 1 ] . trim ( ) : 'any'
142
142
143
- declarations += `export declare ${ isAsync || '' } function ${ funcName } (${ params . trim ( ) } ): ${ returnType } \n\n `
143
+ declarations += `export declare ${ isAsync || '' } function ${ funcName } (${ params . trim ( ) } ): ${ returnType } \n`
144
144
}
145
145
else {
146
146
// If all else fails, just add 'declare' to the original export
147
147
const simplifiedDeclaration = declaration . replace ( / e x p o r t \s + / , '' ) . split ( '{' ) [ 0 ] . trim ( )
148
- declarations += `export declare ${ simplifiedDeclaration } \n\n `
148
+ declarations += `export declare ${ simplifiedDeclaration } \n`
149
149
}
150
150
}
151
151
}
@@ -172,14 +172,14 @@ export async function extractTypeFromSource(filePath: string): Promise<string> {
172
172
const typeExportMatches = Array . from ( fileContent . matchAll ( typeExportRegex ) )
173
173
for ( const [ , typeList ] of typeExportMatches ) {
174
174
const types = typeList . split ( ',' ) . map ( t => t . trim ( ) )
175
- exports += `\n\ nexport type { ${ types . join ( ', ' ) } }`
175
+ exports += `\nexport type { ${ types . join ( ', ' ) } }`
176
176
}
177
177
178
178
// Handle default export
179
179
const defaultExportRegex = / e x p o r t \s + d e f a u l t \s + ( \w + ) /
180
180
const defaultExportMatch = fileContent . match ( defaultExportRegex )
181
181
if ( defaultExportMatch ) {
182
- exports += `\n\ nexport default ${ defaultExportMatch [ 1 ] } `
182
+ exports += `\nexport default ${ defaultExportMatch [ 1 ] } `
183
183
}
184
184
185
185
const output = [ imports , declarations . trim ( ) , exports . trim ( ) ] . filter ( Boolean ) . join ( '\n' ) . trim ( )
0 commit comments