Skip to content

Commit c2f18b0

Browse files
committed
chore: wip
1 parent 184099e commit c2f18b0

File tree

2 files changed

+4
-14
lines changed

2 files changed

+4
-14
lines changed

fixtures/output/example-0001.d.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import { generate } from '@stacksjs/dtsx';
55
/**
66
* Example of const declaration
77
*/
8-
98
export declare const conf: { [key: string]: string };
109
export declare const someObject: {
1110
someString: 'Stacks';
@@ -37,7 +36,6 @@ export declare const someObject: {
3736
* Example of interface declaration
3837
* with another comment in an extra line
3938
*/
40-
4139
export declare interface User {
4240
id: number
4341
name: string
@@ -48,7 +46,6 @@ export declare interface User {
4846
*
4947
* with multiple lines of comments, including an empty line
5048
*/
51-
5249
export declare interface ResponseData {
5350
success: boolean
5451
data: User[]
@@ -59,7 +56,6 @@ export declare interface ResponseData {
5956
*
6057
* with multiple empty lines, including an empty lines
6158
*/
62-
6359
export declare function fetchUsers(): Promise<ResponseData>;
6460
export declare interface ApiResponse<T> {
6561
status: number
@@ -71,7 +67,6 @@ export declare interface ApiResponse<T> {
7167
*
7268
* with multiple empty lines, including being poorly formatted
7369
*/
74-
7570
declare const settings: { [key: string]: any };
7671
export declare interface Product {
7772
id: number
@@ -81,7 +76,6 @@ export declare interface Product {
8176
/**
8277
* Example of function declaration
8378
*/
84-
8579
export declare function getProduct(id: number): Promise<ApiResponse<Product>>;
8680
export declare interface AuthResponse {
8781
token: string

src/extract.ts

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -617,9 +617,10 @@ export function processDeclarationBlock(
617617
const jsdocComments = comments.filter(isJSDocComment)
618618
console.log('Filtered JSDoc comments:', jsdocComments)
619619

620+
// Add JSDoc comments directly before the declaration
620621
if (jsdocComments.length > 0) {
621-
console.log('Adding JSDoc comments to dtsLines:', jsdocComments)
622-
state.dtsLines.push(...jsdocComments, '') // Add empty line after comments
622+
// Directly add the comments without the extra newline
623+
state.dtsLines.push(...jsdocComments.map(comment => comment.trimEnd()))
623624
}
624625

625626
// Remove any non-JSDoc comments that might have slipped through
@@ -638,12 +639,7 @@ export function processDeclarationBlock(
638639
// Remove leading comments and whitespace when checking its type
639640
const declarationWithoutComments = removeLeadingComments(declaration).trimStart()
640641

641-
console.log('Processing declaration:', {
642-
original: declaration,
643-
withoutComments: declarationWithoutComments,
644-
})
645-
646-
// Process the declaration
642+
// Process the declaration as before
647643
processSpecificDeclaration(declarationWithoutComments, declaration, state)
648644
}
649645

0 commit comments

Comments
 (0)