UNPKG

api-extractor-model-me

Version:

A helper library for loading and saving the .api.json files created by API Extractor

1,308 lines (1,251 loc) 83.7 kB
/** * Use this library to read and write *.api.json files as defined by the * {@link https://api-extractor.com/ | API Extractor} tool. These files are used to generate a documentation * website for your TypeScript package. The files store the API signatures and doc comments that were extracted * from your package. * * @packageDocumentation */ import { DeclarationReference } from '@microsoft/tsdoc/lib-commonjs/beta/DeclarationReference'; import { DocDeclarationReference } from '@microsoft/tsdoc'; import { IJsonFileSaveOptions } from '@rushstack/node-core-library'; import * as tsdoc from '@microsoft/tsdoc'; import { TSDocConfiguration } from '@microsoft/tsdoc'; import { TSDocTagDefinition } from '@microsoft/tsdoc'; /** * @internal */ export declare class AedocDefinitions { static readonly betaDocumentation: TSDocTagDefinition; static readonly internalRemarks: TSDocTagDefinition; static readonly preapprovedTag: TSDocTagDefinition; static get tsdocConfiguration(): TSDocConfiguration; private static _tsdocConfiguration; } /** * Represents a TypeScript function call signature. * * @remarks * * This is part of the {@link ApiModel} hierarchy of classes, which are serializable representations of * API declarations. * * `ApiCallSignature` represents a TypeScript declaration such as `(x: number, y: number): number` * in this example: * * ```ts * export interface IChooser { * // A call signature: * (x: number, y: number): number; * * // Another overload for this call signature: * (x: string, y: string): string; * } * * function chooseFirst<T>(x: T, y: T): T { * return x; * } * * let chooser: IChooser = chooseFirst; * ``` * * @public */ export declare class ApiCallSignature extends ApiCallSignature_base { constructor(options: IApiCallSignatureOptions); static getContainerKey(overloadIndex: number): string; /** @override */ get kind(): ApiItemKind; /** @override */ get containerKey(): string; /** @beta @override */ buildCanonicalReference(): DeclarationReference; } declare const ApiCallSignature_base: typeof ApiDeclaredItem & (new (...args: any[]) => ApiReturnTypeMixin) & (new (...args: any[]) => ApiReleaseTagMixin) & (new (...args: any[]) => ApiParameterListMixin) & (new (...args: any[]) => ApiTypeParameterListMixin); /** * Represents a TypeScript class declaration. * * @remarks * * This is part of the {@link ApiModel} hierarchy of classes, which are serializable representations of * API declarations. * * `ApiClass` represents a TypeScript declaration such as this: * * ```ts * export class X { } * ``` * * @public */ export declare class ApiClass extends ApiClass_base { /** * The base class that this class inherits from (using the `extends` keyword), or undefined if there is no base class. */ readonly extendsType: HeritageType | undefined; private readonly _implementsTypes; constructor(options: IApiClassOptions); static getContainerKey(name: string): string; /** @override */ static onDeserializeInto(options: Partial<IApiClassOptions>, context: DeserializerContext, jsonObject: IApiClassJson): void; /** @override */ get kind(): ApiItemKind; /** @override */ get containerKey(): string; /** * The list of interfaces that this class implements using the `implements` keyword. */ get implementsTypes(): ReadonlyArray<HeritageType>; /** @override */ serializeInto(jsonObject: Partial<IApiClassJson>): void; /** @beta @override */ buildCanonicalReference(): DeclarationReference; } declare const ApiClass_base: typeof ApiDeclaredItem & (new (...args: any[]) => ApiReleaseTagMixin) & (new (...args: any[]) => ApiTypeParameterListMixin) & (new (...args: any[]) => ApiNameMixin) & (new (...args: any[]) => ApiItemContainerMixin); /** * Represents a TypeScript class constructor declaration that belongs to an `ApiClass`. * * @remarks * * This is part of the {@link ApiModel} hierarchy of classes, which are serializable representations of * API declarations. * * `ApiConstructor` represents a declaration using the `constructor` keyword such as in this example: * * ```ts * export class Vector { * public x: number; * public y: number; * * // A class constructor: * public constructor(x: number, y: number) { * this.x = x; * this.y = y; * } * } * ``` * * Compare with {@link ApiConstructSignature}, which describes the construct signature for a class constructor. * * @public */ export declare class ApiConstructor extends ApiConstructor_base { constructor(options: IApiConstructorOptions); static getContainerKey(overloadIndex: number): string; /** @override */ get kind(): ApiItemKind; /** @override */ get containerKey(): string; /** @beta @override */ buildCanonicalReference(): DeclarationReference; } declare const ApiConstructor_base: typeof ApiDeclaredItem & (new (...args: any[]) => ApiReleaseTagMixin) & (new (...args: any[]) => ApiParameterListMixin); /** * Represents a TypeScript construct signature that belongs to an `ApiInterface`. * * @remarks * * This is part of the {@link ApiModel} hierarchy of classes, which are serializable representations of * API declarations. * * `ApiConstructSignature` represents a construct signature using the `new` keyword such as in this example: * * ```ts * export interface IVector { * x: number; * y: number; * } * * export interface IVectorConstructor { * // A construct signature: * new(x: number, y: number): IVector; * } * * export function createVector(vectorConstructor: IVectorConstructor, * x: number, y: number): IVector { * return new vectorConstructor(x, y); * } * * class Vector implements IVector { * public x: number; * public y: number; * public constructor(x: number, y: number) { * this.x = x; * this.y = y; * } * } * * let vector: Vector = createVector(Vector, 1, 2); * ``` * * Compare with {@link ApiConstructor}, which describes the class constructor itself. * * @public */ export declare class ApiConstructSignature extends ApiConstructSignature_base { constructor(options: IApiConstructSignatureOptions); static getContainerKey(overloadIndex: number): string; /** @override */ get kind(): ApiItemKind; /** @override */ get containerKey(): string; /** @beta @override */ buildCanonicalReference(): DeclarationReference; } declare const ApiConstructSignature_base: typeof ApiDeclaredItem & (new (...args: any[]) => ApiReturnTypeMixin) & (new (...args: any[]) => ApiReleaseTagMixin) & (new (...args: any[]) => ApiParameterListMixin) & (new (...args: any[]) => ApiTypeParameterListMixin); /** * The base class for API items that have an associated source code excerpt containing a TypeScript declaration. * * @remarks * * This is part of the {@link ApiModel} hierarchy of classes, which are serializable representations of * API declarations. * * Most `ApiItem` subclasses have declarations and thus extend `ApiDeclaredItem`. Counterexamples include * `ApiModel` and `ApiPackage`, which do not have any corresponding TypeScript source code. * * @public */ export declare class ApiDeclaredItem extends ApiDocumentedItem { private _excerptTokens; private _excerpt; constructor(options: IApiDeclaredItemOptions); /** @override */ static onDeserializeInto(options: Partial<IApiDeclaredItemOptions>, context: DeserializerContext, jsonObject: IApiDeclaredItemJson): void; /** * The source code excerpt where the API item is declared. */ get excerpt(): Excerpt; /** * The individual source code tokens that comprise the main excerpt. */ get excerptTokens(): ReadonlyArray<ExcerptToken>; /** * If the API item has certain important modifier tags such as `@sealed`, `@virtual`, or `@override`, * this prepends them as a doc comment above the excerpt. */ getExcerptWithModifiers(): string; /** @override */ serializeInto(jsonObject: Partial<IApiDeclaredItemJson>): void; /** * Constructs a new {@link Excerpt} corresponding to the provided token range. */ buildExcerpt(tokenRange: IExcerptTokenRange): Excerpt; } /** * An abstract base class for API declarations that can have an associated TSDoc comment. * * @remarks * * This is part of the {@link ApiModel} hierarchy of classes, which are serializable representations of * API declarations. * * @public */ export declare class ApiDocumentedItem extends ApiItem { private _tsdocComment; constructor(options: IApiDocumentedItemOptions); /** @override */ static onDeserializeInto(options: Partial<IApiDocumentedItemOptions>, context: DeserializerContext, jsonObject: IApiItemJson): void; get tsdocComment(): tsdoc.DocComment | undefined; /** @override */ serializeInto(jsonObject: Partial<IApiDocumentedItemJson>): void; } /** * Represents the entry point for an NPM package. * * @remarks * * This is part of the {@link ApiModel} hierarchy of classes, which are serializable representations of * API declarations. * * `ApiEntryPoint` represents the entry point to an NPM package. API Extractor does not currently support * analysis of multiple entry points, but the `ApiEntryPoint` object is included to support a future feature. * In the current implementation, `ApiEntryPoint.importPath` is always the empty string. * * For example, suppose the package.json file looks like this: * * ```json * { * "name": "example-library", * "version": "1.0.0", * "main": "./lib/index.js", * "typings": "./lib/index.d.ts" * } * ``` * * In this example, the `ApiEntryPoint` would represent the TypeScript module for `./lib/index.js`. * * @public */ export declare class ApiEntryPoint extends ApiEntryPoint_base { constructor(options: IApiEntryPointOptions); /** @override */ get kind(): ApiItemKind; /** @override */ get containerKey(): string; /** * The module path for this entry point, relative to the parent `ApiPackage`. In the current implementation, * this is always the empty string, indicating the default entry point. * * @remarks * * API Extractor does not currently support analysis of multiple entry points. If that feature is implemented * in the future, then the `ApiEntryPoint.importPath` will be used to distinguish different entry points, * for example: `controls/Button` in `import { Button } from "example-package/controls/Button";`. * * The `ApiEntryPoint.name` property stores the same value as `ApiEntryPoint.importPath`. */ get importPath(): string; /** @beta @override */ buildCanonicalReference(): DeclarationReference; } declare const ApiEntryPoint_base: typeof ApiItem & (new (...args: any[]) => ApiNameMixin) & (new (...args: any[]) => ApiItemContainerMixin); /** * Represents a TypeScript enum declaration. * * @remarks * * This is part of the {@link ApiModel} hierarchy of classes, which are serializable representations of * API declarations. * * `ApiEnum` represents an enum declaration such as `FontSizes` in the example below: * * ```ts * export enum FontSizes { * Small = 100, * Medium = 200, * Large = 300 * } * ``` * * @public */ export declare class ApiEnum extends ApiEnum_base { constructor(options: IApiEnumOptions); static getContainerKey(name: string): string; /** @override */ get kind(): ApiItemKind; /** @override */ get members(): ReadonlyArray<ApiEnumMember>; /** @override */ get containerKey(): string; /** @override */ addMember(member: ApiEnumMember): void; /** @beta @override */ buildCanonicalReference(): DeclarationReference; } declare const ApiEnum_base: typeof ApiDeclaredItem & (new (...args: any[]) => ApiReleaseTagMixin) & (new (...args: any[]) => ApiNameMixin) & (new (...args: any[]) => ApiItemContainerMixin); /** * Represents a member of a TypeScript enum declaration. * * @remarks * * This is part of the {@link ApiModel} hierarchy of classes, which are serializable representations of * API declarations. * * `ApiEnumMember` represents an enum member such as `Small = 100` in the example below: * * ```ts * export enum FontSizes { * Small = 100, * Medium = 200, * Large = 300 * } * ``` * * @public */ export declare class ApiEnumMember extends ApiEnumMember_base { /** * An {@link Excerpt} that describes the value of the enum member. */ readonly initializerExcerpt: Excerpt; constructor(options: IApiEnumMemberOptions); static getContainerKey(name: string): string; /** @override */ static onDeserializeInto(options: Partial<IApiEnumMemberOptions>, context: DeserializerContext, jsonObject: IApiEnumMemberJson): void; /** @override */ get kind(): ApiItemKind; /** @override */ get containerKey(): string; /** @override */ serializeInto(jsonObject: Partial<IApiEnumMemberJson>): void; /** @beta @override */ buildCanonicalReference(): DeclarationReference; } declare const ApiEnumMember_base: typeof ApiDeclaredItem & (new (...args: any[]) => ApiReleaseTagMixin) & (new (...args: any[]) => ApiNameMixin); /** * Represents a TypeScript function declaration. * * @remarks * * This is part of the {@link ApiModel} hierarchy of classes, which are serializable representations of * API declarations. * * `ApiFunction` represents a TypeScript declaration such as this example: * * ```ts * export function getAverage(x: number, y: number): number { * return (x + y) / 2.0; * } * ``` * * Functions are exported by an entry point module or by a namespace. Compare with {@link ApiMethod}, which * represents a function that is a member of a class. * * @public */ export declare class ApiFunction extends ApiFunction_base { constructor(options: IApiFunctionOptions); static getContainerKey(name: string, overloadIndex: number): string; /** @override */ get kind(): ApiItemKind; /** @override */ get containerKey(): string; /** @beta @override */ buildCanonicalReference(): DeclarationReference; } declare const ApiFunction_base: typeof ApiDeclaredItem & (new (...args: any[]) => ApiReturnTypeMixin) & (new (...args: any[]) => ApiReleaseTagMixin) & (new (...args: any[]) => ApiParameterListMixin) & (new (...args: any[]) => ApiTypeParameterListMixin) & (new (...args: any[]) => ApiNameMixin); /** * Represents a TypeScript index signature. * * @remarks * * This is part of the {@link ApiModel} hierarchy of classes, which are serializable representations of * API declarations. * * `ApiIndexSignature` represents a TypeScript declaration such as `[x: number]: number` in this example: * * ```ts * export interface INumberTable { * // An index signature * [value: number]: number; * * // An overloaded index signature * [name: string]: number; * } * ``` * * @public */ export declare class ApiIndexSignature extends ApiIndexSignature_base { constructor(options: IApiIndexSignatureOptions); static getContainerKey(overloadIndex: number): string; /** @override */ get kind(): ApiItemKind; /** @override */ get containerKey(): string; /** @beta @override */ buildCanonicalReference(): DeclarationReference; } declare const ApiIndexSignature_base: typeof ApiDeclaredItem & (new (...args: any[]) => ApiReturnTypeMixin) & (new (...args: any[]) => ApiReleaseTagMixin) & (new (...args: any[]) => ApiParameterListMixin); /** * Represents a TypeScript class declaration. * * @remarks * * This is part of the {@link ApiModel} hierarchy of classes, which are serializable representations of * API declarations. * * `ApiInterface` represents a TypeScript declaration such as this: * * ```ts * export interface X extends Y { * } * ``` * * @public */ export declare class ApiInterface extends ApiInterface_base { private readonly _extendsTypes; constructor(options: IApiInterfaceOptions); static getContainerKey(name: string): string; /** @override */ static onDeserializeInto(options: Partial<IApiInterfaceOptions>, context: DeserializerContext, jsonObject: IApiInterfaceJson): void; /** @override */ get kind(): ApiItemKind; /** @override */ get containerKey(): string; /** * The list of base interfaces that this interface inherits from using the `extends` keyword. */ get extendsTypes(): ReadonlyArray<HeritageType>; /** @override */ serializeInto(jsonObject: Partial<IApiInterfaceJson>): void; /** @beta @override */ buildCanonicalReference(): DeclarationReference; } declare const ApiInterface_base: typeof ApiDeclaredItem & (new (...args: any[]) => ApiReleaseTagMixin) & (new (...args: any[]) => ApiTypeParameterListMixin) & (new (...args: any[]) => ApiNameMixin) & (new (...args: any[]) => ApiItemContainerMixin); /** * The abstract base class for all members of an `ApiModel` object. * * @remarks * This is part of the {@link ApiModel} hierarchy of classes, which are serializable representations of * API declarations. * @public */ export declare class ApiItem { private _canonicalReference; private _parent; constructor(options: IApiItemOptions); static deserialize(jsonObject: IApiItemJson, context: DeserializerContext): ApiItem; /** @virtual */ static onDeserializeInto(options: Partial<IApiItemOptions>, context: DeserializerContext, jsonObject: IApiItemJson): void; /** @virtual */ serializeInto(jsonObject: Partial<IApiItemJson>): void; /** * Identifies the subclass of the `ApiItem` base class. * @virtual */ get kind(): ApiItemKind; /** * Warning: This API is used internally by API extractor but is not yet ready for general usage. * * @remarks * * Returns a `DeclarationReference` object using the experimental new declaration reference notation. * * @beta */ get canonicalReference(): DeclarationReference; /** * Returns a string key that can be used to efficiently retrieve an `ApiItem` from an `ApiItemContainerMixin`. * The key is unique within the container. Its format is undocumented and may change at any time. * * @remarks * Use the `getContainerKey()` static member to construct the key. Each subclass has a different implementation * of this function, according to the aspects that are important for identifying it. * * @virtual */ get containerKey(): string; /** * Returns a name for this object that can be used in diagnostic messages, for example. * * @remarks * For an object that inherits ApiNameMixin, this will return the declared name (e.g. the name of a TypeScript * function). Otherwise, it will return a string such as "(call signature)" or "(model)". * * @virtual */ get displayName(): string; /** * If this item was added to a ApiItemContainerMixin item, then this returns the container item. * If this is an Parameter that was added to a method or function, then this returns the function item. * Otherwise, it returns undefined. * @virtual */ get parent(): ApiItem | undefined; /** * This property supports a visitor pattern for walking the tree. * For items with ApiItemContainerMixin, it returns the contained items, sorted alphabetically. * Otherwise it returns an empty array. * @virtual */ get members(): ReadonlyArray<ApiItem>; /** * If this item has a name (i.e. extends `ApiNameMixin`), then return all items that have the same parent * and the same name. Otherwise, return all items that have the same parent and the same `ApiItemKind`. * * @remarks * Examples: For a function, this would return all overloads for the function. For a constructor, this would * return all overloads for the constructor. For a merged declaration (e.g. a `namespace` and `enum` with the * same name), this would return both declarations. If this item does not have a parent, or if it is the only * item of its name/kind, then the result is an array containing only this item. */ getMergedSiblings(): ReadonlyArray<ApiItem>; /** * Returns the chain of ancestors, starting from the root of the tree, and ending with the this item. */ getHierarchy(): ReadonlyArray<ApiItem>; /** * This returns a scoped name such as `"Namespace1.Namespace2.MyClass.myMember()"`. It does not include the * package name or entry point. * * @remarks * If called on an ApiEntrypoint, ApiPackage, or ApiModel item, the result is an empty string. */ getScopedNameWithinPackage(): string; /** * If this item is an ApiPackage or has an ApiPackage as one of its parents, then that object is returned. * Otherwise undefined is returned. */ getAssociatedPackage(): ApiPackage | undefined; /** @virtual */ getSortKey(): string; /** * PRIVATE * * @privateRemarks * Allows ApiItemContainerMixin to assign the parent when the item is added to a container. * * @internal */ [apiItem_onParentChanged](parent: ApiItem | undefined): void; /** * Builds the cached object used by the `canonicalReference` property. * @virtual */ protected buildCanonicalReference(): DeclarationReference; } declare const apiItem_onParentChanged: unique symbol; /** * Mixin function for {@link ApiDeclaredItem}. * * @param baseClass - The base class to be extended * @returns A child class that extends baseClass, adding the {@link (ApiItemContainerMixin:interface)} functionality. * * @public */ export declare function ApiItemContainerMixin<TBaseClass extends IApiItemConstructor>(baseClass: TBaseClass): TBaseClass & (new (...args: any[]) => ApiItemContainerMixin); /** * The mixin base class for API items that act as containers for other child items. * * @remarks * * This is part of the {@link ApiModel} hierarchy of classes, which are serializable representations of * API declarations. The non-abstract classes (e.g. `ApiClass`, `ApiEnum`, `ApiInterface`, etc.) use * TypeScript "mixin" functions (e.g. `ApiDeclaredItem`, `ApiItemContainerMixin`, etc.) to add various * features that cannot be represented as a normal inheritance chain (since TypeScript does not allow a child class * to extend more than one base class). The "mixin" is a TypeScript merged declaration with three components: * the function that generates a subclass, an interface that describes the members of the subclass, and * a namespace containing static members of the class. * * Examples of `ApiItemContainerMixin` child classes include `ApiModel`, `ApiPackage`, `ApiEntryPoint`, * and `ApiEnum`. But note that `Parameter` is not considered a "member" of an `ApiMethod`; this relationship * is modeled using {@link (ApiParameterListMixin:interface).parameters} instead * of {@link ApiItem.members}. * * @public */ export declare interface ApiItemContainerMixin extends ApiItem { /** * Adds a new member to the container. * * @remarks * An ApiItem cannot be added to more than one container. */ addMember(member: ApiItem): void; /** * Attempts to retrieve a member using its containerKey, or returns `undefined` if no matching member was found. * * @remarks * Use the `getContainerKey()` static member to construct the key. Each subclass has a different implementation * of this function, according to the aspects that are important for identifying it. * * See {@link ApiItem.containerKey} for more information. */ tryGetMemberByKey(containerKey: string): ApiItem | undefined; /** * Returns a list of members with the specified name. */ findMembersByName(name: string): ReadonlyArray<ApiItem>; /** * For a given member of this container, return its `ApiItem.getMergedSiblings()` list. * @internal */ _getMergedSiblingsForMember(memberApiItem: ApiItem): ReadonlyArray<ApiItem>; /** @override */ serializeInto(jsonObject: Partial<IApiItemJson>): void; } /** * Static members for {@link (ApiItemContainerMixin:interface)}. * @public */ export declare namespace ApiItemContainerMixin { /** * A type guard that tests whether the specified `ApiItem` subclass extends the `ApiItemContainerMixin` mixin. * * @remarks * * The JavaScript `instanceof` operator cannot be used to test for mixin inheritance, because each invocation of * the mixin function produces a different subclass. (This could be mitigated by `Symbol.hasInstance`, however * the TypeScript type system cannot invoke a runtime test.) */ export function isBaseClassOf(apiItem: ApiItem): apiItem is ApiItemContainerMixin; } /** * The type returned by the {@link ApiItem.kind} property, which can be used to easily distinguish subclasses of * {@link ApiItem}. * * @public */ export declare const enum ApiItemKind { CallSignature = "CallSignature", Class = "Class", Constructor = "Constructor", ConstructSignature = "ConstructSignature", EntryPoint = "EntryPoint", Enum = "Enum", EnumMember = "EnumMember", Function = "Function", IndexSignature = "IndexSignature", Interface = "Interface", Method = "Method", MethodSignature = "MethodSignature", Model = "Model", Namespace = "Namespace", Package = "Package", Property = "Property", PropertySignature = "PropertySignature", TypeAlias = "TypeAlias", Variable = "Variable", None = "None" } declare enum ApiJsonSchemaVersion { /** * The initial release. */ V_1000 = 1000, /** * Add support for type parameters and type alias types. */ V_1001 = 1001, /** * Remove "canonicalReference" field. This field was for diagnostic purposes only and was never deserialized. */ V_1002 = 1002, /** * Reintroduce the "canonicalReference" field using the experimental new TSDoc declaration reference notation. * * This is not a breaking change because this field is never deserialized; it is provided for informational * purposes only. */ V_1003 = 1003, /** * The current latest .api.json schema version. * * IMPORTANT: When incrementing this number, consider whether `OLDEST_SUPPORTED` or `OLDEST_FORWARDS_COMPATIBLE` * should be updated. */ LATEST = 1003, /** * The oldest .api.json schema version that is still supported for backwards compatibility. * * This must be updated if you change to the file format and do not implement compatibility logic for * deserializing the older representation. */ OLDEST_SUPPORTED = 1001, /** * Used to assign `IApiPackageMetadataJson.oldestForwardsCompatibleVersion`. * * This value must be \<= `ApiJsonSchemaVersion.LATEST`. It must be reset to the `LATEST` value * if the older library would not be able to deserialize your new file format. Adding a nonessential field * is generally okay. Removing, modifying, or reinterpreting existing fields is NOT safe. */ OLDEST_FORWARDS_COMPATIBLE = 1001 } /** * Represents a TypeScript member function declaration that belongs to an `ApiClass`. * * @remarks * * This is part of the {@link ApiModel} hierarchy of classes, which are serializable representations of * API declarations. * * `ApiMethod` represents a TypeScript declaration such as the `render` member function in this example: * * ```ts * export class Widget { * public render(): void { } * } * ``` * * Compare with {@link ApiMethodSignature}, which represents a method belonging to an interface. * For example, a class method can be `static` but an interface method cannot. * * @public */ export declare class ApiMethod extends ApiMethod_base { constructor(options: IApiMethodOptions); static getContainerKey(name: string, isStatic: boolean, overloadIndex: number): string; /** @override */ get kind(): ApiItemKind; /** @override */ get containerKey(): string; /** @beta @override */ buildCanonicalReference(): DeclarationReference; } declare const ApiMethod_base: typeof ApiDeclaredItem & (new (...args: any[]) => ApiOptionalMixin) & (new (...args: any[]) => ApiStaticMixin) & (new (...args: any[]) => ApiReturnTypeMixin) & (new (...args: any[]) => ApiReleaseTagMixin) & (new (...args: any[]) => ApiParameterListMixin) & (new (...args: any[]) => ApiTypeParameterListMixin) & (new (...args: any[]) => ApiNameMixin); /** * Represents a TypeScript member function declaration that belongs to an `ApiInterface`. * * @remarks * * This is part of the {@link ApiModel} hierarchy of classes, which are serializable representations of * API declarations. * * `ApiMethodSignature` represents a TypeScript declaration such as the `render` member function in this example: * * ```ts * export interface IWidget { * render(): void; * } * ``` * * Compare with {@link ApiMethod}, which represents a method belonging to a class. * For example, a class method can be `static` but an interface method cannot. * * @public */ export declare class ApiMethodSignature extends ApiMethodSignature_base { constructor(options: IApiMethodSignatureOptions); static getContainerKey(name: string, overloadIndex: number): string; /** @override */ get kind(): ApiItemKind; /** @override */ get containerKey(): string; /** @beta @override */ buildCanonicalReference(): DeclarationReference; } declare const ApiMethodSignature_base: typeof ApiDeclaredItem & (new (...args: any[]) => ApiOptionalMixin) & (new (...args: any[]) => ApiReturnTypeMixin) & (new (...args: any[]) => ApiReleaseTagMixin) & (new (...args: any[]) => ApiParameterListMixin) & (new (...args: any[]) => ApiTypeParameterListMixin) & (new (...args: any[]) => ApiNameMixin); /** * A serializable representation of a collection of API declarations. * * @remarks * * An `ApiModel` represents a collection of API declarations that can be serialized to disk. It captures all the * important information needed to generate documentation, without any reliance on the TypeScript compiler engine. * * An `ApiModel` acts as the root of a tree of objects that all inherit from the `ApiItem` base class. * The tree children are determined by the {@link (ApiItemContainerMixin:interface)} mixin base class. The model * contains packages. Packages have an entry point (today, only one). And the entry point can contain various types * of API declarations. The container relationships might look like this: * * ``` * Things that can contain other things: * * - ApiModel * - ApiPackage * - ApiEntryPoint * - ApiClass * - ApiMethod * - ApiProperty * - ApiEnum * - ApiEnumMember * - ApiInterface * - ApiMethodSignature * - ApiPropertySignature * - ApiNamespace * - (ApiClass, ApiEnum, ApiInterace, ...) * * ``` * * Normally, API Extractor writes an .api.json file to disk for each project that it builds. Then, a tool like * API Documenter can load the various `ApiPackage` objects into a single `ApiModel` and process them as a group. * This is useful because compilation generally occurs separately (e.g. because projects may reside in different * Git repos, or because they build with different TypeScript compiler configurations that may be incompatible), * whereas API Documenter cannot detect broken hyperlinks without seeing the entire documentation set. * * @public */ export declare class ApiModel extends ApiModel_base { private readonly _resolver; private _packagesByName; private _apiItemsByCanonicalReference; constructor(); loadPackage(apiJsonFilename: string): ApiPackage; /** @override */ get kind(): ApiItemKind; /** @override */ get containerKey(): string; get packages(): ReadonlyArray<ApiPackage>; /** @override */ addMember(member: ApiPackage): void; /** * Efficiently finds a package by the NPM package name. * * @remarks * * If the NPM scope is omitted in the package name, it will still be found provided that it is an unambiguous match. * For example, it's often convenient to write `{@link node-core-library#JsonFile}` instead of * `{@link @rushstack/node-core-library#JsonFile}`. */ tryGetPackageByName(packageName: string): ApiPackage | undefined; resolveDeclarationReference(declarationReference: DocDeclarationReference | DeclarationReference, contextApiItem: ApiItem | undefined): IResolveDeclarationReferenceResult; private _initApiItemsRecursive; /** @beta @override */ buildCanonicalReference(): DeclarationReference; } declare const ApiModel_base: typeof ApiItem & (new (...args: any[]) => ApiItemContainerMixin); /** * Mixin function for {@link (ApiNameMixin:interface)}. * * @param baseClass - The base class to be extended * @returns A child class that extends baseClass, adding the {@link (ApiNameMixin:interface)} functionality. * * @public */ export declare function ApiNameMixin<TBaseClass extends IApiItemConstructor>(baseClass: TBaseClass): TBaseClass & (new (...args: any[]) => ApiNameMixin); /** * The mixin base class for API items that have a name. For example, a class has a name, but a class constructor * does not. * * @remarks * * This is part of the {@link ApiModel} hierarchy of classes, which are serializable representations of * API declarations. The non-abstract classes (e.g. `ApiClass`, `ApiEnum`, `ApiInterface`, etc.) use * TypeScript "mixin" functions (e.g. `ApiDeclaredItem`, `ApiItemContainerMixin`, etc.) to add various * features that cannot be represented as a normal inheritance chain (since TypeScript does not allow a child class * to extend more than one base class). The "mixin" is a TypeScript merged declaration with three components: * the function that generates a subclass, an interface that describes the members of the subclass, and * a namespace containing static members of the class. * * @public */ export declare interface ApiNameMixin extends ApiItem { /** * The exported name of this API item. * * @remarks * Note that due tue type aliasing, the exported name may be different from the locally declared name. */ readonly name: string; /** @override */ serializeInto(jsonObject: Partial<IApiItemJson>): void; } /** * Static members for {@link (ApiNameMixin:interface)}. * @public */ export declare namespace ApiNameMixin { /** * A type guard that tests whether the specified `ApiItem` subclass extends the `ApiNameMixin` mixin. * * @remarks * * The JavaScript `instanceof` operator cannot be used to test for mixin inheritance, because each invocation of * the mixin function produces a different subclass. (This could be mitigated by `Symbol.hasInstance`, however * the TypeScript type system cannot invoke a runtime test.) */ export function isBaseClassOf(apiItem: ApiItem): apiItem is ApiNameMixin; } /** * Represents a TypeScript namespace declaration. * * @remarks * * This is part of the {@link ApiModel} hierarchy of classes, which are serializable representations of * API declarations. * * `ApiNamespace` represents a TypeScript declaration such `X` or `Y` in this example: * * ```ts * export namespace X { * export namespace Y { * export interface IWidget { * render(): void; * } * } * } * ``` * * @public */ export declare class ApiNamespace extends ApiNamespace_base { constructor(options: IApiNamespaceOptions); static getContainerKey(name: string): string; /** @override */ get kind(): ApiItemKind; /** @override */ get containerKey(): string; /** @beta @override */ buildCanonicalReference(): DeclarationReference; } declare const ApiNamespace_base: typeof ApiDeclaredItem & (new (...args: any[]) => ApiReleaseTagMixin) & (new (...args: any[]) => ApiNameMixin) & (new (...args: any[]) => ApiItemContainerMixin); /** * Mixin function for {@link (ApiOptionalMixin:interface)}. * * @param baseClass - The base class to be extended * @returns A child class that extends baseClass, adding the {@link (ApiOptionalMixin:interface)} functionality. * * @public */ export declare function ApiOptionalMixin<TBaseClass extends IApiItemConstructor>(baseClass: TBaseClass): TBaseClass & (new (...args: any[]) => ApiOptionalMixin); /** * The mixin base class for API items that can be marked as optional by appending a `?` to them. * For example, a property of an interface can be optional. * * @remarks * * This is part of the {@link ApiModel} hierarchy of classes, which are serializable representations of * API declarations. The non-abstract classes (e.g. `ApiClass`, `ApiEnum`, `ApiInterface`, etc.) use * TypeScript "mixin" functions (e.g. `ApiDeclaredItem`, `ApiItemContainerMixin`, etc.) to add various * features that cannot be represented as a normal inheritance chain (since TypeScript does not allow a child class * to extend more than one base class). The "mixin" is a TypeScript merged declaration with three components: * the function that generates a subclass, an interface that describes the members of the subclass, and * a namespace containing static members of the class. * * @public */ export declare interface ApiOptionalMixin extends ApiItem { /** * True if this is an optional property. * @remarks * For example: * ```ts * interface X { * y: string; // not optional * z?: string; // optional * } * ``` */ readonly isOptional: boolean; /** @override */ serializeInto(jsonObject: Partial<IApiItemJson>): void; } /** * Optional members for {@link (ApiOptionalMixin:interface)}. * @public */ export declare namespace ApiOptionalMixin { /** * A type guard that tests whether the specified `ApiItem` subclass extends the `ApiOptionalMixin` mixin. * * @remarks * * The JavaScript `instanceof` operator cannot be used to test for mixin inheritance, because each invocation of * the mixin function produces a different subclass. (This could be mitigated by `Symbol.hasInstance`, however * the TypeScript type system cannot invoke a runtime test.) */ export function isBaseClassOf(apiItem: ApiItem): apiItem is ApiOptionalMixin; } /** * Represents an NPM package containing API declarations. * * @remarks * * This is part of the {@link ApiModel} hierarchy of classes, which are serializable representations of * API declarations. * * @public */ export declare class ApiPackage extends ApiPackage_base { constructor(options: IApiPackageOptions); static loadFromJsonFile(apiJsonFilename: string): ApiPackage; /** @override */ get kind(): ApiItemKind; /** @override */ get containerKey(): string; get entryPoints(): ReadonlyArray<ApiEntryPoint>; /** @override */ addMember(member: ApiEntryPoint): void; findEntryPointsByPath(importPath: string): ReadonlyArray<ApiEntryPoint>; saveToJsonFile(apiJsonFilename: string, options?: IApiPackageSaveOptions): void; /** @beta @override */ buildCanonicalReference(): DeclarationReference; } declare const ApiPackage_base: typeof ApiDocumentedItem & (new (...args: any[]) => ApiNameMixin) & (new (...args: any[]) => ApiItemContainerMixin); /** * Mixin function for {@link (ApiParameterListMixin:interface)}. * * @param baseClass - The base class to be extended * @returns A child class that extends baseClass, adding the {@link (ApiParameterListMixin:interface)} functionality. * * @public */ export declare function ApiParameterListMixin<TBaseClass extends IApiItemConstructor>(baseClass: TBaseClass): TBaseClass & (new (...args: any[]) => ApiParameterListMixin); /** * The mixin base class for API items that can have function parameters (but not necessarily a return value). * * @remarks * * This is part of the {@link ApiModel} hierarchy of classes, which are serializable representations of * API declarations. The non-abstract classes (e.g. `ApiClass`, `ApiEnum`, `ApiInterface`, etc.) use * TypeScript "mixin" functions (e.g. `ApiDeclaredItem`, `ApiItemContainerMixin`, etc.) to add various * features that cannot be represented as a normal inheritance chain (since TypeScript does not allow a child class * to extend more than one base class). The "mixin" is a TypeScript merged declaration with three components: * the function that generates a subclass, an interface that describes the members of the subclass, and * a namespace containing static members of the class. * * @public */ export declare interface ApiParameterListMixin extends ApiItem { /** * When a function has multiple overloaded declarations, this zero-based integer index can be used to unqiuely * identify them. * * @remarks * * Consider this overloaded declaration: * * ```ts * export namespace Versioning { * // TSDoc: Versioning.(addVersions:1) * export function addVersions(x: number, y: number): number; * * // TSDoc: Versioning.(addVersions:2) * export function addVersions(x: string, y: string): string; * * // (implementation) * export function addVersions(x: number|string, y: number|string): number|string { * // . . . * } * } * ``` * * In the above example, there are two overloaded declarations. The overload using numbers will have * `overloadIndex = 1`. The overload using strings will have `overloadIndex = 2`. The third declaration that * accepts all possible inputs is considered part of the implementation, and is not processed by API Extractor. */ readonly overloadIndex: number; /** * The function parameters. */ readonly parameters: ReadonlyArray<Parameter>; serializeInto(jsonObject: Partial<IApiItemJson>): void; } /** * Static members for {@link (ApiParameterListMixin:interface)}. * @public */ export declare namespace ApiParameterListMixin { /** * A type guard that tests whether the specified `ApiItem` subclass extends the `ApiParameterListMixin` mixin. * * @remarks * * The JavaScript `instanceof` operator cannot be used to test for mixin inheritance, because each invocation of * the mixin function produces a different subclass. (This could be mitigated by `Symbol.hasInstance`, however * the TypeScript type system cannot invoke a runtime test.) */ export function isBaseClassOf(apiItem: ApiItem): apiItem is ApiParameterListMixin; } /** * Represents a TypeScript property declaration that belongs to an `ApiClass`. * * @remarks * * This is part of the {@link ApiModel} hierarchy of classes, which are serializable representations of * API declarations. * * `ApiProperty` represents a TypeScript declaration such as the `width` and `height` members in this example: * * ```ts * export class Widget { * public width: number = 100; * * public get height(): number { * if (this.isSquashed()) { * return 0; * } else { * return this.clientArea.height; * } * } * } * ``` * * Note that member variables are also considered to be properties. * * If the property has both a getter function and setter function, they will be represented by a single `ApiProperty` * and must have a single documentation comment. * * Compare with {@link ApiPropertySignature}, which represents a property belonging to an interface. * For example, a class property can be `static` but an interface property cannot. * * @public */ export declare class ApiProperty extends ApiProperty_base { constructor(options: IApiPropertyOptions); static getContainerKey(name: string, isStatic: boolean): string; /** @override */ get kind(): ApiItemKind; /** @override */ get containerKey(): string; /** @beta @override */ buildCanonicalReference(): DeclarationReference; } declare const ApiProperty_base: typeof ApiPropertyItem & (new (...args: any[]) => ApiStaticMixin); /** * The abstract base class for {@link ApiProperty} and {@link ApiPropertySignature}. * * @public */ export declare class ApiPropertyItem extends ApiPropertyItem_base { /** * An {@link Excerpt} that describes the type of the property. */ readonly propertyTypeExcerpt: Excerpt; constructor(options: IApiPropertyItemOptions); /** @override */ static onDeserializeInto(options: Partial<IApiPropertyItemOptions>, context: DeserializerContext, jsonObject: IApiPropertyItemJson): void; /** * Returns true if this property should be documented as an event. * * @remarks * The `@eventProperty` TSDoc modifier can be added to readonly properties to indicate that they return an * event object that event handlers can be attached to. The event-handling API is implementation-defined, but * typically the return type would be a class with members such as `addHandler()` and `removeHandler()`. * The documentation should display such properties under an "Events" heading instead of the * usual "Properties" heading. */ get isEventProperty(): boolean; /** @override */ serializeInto(jsonObject: Partial<IApiPropertyItemJson>): void; } declare const ApiPropertyItem_base: typeof ApiDeclaredItem & (new (...args: any[]) => ApiOptionalMixin) & (new (...args: any[]) => ApiReleaseTagMixin) & (new (...args: any[]) => ApiNameMixin); /** * Represents a TypeScript property declaration that belongs to an `ApiInterface`. * * @remarks * * This is part of the {@link ApiModel} hierarchy of classes, which are serializable representations of * API declarations. * * `ApiPropertySignature` represents a TypeScript declaration such as the `width` and `height` members in this example: * * ```ts * export interface IWidget { * readonly width: number; * height: number; * } * ``` * * Compare with {@link ApiProperty}, which represents a property belonging to a class. * For example, a class property can be `static` but an interface property cannot. * * @public */ export declare class ApiPropertySignature extends ApiPropertyItem { constructor(options: IApiPropertySignatureOptions); static getContainerKey(name: string): string; /** @override */ get kind(): ApiItemKind; /** @override */ get containerKey(): string; /** @beta @override */ buildCanonicalReference(): DeclarationReference; } /** * Mixin function for {@link (ApiReleaseTagMixin:interface)}. * * @param baseClass - The base class to be extended * @returns A child class that extends baseClass, adding the {@link (ApiReleaseTagMixin:interface)} functionality. * * @public */ export declare function ApiReleaseTagMixin<TBaseClass extends IApiItemConstructor>(baseClass: TBaseClass): TBaseClass & (new (...args: any[]) => ApiReleaseTagMixin); /** * The mixin base class for API items that can be attributed with a TSDoc tag such as `@internal`, * `@alpha`, `@beta`, or `@public`. These "release tags" indicate the support level for an API. * * @remarks * * This is part of the {@link ApiModel} hierarchy of classes, which are serializable representations of * API declarations. The non-abstract classes (e.g. `ApiClass`, `ApiEnum`, `ApiInterface`, etc.) use * TypeScript "mixin" functions (e.g. `ApiDeclaredItem`, `ApiItemContainerMixin`, etc.) to add various * features that cannot be represented as a normal inheritance chain (since TypeScript does not allow a child class * to extend more than one base class). The "mixin" is a TypeScript merged declaration with three components: * the function that generates a subclass, an interface that describes the members of the subclass, and * a namespace containing static members of the class. * * @public */ export declare interface ApiReleaseTagMixin extends ApiItem { /** * The effective release tag for this declaration. If it is not explicitly specified, the value may be * inherited from a containing declaration. * * @remarks * For example, an `ApiEnumMember` may inherit its release t