@@ -198,37 +198,37 @@ function extractFunctionDeclaration(node: ts.FunctionDeclaration, sourceCode: st
198
198
* Build clean function signature for DTS output
199
199
*/
200
200
function buildFunctionSignature ( node : ts . FunctionDeclaration ) : string {
201
- const parts : string [ ] = [ ]
201
+ let result = ''
202
202
203
203
// Add modifiers
204
- if ( hasExportModifier ( node ) ) parts . push ( 'export' )
205
- parts . push ( 'declare' )
206
- if ( node . asteriskToken ) parts . push ( 'function*' )
207
- else parts . push ( 'function' )
204
+ if ( hasExportModifier ( node ) ) result += 'export '
205
+ result += 'declare '
206
+ if ( node . asteriskToken ) result += 'function* '
207
+ else result += 'function '
208
208
209
- // Add name
210
- if ( node . name ) parts . push ( node . name . getText ( ) )
209
+ // Add name (no space before)
210
+ if ( node . name ) result += node . name . getText ( )
211
211
212
- // Add generics
212
+ // Add generics (no space before)
213
213
if ( node . typeParameters ) {
214
214
const generics = node . typeParameters . map ( tp => tp . getText ( ) ) . join ( ', ' )
215
- parts . push ( `<${ generics } >` )
215
+ result += `<${ generics } >`
216
216
}
217
217
218
- // Add parameters
218
+ // Add parameters (no space before)
219
219
const params = node . parameters . map ( param => {
220
220
const name = param . name . getText ( )
221
221
const type = param . type ?. getText ( ) || 'any'
222
222
const optional = param . questionToken ? '?' : ''
223
223
return `${ name } ${ optional } : ${ type } `
224
224
} ) . join ( ', ' )
225
- parts . push ( `(${ params } )` )
225
+ result += `(${ params } )`
226
226
227
- // Add return type
227
+ // Add return type (no space before colon)
228
228
const returnType = node . type ?. getText ( ) || 'void'
229
- parts . push ( `: ${ returnType } ` )
229
+ result += `: ${ returnType } `
230
230
231
- return parts . join ( ' ' ) + ';'
231
+ return result + ';'
232
232
}
233
233
234
234
/**
@@ -271,18 +271,18 @@ function extractVariableStatement(node: ts.VariableStatement, sourceCode: string
271
271
* Build clean variable declaration for DTS
272
272
*/
273
273
function buildVariableDeclaration ( name : string , type : string | undefined , kind : string , isExported : boolean ) : string {
274
- const parts : string [ ] = [ ]
274
+ let result = ''
275
275
276
- if ( isExported ) parts . push ( 'export' )
277
- parts . push ( 'declare' )
278
- parts . push ( kind )
279
- parts . push ( name )
276
+ if ( isExported ) result += 'export '
277
+ result += 'declare '
278
+ result += kind + ' '
279
+ result += name
280
280
281
281
if ( type ) {
282
- parts . push ( `: ${ type } ` )
282
+ result += `: ${ type } `
283
283
}
284
284
285
- return parts . join ( ' ' ) + ';'
285
+ return result + ';'
286
286
}
287
287
288
288
/**
@@ -319,17 +319,17 @@ function extractInterfaceDeclaration(node: ts.InterfaceDeclaration, sourceCode:
319
319
* Build clean interface declaration for DTS
320
320
*/
321
321
function buildInterfaceDeclaration ( node : ts . InterfaceDeclaration , isExported : boolean ) : string {
322
- const parts : string [ ] = [ ]
322
+ let result = ''
323
323
324
- if ( isExported ) parts . push ( 'export' )
325
- parts . push ( 'declare' )
326
- parts . push ( 'interface' )
327
- parts . push ( node . name . getText ( ) )
324
+ if ( isExported ) result += 'export '
325
+ result += 'declare '
326
+ result += 'interface '
327
+ result += node . name . getText ( )
328
328
329
- // Add generics
329
+ // Add generics (no space before)
330
330
if ( node . typeParameters ) {
331
331
const generics = node . typeParameters . map ( tp => tp . getText ( ) ) . join ( ', ' )
332
- parts . push ( `<${ generics } >` )
332
+ result += `<${ generics } >`
333
333
}
334
334
335
335
// Add extends
@@ -339,15 +339,15 @@ function buildInterfaceDeclaration(node: ts.InterfaceDeclaration, isExported: bo
339
339
)
340
340
if ( extendsClause ) {
341
341
const types = extendsClause . types . map ( type => type . getText ( ) ) . join ( ', ' )
342
- parts . push ( ` extends ${ types } `)
342
+ result += ` extends ${ types } `
343
343
}
344
344
}
345
345
346
346
// Add body (simplified)
347
347
const body = getInterfaceBody ( node )
348
- parts . push ( body )
348
+ result += ' ' + body
349
349
350
- return parts . join ( ' ' )
350
+ return result
351
351
}
352
352
353
353
/**
@@ -406,22 +406,22 @@ function extractTypeAliasDeclaration(node: ts.TypeAliasDeclaration, sourceCode:
406
406
* Build clean type declaration for DTS
407
407
*/
408
408
function buildTypeDeclaration ( node : ts . TypeAliasDeclaration , isExported : boolean ) : string {
409
- const parts : string [ ] = [ ]
409
+ let result = ''
410
410
411
- if ( isExported ) parts . push ( 'export' )
412
- parts . push ( 'type' )
413
- parts . push ( node . name . getText ( ) )
411
+ if ( isExported ) result += 'export '
412
+ result += 'type '
413
+ result += node . name . getText ( )
414
414
415
- // Add generics
415
+ // Add generics (no space before)
416
416
if ( node . typeParameters ) {
417
417
const generics = node . typeParameters . map ( tp => tp . getText ( ) ) . join ( ', ' )
418
- parts . push ( `<${ generics } >` )
418
+ result += `<${ generics } >`
419
419
}
420
420
421
- parts . push ( '=' )
422
- parts . push ( node . type . getText ( ) )
421
+ result += ' = '
422
+ result += node . type . getText ( )
423
423
424
- return parts . join ( ' ' )
424
+ return result
425
425
}
426
426
427
427
/**
0 commit comments