@stacksjs/dtsx
Version:
A modern, fast .d.ts generation tool, powered by Bun.
67 lines (66 loc) • 2.04 kB
TypeScript
/**
* Parse an import statement into its components using string operations
* Avoids regex backtracking issues
*/
export declare function parseImportStatement(importText: string): {
defaultName: string | null
namedItems: string[]
source: string
isTypeOnly: boolean
isNamespace: boolean
} | null;
/**
* Extract all imported items from an import statement (with caching)
* Uses simple string operations to avoid regex backtracking
*/
export declare function extractAllImportedItems(importText: string): string[];
/**
* Parse an import statement with detailed type-only information for each item
* Handles: import type { X }, import { type X, Y }, import * as X, etc.
*/
export declare function parseImportDetailed(importText: string): ParsedImport | null;
/**
* Parse an export statement with detailed type-only information
* Handles: export type { X }, export { type X, Y }, export * from, etc.
*/
export declare function parseExportDetailed(exportText: string): {
namedItems: ImportItem[]
source: string | null
isTypeOnly: boolean
isNamespace: boolean
isDefault: boolean
} | null;
/**
* Check if an import item is type-only
*/
export declare function isTypeOnlyImportItem(itemText: string): boolean;
/**
* Convert import items to type-only format
* E.g., "{ X, Y }" becomes "{ type X, type Y }"
*/
export declare function convertToTypeOnlyImport(importText: string): string;
/**
* Merge value and type imports from the same module
* Combines separate import statements into one where possible
*/
export declare function mergeImports(imports: string[]): string[];
/**
* Represents a single imported item with its type-only status
*/
export declare interface ImportItem {
name: string
originalName: string
isTypeOnly: boolean
isDefault: boolean
}
/**
* Detailed import statement parse result
*/
export declare interface ParsedImport {
defaultName: string | null
namedItems: ImportItem[]
source: string
isTypeOnly: boolean
isNamespace: boolean
namespaceName: string | null
}