@microsoft/api-extractor
Version:
Validate, document, and review the exported API for a TypeScript library
71 lines (70 loc) • 2.62 kB
TypeScript
import * as ts from 'typescript';
import { PackageJsonLookup } from '@microsoft/node-core-library';
import AstPackage from './ast/AstPackage';
import DocItemLoader from './DocItemLoader';
import { ILogger } from './extractor/ILogger';
import { IExtractorPoliciesConfig } from './extractor/IExtractorConfig';
/**
* Options for ExtractorContext constructor.
*/
export interface IExtractorContextOptions {
/**
* Configuration for the TypeScript compiler. The most important options to set are:
*
* - target: ts.ScriptTarget.ES5
* - module: ts.ModuleKind.CommonJS
* - moduleResolution: ts.ModuleResolutionKind.NodeJs
* - rootDir: inputFolder
*/
program: ts.Program;
/**
* The entry point for the project. This should correspond to the "main" field
* from NPM's package.json file. If it is a relative path, it will be relative to
* the project folder described by IExtractorAnalyzeOptions.compilerOptions.
*/
entryPointFile: string;
logger: ILogger;
policies: IExtractorPoliciesConfig;
}
/**
* The main entry point for the "api-extractor" utility. The Analyzer object invokes the
* TypeScript Compiler API to analyze a project, and constructs the AstItem
* abstract syntax tree.
*/
export declare class ExtractorContext {
typeChecker: ts.TypeChecker;
package: AstPackage;
/**
* One DocItemLoader is needed per analyzer to look up external API members
* as needed.
*/
readonly docItemLoader: DocItemLoader;
readonly packageJsonLookup: PackageJsonLookup;
readonly policies: IExtractorPoliciesConfig;
private _packageName;
private _packageFolder;
private _logger;
constructor(options: IExtractorContextOptions);
/**
* Returns the full name of the package being analyzed.
*/
readonly packageName: string;
/**
* Returns the folder for the package being analyzed.
*/
readonly packageFolder: string;
/**
* Reports an error message to the registered ApiErrorHandler.
*/
reportError(message: string, sourceFile: ts.SourceFile | undefined, start: number | undefined): void;
/**
* Scans for external package api files and loads them into the docItemLoader member before
* any API analysis begins.
*
* @param externalJsonCollectionPath - an absolute path to to the folder that contains all the external
* api json files.
* Ex: if externalJsonPath is './resources', then in that folder
* are 'es6-collections.api.json', etc.
*/
loadExternalPackages(externalJsonCollectionPath: string): void;
}