@stacksjs/dtsx
Version:
A modern, fast .d.ts generation tool, powered by Bun.
90 lines (89 loc) • 2.53 kB
TypeScript
import type { Declaration, TrackingConfig } from './types';
/**
* Create a new tracker instance
*/
export declare function createTracker(config?: TrackingConfig): Tracker;
/**
* Track declarations from a file
*/
export declare function trackDeclarations(declarations: Declaration[], file: string, tracker: Tracker): void;
/**
* Analyze imports for a set of files
*/
export declare function analyzeImports(fileDeclarations: Map<string, Declaration[]>, config?: TrackingConfig): TrackingResults;
/**
* Analyze types for a set of files
*/
export declare function analyzeTypes(fileDeclarations: Map<string, Declaration[]>, config?: TrackingConfig): TrackingResults;
/**
* Type information tracked during processing
*/
export declare interface TrackedType {
name: string
kind: 'interface' | 'type' | 'class' | 'enum'
file: string
line?: number
usedBy: Set<string>
references: Set<string>
extendsFrom?: string[]
implementsFrom?: string[]
}
/**
* Import information tracked during processing
*/
export declare interface TrackedImport {
source: string
specifiers: string[]
isTypeOnly: boolean
file: string
usedSpecifiers: Set<string>
unusedSpecifiers: Set<string>
}
/**
* Type relationship information
*/
export declare interface TypeRelationship {
from: string
to: string
kind: 'extends' | 'implements' | 'references' | 'uses'
file: string
}
/**
* Tracking results from analysis
*/
export declare interface TrackingResults {
types: Map<string, TrackedType>
imports: Map<string, TrackedImport[]>
relationships: TypeRelationship[]
unusedTypes: string[]
unusedImports: TrackedImport[]
circularReferences: string[][]
statistics: TrackingStatistics
}
/**
* Tracking statistics
*/
export declare interface TrackingStatistics {
totalTypes: number
usedTypes: number
unusedTypes: number
totalImports: number
usedImports: number
unusedImports: number
totalRelationships: number
circularDependencies: number
}
/**
* Tracker class for collecting type and import information
*/
export declare class Tracker {
constructor(config?: TrackingConfig);
trackType(decl: Declaration, file: string): void;
trackTypeUsage(typeName: string, usedBy: string, file: string): void;
trackImport(source: string, specifiers: string[], isTypeOnly: boolean, file: string): void;
trackImportUsage(specifier: string, file: string): void;
trackTypeReference(typeName: string, file: string): void;
getResults(): TrackingResults;
clear(): void;
formatResults(): string;
}