UNPKG

@stacksjs/dtsx

Version:

A modern, fast .d.ts generation tool, powered by Bun.

57 lines (56 loc) 1.54 kB
import type { Declaration } from './types'; /** * Sort import declarations */ declare function sortImports(declarations: Declaration[]): Declaration[]; /** * Optimize declarations */ export declare function optimizeDeclarations(declarations: Declaration[], config?: OptimizerConfig): { declarations: Declaration[], result: OptimizationResult }; /** * Optimize a .d.ts file */ export declare function optimizeFile(filePath: string, config?: OptimizerConfig): Promise<OptimizationResult>; /** * Minify .d.ts content */ export declare function minifyDts(content: string): string; /** * Optimizer configuration */ export declare interface OptimizerConfig { removeUnusedImports?: boolean deduplicateDeclarations?: boolean inlineSimpleTypes?: boolean removeEmptyInterfaces?: boolean mergeInterfaces?: boolean sortDeclarations?: boolean sortImports?: boolean removeComments?: boolean minify?: boolean treeShake?: boolean entryPoints?: string[] } /** * Optimization result */ export declare interface OptimizationResult { originalSize: number optimizedSize: number savings: number savingsPercent: number removedImports: number removedDeclarations: number mergedInterfaces: number inlinedTypes: number } /** * Type usage tracker for tree shaking */ declare class _TypeUsageTracker { addDeclaration(decl: Declaration): void; addUsage(typeName: string): void; addReference(fromType: string, toType: string): void; getReachableTypes(): Set<string>; isUsed(typeName: string): boolean; }