diff --git a/fixtures/output/example-0001.d.ts b/fixtures/output/example-0001.d.ts index 43484a0..25a1130 100644 --- a/fixtures/output/example-0001.d.ts +++ b/fixtures/output/example-0001.d.ts @@ -5,7 +5,6 @@ import { generate } from '@stacksjs/dtsx'; /** * Example of const declaration */ - export declare const conf: { [key: string]: string }; export declare const someObject: { someString: 'Stacks'; @@ -37,7 +36,6 @@ export declare const someObject: { * Example of interface declaration * with another comment in an extra line */ - export declare interface User { id: number name: string @@ -48,7 +46,6 @@ export declare interface User { * * with multiple lines of comments, including an empty line */ - export declare interface ResponseData { success: boolean data: User[] @@ -59,7 +56,6 @@ export declare interface ResponseData { * * with multiple empty lines, including an empty lines */ - export declare function fetchUsers(): Promise; export declare interface ApiResponse { status: number @@ -71,7 +67,6 @@ export declare interface ApiResponse { * * with multiple empty lines, including being poorly formatted */ - declare const settings: { [key: string]: any }; export declare interface Product { id: number @@ -81,7 +76,6 @@ export declare interface Product { /** * Example of function declaration */ - export declare function getProduct(id: number): Promise>; export declare interface AuthResponse { token: string diff --git a/src/extract.ts b/src/extract.ts index 2ca6233..70e0813 100644 --- a/src/extract.ts +++ b/src/extract.ts @@ -617,9 +617,10 @@ export function processDeclarationBlock( const jsdocComments = comments.filter(isJSDocComment) console.log('Filtered JSDoc comments:', jsdocComments) + // Add JSDoc comments directly before the declaration if (jsdocComments.length > 0) { - console.log('Adding JSDoc comments to dtsLines:', jsdocComments) - state.dtsLines.push(...jsdocComments, '') // Add empty line after comments + // Directly add the comments without the extra newline + state.dtsLines.push(...jsdocComments.map(comment => comment.trimEnd())) } // Remove any non-JSDoc comments that might have slipped through @@ -638,12 +639,7 @@ export function processDeclarationBlock( // Remove leading comments and whitespace when checking its type const declarationWithoutComments = removeLeadingComments(declaration).trimStart() - console.log('Processing declaration:', { - original: declaration, - withoutComments: declarationWithoutComments, - }) - - // Process the declaration + // Process the declaration as before processSpecificDeclaration(declarationWithoutComments, declaration, state) }