UNPKG

@stacksjs/dtsx

Version:

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

57 lines (56 loc) 2.05 kB
/** * Resolve a relative re-export specifier to an absolute path on disk. * * Mirrors TypeScript's classic resolver for relative paths only — bare * specifiers (e.g. `react`, `@scope/foo`) return `{ resolved: null }`. */ export declare function resolveRelativeSpecifier(specifier: string, fromFile: string): ResolveResult; /** * Quickly scan source for relative re-export references. * * By default only re-exports are returned, since plain `import`s do not * propagate types to consumers unless they are also re-exported. Pass * `includeImports: true` for the bundle pathway, where any reachable * file's declarations may need to be inlined. */ export declare function scanReExportSpecifiers(source: string, options?: { includeImports?: boolean }): ReExportRef[]; /** * BFS the re-export graph starting from `entrypoints`. * * Each entrypoint and every file reached via `export … from './x'` * (recursively, with cycle protection) ends up in `reachable`. Files * whose source can't be read are skipped silently — the caller is the * one with the right context to decide whether that's an error. */ export declare function collectReachableViaReExports(entrypoints: string[], options?: { includeImports?: boolean }): Promise<ReachabilityResult>; /** * A single relative re-export or import reference parsed out of source. */ export declare interface ReExportRef { specifier: string kind: 'export-star' | 'export-star-as' | 'export-named' | 'import' isTypeOnly: boolean } /** * Result of resolving a specifier to disk. */ export declare interface ResolveResult { resolved: string | null isRelative: boolean } /** * An unresolved relative re-export discovered during traversal. */ export declare interface UnresolvedReExport { from: string specifier: string isTypeOnly: boolean } /** * Result of walking the re-export graph from a set of entrypoints. */ export declare interface ReachabilityResult { reachable: Set<string> reExports: Map<string, ReExportRef[]> unresolved: UnresolvedReExport[] }