@stacksjs/dtsx
Version:
A modern, fast .d.ts generation tool, powered by Bun.
124 lines (123 loc) • 3.63 kB
TypeScript
import type { DeclarationKind } from './types';
/**
* Normalize output content
*/
export declare function normalizeOutput(content: string, config?: OutputNormalizerConfig): string;
/**
* Normalize line endings
*/
export declare function normalizeLineEndings(content: string, style: LineEnding): string;
/**
* Detect current line ending style
*/
export declare function detectLineEnding(content: string): LineEnding;
/**
* Remove trailing whitespace from all lines
*/
export declare function removeTrailingWhitespace(content: string): string;
/**
* Normalize blank lines (limit consecutive blank lines)
*/
export declare function normalizeBlankLines(content: string, max: number): string;
/**
* Ensure content ends with exactly one newline
*/
export declare function ensureTrailingNewline(content: string): string;
/**
* Normalize indentation
*/
export declare function normalizeIndent(content: string, config: { style?: 'spaces' | 'tabs', size?: number }): string;
/**
* Process and organize imports
*/
export declare function processImports(content: string, config: ImportGrouping): string;
/**
* Order declarations by kind
*/
export declare function orderDeclarations(content: string, config: DeclarationOrder): string;
/**
* Preserve and format comments
*/
export declare function preserveCommentFormatting(content: string): string;
/**
* Create a configured normalizer
*/
export declare function createOutputNormalizer(config?: OutputNormalizerConfig): {
normalize: (content: string) => string
normalizeLineEndings: (content: string) => string
removeTrailingWhitespace: typeof removeTrailingWhitespace
normalizeBlankLines: (content: string) => string
ensureTrailingNewline: typeof ensureTrailingNewline
processImports: (content: string) => string
orderDeclarations: (content: string) => string
};
/**
* Default declaration order
*/
export declare const DEFAULT_DECLARATION_ORDER: DeclarationKind[];
/**
* Default import group order
*/
export declare const DEFAULT_IMPORT_GROUP_ORDER: ImportGroupType[];
/**
* Preset configurations
*/
export declare const normalizerPresets: {
/** Default preset - LF, trailing newline, basic cleanup */
default: unknown;
/** Minimal preset - just line endings and trailing newline */
minimal: unknown;
/** Strict preset - all normalization enabled */
strict: unknown;
/** Windows preset - CRLF line endings */
windows: unknown;
/** Tabs preset - use tabs for indentation */
tabs: unknown
};
/**
* Declaration ordering configuration
*/
export declare interface DeclarationOrder {
kinds?: DeclarationKind[]
alphabetize?: boolean
groupExports?: boolean
}
/**
* Import grouping configuration
*/
export declare interface ImportGrouping {
enabled?: boolean
groups?: ImportGroupType[]
separateGroups?: boolean
alphabetize?: boolean
}
/**
* Output normalizer configuration
*/
export declare interface OutputNormalizerConfig {
lineEnding?: LineEnding
trailingNewline?: boolean
maxBlankLines?: number
trimTrailingWhitespace?: boolean
normalizeIndentation?: boolean
indent?: {
style?: 'spaces' | 'tabs'
size?: number
}
declarationOrder?: DeclarationOrder
importGrouping?: ImportGrouping
preserveComments?: boolean
insertFinalNewline?: boolean
}
/**
* Line ending style
*/
export type LineEnding = 'lf' | 'crlf' | 'auto';
export type ImportGroupType = | 'builtin' // node:* modules
| 'external' // npm packages
| 'scoped' // @org/* packages
| 'internal' // @/* or ~/* aliases
| 'parent' // ../* imports
| 'sibling' // ./* imports
| 'index' // . or ./index
| 'type' // import type;