@@ -34,58 +34,6 @@ export async function checkIsolatedDeclarations(options?: DtsGenerationConfig):
34
34
}
35
35
}
36
36
37
- export function formatDeclarations ( declarations : string ) : string {
38
- const lines = declarations . split ( '\n' )
39
- const formattedLines = lines . map ( ( line ) => {
40
- // Trim trailing spaces
41
- line = line . trimEnd ( )
42
-
43
- // Handle interface and type declarations
44
- if ( line . startsWith ( 'export interface' ) || line . startsWith ( 'export type' ) ) {
45
- const parts = line . split ( '{' )
46
- if ( parts . length > 1 ) {
47
- return `${ parts [ 0 ] . trim ( ) } {${ parts [ 1 ] } `
48
- }
49
- }
50
-
51
- // Remove semicolons from the end of lines
52
- if ( line . endsWith ( ';' ) ) {
53
- line = line . slice ( 0 , - 1 )
54
- }
55
-
56
- return line
57
- } )
58
-
59
- // Join lines and ensure only one blank line between declarations
60
- let result = formattedLines . join ( '\n' )
61
- result = result . replace ( / \n { 3 , } / g, '\n\n' )
62
-
63
- // Format comments
64
- result = result . replace ( / \/ \* \* \n ( [ ^ * ] * ) ( \n \* \/ ) / g, ( match , content ) => {
65
- const formattedContent = content
66
- . split ( '\n' )
67
- . map ( ( line : string ) => ` *${ line . trim ( ) ? ` ${ line . trim ( ) } ` : '' } ` )
68
- . join ( '\n' )
69
- return `/**\n${ formattedContent } \n */`
70
- } )
71
-
72
- return `${ result . trim ( ) } \n`
73
- }
74
-
75
- export function formatComment ( comment : string ) : string {
76
- const lines = comment . split ( '\n' )
77
- return lines
78
- . map ( ( line , index ) => {
79
- if ( index === 0 )
80
- return '/**'
81
- if ( index === lines . length - 1 )
82
- return ' */'
83
- const trimmedLine = line . replace ( / ^ \s * \* ? \s ? / , '' ) . trim ( )
84
- return ` * ${ trimmedLine } `
85
- } )
86
- . join ( '\n' )
87
- }
88
-
89
37
export function deepMerge < T extends object > ( target : T , ...sources : Array < Partial < T > > ) : T {
90
38
if ( ! sources . length )
91
39
return target
0 commit comments