Skip to content

Commit

Permalink
chore: wip
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisbbreuer committed Oct 27, 2024
1 parent 184099e commit c2f18b0
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 14 deletions.
6 changes: 0 additions & 6 deletions fixtures/output/example-0001.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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
Expand All @@ -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[]
Expand All @@ -59,7 +56,6 @@ export declare interface ResponseData {
*
* with multiple empty lines, including an empty lines
*/

export declare function fetchUsers(): Promise<ResponseData>;
export declare interface ApiResponse<T> {
status: number
Expand All @@ -71,7 +67,6 @@ export declare interface ApiResponse<T> {
*
* with multiple empty lines, including being poorly formatted
*/

declare const settings: { [key: string]: any };
export declare interface Product {
id: number
Expand All @@ -81,7 +76,6 @@ export declare interface Product {
/**
* Example of function declaration
*/

export declare function getProduct(id: number): Promise<ApiResponse<Product>>;
export declare interface AuthResponse {
token: string
Expand Down
12 changes: 4 additions & 8 deletions src/extract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
}

Expand Down

0 comments on commit c2f18b0

Please sign in to comment.