import { type ITerminal } from '@rushstack/terminal'; import { type IDeclarationMapping } from './DeclarationMap'; /** * Typings content produced by a parser, along with the information needed to emit a declaration * source map for it. * * @public */ export interface IGeneratedTypings { /** * The generated typings content, excluding the generated file header. */ typingsData: string; /** * Positions associating declarations in {@link IGeneratedTypings.typingsData} with the source * file that produced them. When omitted or empty, no declaration map is emitted. */ declarationMappings?: readonly IDeclarationMapping[]; } /** * @public */ export interface ITypingsGeneratorBaseOptions { srcFolder: string; generatedTsFolder: string; secondaryGeneratedTsFolders?: string[]; globsToIgnore?: string[]; terminal?: ITerminal; /** * If true, a `.d.ts.map` file is emitted next to each generated `.d.ts` file whose parser * provided declaration positions. This allows editors to resolve "go to definition" to the * original source file instead of the generated typings. * * @defaultValue false */ generateDeclarationMaps?: boolean; } /** * @public */ export interface ITypingsGeneratorOptionsWithoutReadFile extends ITypingsGeneratorBaseOptions { fileExtensions: string[]; parseAndGenerateTypings: (fileContents: TFileContents, filePath: string, relativePath: string) => TTypingsResult | Promise; getAdditionalOutputFiles?: (relativePath: string) => string[]; } /** * @public */ export type ReadFile = (filePath: string, relativePath: string) => Promise | TFileContents; /** * @public */ export interface ITypingsGeneratorOptions extends ITypingsGeneratorOptionsWithoutReadFile { readFile?: ReadFile; } /** * Options for a TypingsGenerator that needs to customize how files are read. * * @public */ export interface ITypingsGeneratorOptionsWithCustomReadFile extends ITypingsGeneratorOptionsWithoutReadFile { readFile: ReadFile; } /** * This is a simple tool that generates .d.ts files for non-TS files. * * @public */ export declare class TypingsGenerator { private readonly _dependenciesOfFile; private readonly _consumersOfFile; private readonly _relativePaths; protected readonly _options: ITypingsGeneratorOptionsWithCustomReadFile; protected readonly terminal: ITerminal; /** * The folder path that contains all input source files. */ readonly sourceFolderPath: string; /** * The glob pattern used to find input files to process. */ readonly inputFileGlob: string; /** * The glob patterns that should be ignored when finding input files to process. */ readonly ignoredFileGlobs: readonly string[]; constructor(options: TFileContents extends string ? ITypingsGeneratorOptions : never); constructor(options: ITypingsGeneratorOptionsWithCustomReadFile); /** * Generate typings for the provided input files. * * @param relativeFilePaths - The input files to process, relative to the source folder. If not provided, * all input files will be processed. */ generateTypingsAsync(relativeFilePaths?: string[]): Promise; runWatcherAsync(): Promise; /** * Register file dependencies that may effect the typings of a consumer file. * Note: This feature is only useful in watch mode. * The registerDependency method must be called in the body of parseAndGenerateTypings every * time because the registry for a file is cleared at the beginning of processing. */ registerDependency(consumer: string, rawDependency: string): void; getOutputFilePaths(relativePath: string): string[]; private _getOutputFilePathsWithoutCheck; private _reprocessFilesAsync; private _parseFileAndGenerateTypingsAsync; /** * Removes the consumer from all extant dependencies */ private _clearDependencies; private _getTypingsFilePaths; private _normalizeFileExtensions; } //# sourceMappingURL=TypingsGenerator.d.ts.map