@stacksjs/dtsx
Version:
A modern, fast .d.ts generation tool, powered by Bun.
64 lines (63 loc) • 2.33 kB
TypeScript
import type { DtsGenerationConfig } from './types';
/**
* Build the source-map directive without embedding the complete marker in
* dtsx's own bundle, where Bun can mistake a string literal for a real map.
*/
export declare function sourceMapCommentPrefix(): string;
/**
* Exhaustive check helper for switch statements
* This function should never be called if all cases are handled
* TypeScript will error if a case is missing
*/
export declare function assertNever(value: never, message?: string): never;
export declare function writeToFile(filePath: string, content: string, lineEnding?: 'lf' | 'crlf' | 'auto'): Promise<void>;
export declare function getAllTypeScriptFiles(directory?: string): Promise<string[]>;
/** Resolve the effective isolatedDeclarations option across a tsconfig hierarchy. */
export declare function checkIsolatedDeclarationsConfig(options?: Pick<DtsGenerationConfig, 'cwd' | 'tsconfigPath'>): Promise<boolean>;
/**
* Validate declaration syntax with the dtsx scanner
*/
// eslint-disable-next-line pickier/no-unused-vars
export declare function validateDtsContent(content: string, filename: string): ValidationResult;
/**
* Simple line-by-line diff between two strings
* Returns formatted diff output with +/- prefixes
*/
export declare function createDiff(oldContent: string, newContent: string, filename: string): string;
/**
* Generate a simple source map for a declaration file
* This creates a basic 1:1 mapping since we're doing declaration extraction
*/
export declare function generateDeclarationMap(dtsContent: string, dtsFilename: string, sourceFilename: string, sourceContent: string): DeclarationSourceMap;
/**
* Add source map URL comment to declaration content
*/
export declare function addSourceMapComment(dtsContent: string, mapFilename: string): string;
/**
* Validation error details
*/
export declare interface ValidationError {
line: number
column: number
message: string
code?: string
suggestion?: string
}
/**
* Validation result for a .d.ts file
*/
export declare interface ValidationResult {
isValid: boolean
errors: ValidationError[]
}
/**
* Source map for declaration files
*/
export declare interface DeclarationSourceMap {
version: 3
file: string
sourceRoot: string
sources: string[]
sourcesContent: string[]
mappings: string
}