import type ts from "typescript"; import type { ApiExtractorConfig, ResolvedApiExtractorConfig } from "./config.js"; import type { ApiExtractorResult, ApiExtractorWatcher } from "./types.js"; /** * ApiExtractor's main JavaScript entrypoint. * * @example * ```js * * import { loadApiExtractorConfig, mergeApiExtractorConfigs } from "@arcgis/api-extractor/extractor/config"; * import { ApiExtractor } from "@arcgis/api-extractor/extractor/ApiExtractor"; * * const baseConfig = await loadApiExtractorConfig(process.cwd(), "api-extractor.config.ts"); * * // Optionally override parts of the config * const mergedConfig = mergeApiExtractorConfigs(baseConfig, { * types: { * fullTypeCheck: true, * }, * }); * * const extractor = new ApiExtractor(mergedConfig); * * const { apiJson, dtsFiles } = await extractor.run(); * // OR, start a watcher: * const watcher = await extractor.watch(); * ``` */ export class ApiExtractor { constructor(rawConfig?: ApiExtractorConfig); readonly config: ResolvedApiExtractorConfig; /** * Number of errors logged during the extraction process. * Errors will be logged using the `config.logger.error` callback if provided. * Otherwise, they will be logged using `console.error`. * * @default 0 */ errorCount: number; /** * If doing typed extraction or full type check, this will be the ts.Program. * If doing untyped watch, this will be a minimal Program-like object to reuse * SourceFiles for unchanged files. * Otherwise, undefined. */ program?: { getSourceFile: ts.Program["getSourceFile"]; getSourceFiles: ts.Program["getSourceFiles"]; getTypeChecker?: ts.Program["getTypeChecker"]; }; /** * @deprecated * @default 0 */ silencedBrokenLinkCount: number; /** The high-level API for running the extractor on the current project. */ run(): Promise; /** * The high-level API for starting a watch-mode extraction on the current project. * When watching, double check that the configuration options the ApiExtractor * was created with are appropriate for watch mode (disable full type check * and type verifier if not necessary). */ watch(): Promise; }