Skip to content

Commit

Permalink
chore: wip
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisbbreuer committed Oct 21, 2024
1 parent 10d9089 commit 594671c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
9 changes: 6 additions & 3 deletions fixtures/output/example-0001.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type { DtsGenerationOption, DtsGenerationConfig } from '@stacksjs/dtsx';
import type { BunPlugin } from 'bun';
import { generate } from '@stacksjs/dtsx';

/**
* Example of const declaration
Expand Down Expand Up @@ -58,7 +59,7 @@ export declare function getProduct(id: number): Promise<ApiResponse<Product>>;
export declare interface AuthResponse {
token: string;
expiresIn: number;
}
};

export declare type AuthStatus = 'authenticated' | 'unauthenticated';

Expand All @@ -78,9 +79,11 @@ interface Options<T> {

export declare function loadConfig<T extends Record<string, unknown>>(options: Options<T>): Promise<T>;

export declare const dtsConfig: DtsGenerationConfig;
declare const dtsConfig: DtsGenerationConfig;

export { generate, dtsConfig };

export { generate } from '@stacksjs/dtsx';
export type { DtsGenerationOption };

export { config } from './config';
export * from './extract';
Expand Down
3 changes: 2 additions & 1 deletion src/extract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,8 @@ function processFunctionDeclaration(declaration: string): string {
const asyncKeyword = functionSignature.includes('async') ? 'async ' : ''
const functionName = functionSignature.replace('export ', '').replace('async ', '').split('(')[0].trim()
const params = functionSignature.split('(')[1].split(')')[0].trim()
const result = `export declare ${asyncKeyword}function ${functionName}(${params}): ${getReturnType(declaration)};`
const returnType = getReturnType(declaration)
const result = `export declare ${asyncKeyword}function ${functionName}(${params}): ${returnType};`
logDebug(`Processed function declaration: ${result}`)
return result
}
Expand Down

0 comments on commit 594671c

Please sign in to comment.