Commit 956c501c authored by DatHV's avatar DatHV
Browse files

update build x-app-sdk

parent 9bb8aadd
/**
* API Extractor helps with validation, documentation, and reviewing of the exported API for a TypeScript library.
* The `@microsoft/api-extractor` package provides the command-line tool. It also exposes a developer API that you
* can use to invoke API Extractor programmatically.
*
* @packageDocumentation
*/
import { EnumMemberOrder } from '@microsoft/api-extractor-model';
import { INodePackageJson } from '@rushstack/node-core-library';
import { IRigConfig } from '@rushstack/rig-package';
import { JsonSchema } from '@rushstack/node-core-library';
import { NewlineKind } from '@rushstack/node-core-library';
import { PackageJsonLookup } from '@rushstack/node-core-library';
import { ReleaseTag } from '@microsoft/api-extractor-model';
import type * as tsdoc from '@microsoft/tsdoc';
import { TSDocConfigFile } from '@microsoft/tsdoc-config';
import { TSDocConfiguration } from '@microsoft/tsdoc';
/**
* The allowed variations of API reports.
*
* @public
*/
export declare type ApiReportVariant = 'public' | 'beta' | 'alpha' | 'complete';
/**
* This class represents the TypeScript compiler state. This allows an optimization where multiple invocations
* of API Extractor can reuse the same TypeScript compiler analysis.
*
* @public
*/
export declare class CompilerState {
/**
* The TypeScript compiler's `Program` object, which represents a complete scope of analysis.
*/
readonly program: unknown;
private constructor();
/**
* Create a compiler state for use with the specified `IExtractorInvokeOptions`.
*/
static create(extractorConfig: ExtractorConfig, options?: ICompilerStateCreateOptions): CompilerState;
/**
* Given a list of absolute file paths, return a list containing only the declaration
* files. Duplicates are also eliminated.
*
* @remarks
* The tsconfig.json settings specify the compiler's input (a set of *.ts source files,
* plus some *.d.ts declaration files used for legacy typings). However API Extractor
* analyzes the compiler's output (a set of *.d.ts entry point files, plus any legacy
* typings). This requires API Extractor to generate a special file list when it invokes
* the compiler.
*
* Duplicates are removed so that entry points can be appended without worrying whether they
* may already appear in the tsconfig.json file list.
*/
private static _generateFilePathsForAnalysis;
private static _createCompilerHost;
}
/**
* Unique identifiers for console messages reported by API Extractor.
*
* @remarks
*
* These strings are possible values for the {@link ExtractorMessage.messageId} property
* when the `ExtractorMessage.category` is {@link ExtractorMessageCategory.Console}.
*
* @public
*/
export declare enum ConsoleMessageId {
/**
* "Analysis will use the bundled TypeScript version ___"
*/
Preamble = "console-preamble",
/**
* "The target project appears to use TypeScript ___ which is newer than the bundled compiler engine;
* consider upgrading API Extractor."
*/
CompilerVersionNotice = "console-compiler-version-notice",
/**
* "Using custom TSDoc config from ___"
*/
UsingCustomTSDocConfig = "console-using-custom-tsdoc-config",
/**
* "Found metadata in ___"
*/
FoundTSDocMetadata = "console-found-tsdoc-metadata",
/**
* "Writing: ___"
*/
WritingDocModelFile = "console-writing-doc-model-file",
/**
* "Writing package typings: ___"
*/
WritingDtsRollup = "console-writing-dts-rollup",
/**
* "Generating ___ API report: ___"
*/
WritingApiReport = "console-writing-api-report",
/**
* "You have changed the public API signature for this project.
* Please copy the file ___ to ___, or perform a local build (which does this automatically).
* See the Git repo documentation for more info."
*
* OR
*
* "The API report file is missing.
* Please copy the file ___ to ___, or perform a local build (which does this automatically).
* See the Git repo documentation for more info."
*/
ApiReportNotCopied = "console-api-report-not-copied",
/**
* "You have changed the public API signature for this project. Updating ___"
*/
ApiReportCopied = "console-api-report-copied",
/**
* "The API report is up to date: ___"
*/
ApiReportUnchanged = "console-api-report-unchanged",
/**
* "The API report file was missing, so a new file was created. Please add this file to Git: ___"
*/
ApiReportCreated = "console-api-report-created",
/**
* "Unable to create the API report file. Please make sure the target folder exists: ___"
*/
ApiReportFolderMissing = "console-api-report-folder-missing",
/**
* Used for the information printed when the "--diagnostics" flag is enabled.
*/
Diagnostics = "console-diagnostics"
}
/**
* The starting point for invoking the API Extractor tool.
* @public
*/
export declare class Extractor {
/**
* Returns the version number of the API Extractor NPM package.
*/
static get version(): string;
/**
* Returns the package name of the API Extractor NPM package.
*/
static get packageName(): string;
private static _getPackageJson;
/**
* Load the api-extractor.json config file from the specified path, and then invoke API Extractor.
*/
static loadConfigAndInvoke(configFilePath: string, options?: IExtractorInvokeOptions): ExtractorResult;
/**
* Invoke API Extractor using an already prepared `ExtractorConfig` object.
*/
static invoke(extractorConfig: ExtractorConfig, options?: IExtractorInvokeOptions): ExtractorResult;
/**
* Generates the API report at the specified release level, writes it to the specified file path, and compares
* the output to the existing report (if one exists).
*
* @param reportTempDirectoryPath - The path to the directory under which the temp report file will be written prior
* to comparison with an existing report.
* @param reportDirectoryPath - The path to the directory under which the existing report file is located, and to
* which the new report will be written post-comparison.
* @param reportConfig - API report configuration, including its file name and {@link ApiReportVariant}.
*
* @returns Whether or not the newly generated report differs from the existing report (if one exists).
*/
private static _writeApiReport;
private static _checkCompilerCompatibility;
private static _generateRollupDtsFile;
}
/**
* The `ExtractorConfig` class loads, validates, interprets, and represents the api-extractor.json config file.
* @sealed
* @public
*/
export declare class ExtractorConfig {
/**
* The JSON Schema for API Extractor config file (api-extractor.schema.json).
*/
static readonly jsonSchema: JsonSchema;
/**
* The config file name "api-extractor.json".
*/
static readonly FILENAME: 'api-extractor.json';
/**
* The full path to `extends/tsdoc-base.json` which contains the standard TSDoc configuration
* for API Extractor.
* @internal
*/
static readonly _tsdocBaseFilePath: string;
private static readonly _defaultConfig;
/** Match all three flavors for type declaration files (.d.ts, .d.mts, .d.cts) */
private static readonly _declarationFileExtensionRegExp;
/** {@inheritDoc IConfigFile.projectFolder} */
readonly projectFolder: string;
/**
* The parsed package.json file for the working package, or undefined if API Extractor was invoked without
* a package.json file.
*/
readonly packageJson: INodePackageJson | undefined;
/**
* The absolute path of the folder containing the package.json file for the working package, or undefined
* if API Extractor was invoked without a package.json file.
*/
readonly packageFolder: string | undefined;
/** {@inheritDoc IConfigFile.mainEntryPointFilePath} */
readonly mainEntryPointFilePath: string;
/** {@inheritDoc IConfigFile.bundledPackages} */
readonly bundledPackages: string[];
/** {@inheritDoc IConfigCompiler.tsconfigFilePath} */
readonly tsconfigFilePath: string;
/** {@inheritDoc IConfigCompiler.overrideTsconfig} */
readonly overrideTsconfig: {} | undefined;
/** {@inheritDoc IConfigCompiler.skipLibCheck} */
readonly skipLibCheck: boolean;
/** {@inheritDoc IConfigApiReport.enabled} */
readonly apiReportEnabled: boolean;
/**
* List of configurations for report files to be generated.
* @remarks Derived from {@link IConfigApiReport.reportFileName} and {@link IConfigApiReport.reportVariants}.
*/
readonly reportConfigs: readonly IExtractorConfigApiReport[];
/** {@inheritDoc IConfigApiReport.reportFolder} */
readonly reportFolder: string;
/** {@inheritDoc IConfigApiReport.reportTempFolder} */
readonly reportTempFolder: string;
/** {@inheritDoc IConfigApiReport.tagsToReport} */
readonly tagsToReport: Readonly<Record<`@${string}`, boolean>>;
/**
* Gets the file path for the "complete" (default) report configuration, if one was specified.
* Otherwise, returns an empty string.
* @deprecated Use {@link ExtractorConfig.reportConfigs} to access all report configurations.
*/
get reportFilePath(): string;
/**
* Gets the temp file path for the "complete" (default) report configuration, if one was specified.
* Otherwise, returns an empty string.
* @deprecated Use {@link ExtractorConfig.reportConfigs} to access all report configurations.
*/
get reportTempFilePath(): string;
/** {@inheritDoc IConfigApiReport.includeForgottenExports} */
readonly apiReportIncludeForgottenExports: boolean;
/**
* If specified, the doc model is enabled and the specified options will be used.
* @beta
*/
readonly docModelGenerationOptions: IApiModelGenerationOptions | undefined;
/** {@inheritDoc IConfigDocModel.apiJsonFilePath} */
readonly apiJsonFilePath: string;
/** {@inheritDoc IConfigDocModel.includeForgottenExports} */
readonly docModelIncludeForgottenExports: boolean;
/** {@inheritDoc IConfigDocModel.projectFolderUrl} */
readonly projectFolderUrl: string | undefined;
/** {@inheritDoc IConfigDtsRollup.enabled} */
readonly rollupEnabled: boolean;
/** {@inheritDoc IConfigDtsRollup.untrimmedFilePath} */
readonly untrimmedFilePath: string;
/** {@inheritDoc IConfigDtsRollup.alphaTrimmedFilePath} */
readonly alphaTrimmedFilePath: string;
/** {@inheritDoc IConfigDtsRollup.betaTrimmedFilePath} */
readonly betaTrimmedFilePath: string;
/** {@inheritDoc IConfigDtsRollup.publicTrimmedFilePath} */
readonly publicTrimmedFilePath: string;
/** {@inheritDoc IConfigDtsRollup.omitTrimmingComments} */
readonly omitTrimmingComments: boolean;
/** {@inheritDoc IConfigTsdocMetadata.enabled} */
readonly tsdocMetadataEnabled: boolean;
/** {@inheritDoc IConfigTsdocMetadata.tsdocMetadataFilePath} */
readonly tsdocMetadataFilePath: string;
/**
* The tsdoc.json configuration that will be used when parsing doc comments.
*/
readonly tsdocConfigFile: TSDocConfigFile;
/**
* The `TSDocConfiguration` loaded from {@link ExtractorConfig.tsdocConfigFile}.
*/
readonly tsdocConfiguration: TSDocConfiguration;
/**
* Specifies what type of newlines API Extractor should use when writing output files. By default, the output files
* will be written with Windows-style newlines.
*/
readonly newlineKind: NewlineKind;
/** {@inheritDoc IConfigFile.messages} */
readonly messages: IExtractorMessagesConfig;
/** {@inheritDoc IConfigFile.testMode} */
readonly testMode: boolean;
/** {@inheritDoc IConfigFile.enumMemberOrder} */
readonly enumMemberOrder: EnumMemberOrder;
private constructor();
/**
* Returns a JSON-like string representing the `ExtractorConfig` state, which can be printed to a console
* for diagnostic purposes.
*
* @remarks
* This is used by the "--diagnostics" command-line option. The string is not intended to be deserialized;
* its format may be changed at any time.
*/
getDiagnosticDump(): string;
/**
* Returns a simplified file path for use in error messages.
* @internal
*/
_getShortFilePath(absolutePath: string): string;
/**
* Searches for the api-extractor.json config file associated with the specified starting folder,
* and loads the file if found. This lookup supports
* {@link https://www.npmjs.com/package/@rushstack/rig-package | rig packages}.
*
* @remarks
* The search will first look for a package.json file in a parent folder of the starting folder;
* if found, that will be used as the base folder instead of the starting folder. If the config
* file is not found in `<baseFolder>/api-extractor.json` or `<baseFolder>/config/api-extractor.json`,
* then `<baseFolder/config/rig.json` will be checked to see whether a
* {@link https://www.npmjs.com/package/@rushstack/rig-package | rig package} is referenced; if so then
* the rig's api-extractor.json file will be used instead. If a config file is found, it will be loaded
* and returned with the `IExtractorConfigPrepareOptions` object. Otherwise, `undefined` is returned
* to indicate that API Extractor does not appear to be configured for the specified folder.
*
* @returns An options object that can be passed to {@link ExtractorConfig.prepare}, or `undefined`
* if not api-extractor.json file was found.
*/
static tryLoadForFolder(options: IExtractorConfigLoadForFolderOptions): IExtractorConfigPrepareOptions | undefined;
/**
* Loads the api-extractor.json config file from the specified file path, and prepares an `ExtractorConfig` object.
*
* @remarks
* Loads the api-extractor.json config file from the specified file path. If the "extends" field is present,
* the referenced file(s) will be merged. For any omitted fields, the API Extractor default values are merged.
*
* The result is prepared using `ExtractorConfig.prepare()`.
*/
static loadFileAndPrepare(configJsonFilePath: string): ExtractorConfig;
/**
* Performs only the first half of {@link ExtractorConfig.loadFileAndPrepare}, providing an opportunity to
* modify the object before it is passed to {@link ExtractorConfig.prepare}.
*
* @remarks
* Loads the api-extractor.json config file from the specified file path. If the "extends" field is present,
* the referenced file(s) will be merged. For any omitted fields, the API Extractor default values are merged.
*/
static loadFile(jsonFilePath: string): IConfigFile;
private static _resolveConfigFileRelativePaths;
private static _resolveConfigFileRelativePath;
/**
* Prepares an `ExtractorConfig` object using a configuration that is provided as a runtime object,
* rather than reading it from disk. This allows configurations to be constructed programmatically,
* loaded from an alternate source, and/or customized after loading.
*/
static prepare(options: IExtractorConfigPrepareOptions): ExtractorConfig;
/**
* Gets the report configuration for the "complete" (default) report configuration, if one was specified.
*/
private _getCompleteReportConfig;
private static _resolvePathWithTokens;
private static _expandStringWithTokens;
/**
* Returns true if the specified file path has the ".d.ts" file extension.
*/
static hasDtsFileExtension(filePath: string): boolean;
/**
* Given a path string that may have originally contained expandable tokens such as `<projectFolder>"`
* this reports an error if any token-looking substrings remain after expansion (e.g. `c:\blah\<invalid>\blah`).
*/
private static _rejectAnyTokensInPath;
}
/**
* Used with {@link IConfigMessageReportingRule.logLevel} and {@link IExtractorInvokeOptions.messageCallback}.
*
* @remarks
* This is part of the {@link IConfigFile} structure.
*
* @public
*/
export declare enum ExtractorLogLevel {
/**
* The message will be displayed as an error.
*
* @remarks
* Errors typically cause the build to fail and return a nonzero exit code.
*/
Error = "error",
/**
* The message will be displayed as an warning.
*
* @remarks
* Warnings typically cause a production build fail and return a nonzero exit code. For a non-production build
* (e.g. using the `--local` option with `api-extractor run`), the warning is displayed but the build will not fail.
*/
Warning = "warning",
/**
* The message will be displayed as an informational message.
*
* @remarks
* Informational messages may contain newlines to ensure nice formatting of the output,
* however word-wrapping is the responsibility of the message handler.
*/
Info = "info",
/**
* The message will be displayed only when "verbose" output is requested, e.g. using the `--verbose`
* command line option.
*/
Verbose = "verbose",
/**
* The message will be discarded entirely.
*/
None = "none"
}
/**
* This object is used to report an error or warning that occurred during API Extractor's analysis.
*
* @public
*/
export declare class ExtractorMessage {
private _handled;
private _logLevel;
/**
* The category of issue.
*/
readonly category: ExtractorMessageCategory;
/**
* A text string that uniquely identifies the issue type. This identifier can be used to suppress
* or configure the reporting of issues, and also to search for help about an issue.
*/
readonly messageId: tsdoc.TSDocMessageId | ExtractorMessageId | ConsoleMessageId | string;
/**
* The text description of this issue.
*/
readonly text: string;
/**
* The absolute path to the affected input source file, if there is one.
*/
readonly sourceFilePath: string | undefined;
/**
* The line number where the issue occurred in the input source file. This is not used if `sourceFilePath`
* is undefined. The first line number is 1.
*/
readonly sourceFileLine: number | undefined;
/**
* The column number where the issue occurred in the input source file. This is not used if `sourceFilePath`
* is undefined. The first column number is 1.
*/
readonly sourceFileColumn: number | undefined;
/**
* Additional contextual information about the message that may be useful when reporting errors.
* All properties are optional.
*/
readonly properties: IExtractorMessageProperties;
/** @internal */
constructor(options: IExtractorMessageOptions);
/**
* If the {@link IExtractorInvokeOptions.messageCallback} sets this property to true, it will prevent the message
* from being displayed by API Extractor.
*
* @remarks
* If the `messageCallback` routes the message to a custom handler (e.g. a toolchain logger), it should
* assign `handled = true` to prevent API Extractor from displaying it. Assigning `handled = true` for all messages
* would effectively disable all console output from the `Extractor` API.
*
* If `handled` is set to true, the message will still be included in the count of errors/warnings;
* to discard a message entirely, instead assign `logLevel = none`.
*/
get handled(): boolean;
set handled(value: boolean);
/**
* Specifies how the message should be reported.
*
* @remarks
* If the {@link IExtractorInvokeOptions.messageCallback} handles the message (i.e. sets `handled = true`),
* it can use the `logLevel` to determine how to display the message.
*
* Alternatively, if API Extractor is handling the message, the `messageCallback` could assign `logLevel` to change
* how it will be processed. However, in general the recommended practice is to configure message routing
* using the `messages` section in api-extractor.json.
*
* To discard a message entirely, assign `logLevel = none`.
*/
get logLevel(): ExtractorLogLevel;
set logLevel(value: ExtractorLogLevel);
/**
* Returns the message formatted with its identifier and file position.
* @remarks
* Example:
* ```
* src/folder/File.ts:123:4 - (ae-extra-release-tag) The doc comment should not contain more than one release tag.
* ```
*/
formatMessageWithLocation(workingPackageFolderPath: string | undefined): string;
formatMessageWithoutLocation(): string;
}
/**
* Specifies a category of messages for use with {@link ExtractorMessage}.
* @public
*/
export declare enum ExtractorMessageCategory {
/**
* Messages originating from the TypeScript compiler.
*
* @remarks
* These strings begin with the prefix "TS" and have a numeric error code.
* Example: `TS2551`
*/
Compiler = "Compiler",
/**
* Messages related to parsing of TSDoc comments.
*
* @remarks
* These strings begin with the prefix "tsdoc-".
* Example: `tsdoc-link-tag-unescaped-text`
*/
TSDoc = "TSDoc",
/**
* Messages related to API Extractor's analysis.
*
* @remarks
* These strings begin with the prefix "ae-".
* Example: `ae-extra-release-tag`
*/
Extractor = "Extractor",
/**
* Console messages communicate the progress of the overall operation. They may include newlines to ensure
* nice formatting. They are output in real time, and cannot be routed to the API Report file.
*
* @remarks
* These strings begin with the prefix "console-".
* Example: `console-writing-typings-file`
*/
Console = "console"
}
/**
* Unique identifiers for messages reported by API Extractor during its analysis.
*
* @remarks
*
* These strings are possible values for the {@link ExtractorMessage.messageId} property
* when the `ExtractorMessage.category` is {@link ExtractorMessageCategory.Extractor}.
*
* @public
*/
export declare enum ExtractorMessageId {
/**
* "The doc comment should not contain more than one release tag."
*/
ExtraReleaseTag = "ae-extra-release-tag",
/**
* "Missing documentation for ___."
* @remarks
* The `ae-undocumented` message is only generated if the API report feature is enabled.
*
* Because the API report file already annotates undocumented items with `// (undocumented)`,
* the `ae-undocumented` message is not logged by default. To see it, add a setting such as:
* ```json
* "messages": {
* "extractorMessageReporting": {
* "ae-undocumented": {
* "logLevel": "warning"
* }
* }
* }
* ```
*/
Undocumented = "ae-undocumented",
/**
* "This symbol has another declaration with a different release tag."
*/
DifferentReleaseTags = "ae-different-release-tags",
/**
* "The symbol ___ is marked as ___, but its signature references ___ which is marked as ___."
*/
IncompatibleReleaseTags = "ae-incompatible-release-tags",
/**
* "___ is part of the package's API, but it is missing a release tag (`@alpha`, `@beta`, `@public`, or `@internal`)."
*/
MissingReleaseTag = "ae-missing-release-tag",
/**
* "The `@packageDocumentation` comment must appear at the top of entry point *.d.ts file."
*/
MisplacedPackageTag = "ae-misplaced-package-tag",
/**
* "The symbol ___ needs to be exported by the entry point ___."
*/
ForgottenExport = "ae-forgotten-export",
/**
* "The name ___ should be prefixed with an underscore because the declaration is marked as `@internal`."
*/
InternalMissingUnderscore = "ae-internal-missing-underscore",
/**
* "Mixed release tags are not allowed for ___ because one of its declarations is marked as `@internal`."
*/
InternalMixedReleaseTag = "ae-internal-mixed-release-tag",
/**
* "The `@preapproved` tag cannot be applied to ___ because it is not a supported declaration type."
*/
PreapprovedUnsupportedType = "ae-preapproved-unsupported-type",
/**
* "The `@preapproved` tag cannot be applied to ___ without an `@internal` release tag."
*/
PreapprovedBadReleaseTag = "ae-preapproved-bad-release-tag",
/**
* "The `@inheritDoc` reference could not be resolved."
*/
UnresolvedInheritDocReference = "ae-unresolved-inheritdoc-reference",
/**
* "The `@inheritDoc` tag needs a TSDoc declaration reference; signature matching is not supported yet."
*
* @privateRemarks
* In the future, we will implement signature matching so that you can write `{@inheritDoc}` and API Extractor
* will find a corresponding member from a base class (or implemented interface). Until then, the tag
* always needs an explicit declaration reference such as `{@inhertDoc MyBaseClass.sameMethod}`.
*/
UnresolvedInheritDocBase = "ae-unresolved-inheritdoc-base",
/**
* "The `@inheritDoc` tag for ___ refers to its own declaration."
*/
CyclicInheritDoc = "ae-cyclic-inherit-doc",
/**
* "The `@link` reference could not be resolved."
*/
UnresolvedLink = "ae-unresolved-link",
/**
* "The doc comment for the property ___ must appear on the getter, not the setter."
*/
SetterWithDocs = "ae-setter-with-docs",
/**
* "The property ___ has a setter but no getter."
*/
MissingGetter = "ae-missing-getter",
/**
* "Incorrect file type; API Extractor expects to analyze compiler outputs with the .d.ts file extension.
* Troubleshooting tips: `https://api-extractor.com/link/dts-error`"
*/
WrongInputFileType = "ae-wrong-input-file-type"
}
/**
* This object represents the outcome of an invocation of API Extractor.
*
* @public
*/
export declare class ExtractorResult {
/**
* The TypeScript compiler state that was used.
*/
readonly compilerState: CompilerState;
/**
* The API Extractor configuration that was used.
*/
readonly extractorConfig: ExtractorConfig;
/**
* Whether the invocation of API Extractor was successful. For example, if `succeeded` is false, then the build task
* would normally return a nonzero process exit code, indicating that the operation failed.
*
* @remarks
*
* Normally the operation "succeeds" if `errorCount` and `warningCount` are both zero. However if
* {@link IExtractorInvokeOptions.localBuild} is `true`, then the operation "succeeds" if `errorCount` is zero
* (i.e. warnings are ignored).
*/
readonly succeeded: boolean;
/**
* Returns true if the API report was found to have changed.
*/
readonly apiReportChanged: boolean;
/**
* Reports the number of errors encountered during analysis.
*
* @remarks
* This does not count exceptions, where unexpected issues prematurely abort the operation.
*/
readonly errorCount: number;
/**
* Reports the number of warnings encountered during analysis.
*
* @remarks
* This does not count warnings that are emitted in the API report file.
*/
readonly warningCount: number;
/** @internal */
constructor(properties: ExtractorResult);
}
/**
* @beta
*/
export declare interface IApiModelGenerationOptions {
/**
* The release tags to trim.
*/
releaseTagsToTrim: Set<ReleaseTag>;
}
/**
* Options for {@link CompilerState.create}
* @public
*/
export declare interface ICompilerStateCreateOptions {
/** {@inheritDoc IExtractorInvokeOptions.typescriptCompilerFolder} */
typescriptCompilerFolder?: string;
/**
* Additional .d.ts files to include in the analysis.
*/
additionalEntryPoints?: string[];
}
/**
* Configures how the API report files (*.api.md) will be generated.
*
* @remarks
* This is part of the {@link IConfigFile} structure.
*
* @public
*/
export declare interface IConfigApiReport {
/**
* Whether to generate an API report.
*/
enabled: boolean;
/**
* The base filename for the API report files, to be combined with {@link IConfigApiReport.reportFolder} or
* {@link IConfigApiReport.reportTempFolder} to produce the full file path.
*
* @remarks
* The `reportFileName` should not include any path separators such as `\` or `/`. The `reportFileName` should
* not include a file extension, since API Extractor will automatically append an appropriate file extension such
* as `.api.md`. If the {@link IConfigApiReport.reportVariants} setting is used, then the file extension includes
* the variant name, for example `my-report.public.api.md` or `my-report.beta.api.md`. The `complete` variant always
* uses the simple extension `my-report.api.md`.
*
* Previous versions of API Extractor required `reportFileName` to include the `.api.md` extension explicitly;
* for backwards compatibility, that is still accepted but will be discarded before applying the above rules.
*
* @defaultValue `<unscopedPackageName>`
*/
reportFileName?: string;
/**
* The set of report variants to generate.
*
* @remarks
* To support different approval requirements for different API levels, multiple "variants" of the API report can
* be generated. The `reportVariants` setting specifies a list of variants to be generated. If omitted,
* by default only the `complete` variant will be generated, which includes all `@internal`, `@alpha`, `@beta`,
* and `@public` items. Other possible variants are `alpha` (`@alpha` + `@beta` + `@public`),
* `beta` (`@beta` + `@public`), and `public` (`@public only`).
*
* The resulting API report file names will be derived from the {@link IConfigApiReport.reportFileName}.
*
* @defaultValue `[ "complete" ]`
*/
reportVariants?: ApiReportVariant[];
/**
* Specifies the folder where the API report file is written. The file name portion is determined by
* the `reportFileName` setting.
*
* @remarks
* The API report file is normally tracked by Git. Changes to it can be used to trigger a branch policy,
* e.g. for an API review.
*
* The path is resolved relative to the folder of the config file that contains the setting; to change this,
* prepend a folder token such as `<projectFolder>`.
*/
reportFolder?: string;
/**
* Specifies the folder where the temporary report file is written. The file name portion is determined by
* the `reportFileName` setting.
*
* @remarks
* After the temporary file is written to disk, it is compared with the file in the `reportFolder`.
* If they are different, a production build will fail.
*
* The path is resolved relative to the folder of the config file that contains the setting; to change this,
* prepend a folder token such as `<projectFolder>`.
*/
reportTempFolder?: string;
/**
* Whether "forgotten exports" should be included in the API report file.
*
* @remarks
* Forgotten exports are declarations flagged with `ae-forgotten-export` warnings. See
* https://api-extractor.com/pages/messages/ae-forgotten-export/ to learn more.
*
* @defaultValue `false`
*/
includeForgottenExports?: boolean;
/**
* Specifies a list of {@link https://tsdoc.org/ | TSDoc} tags that should be reported in the API report file for
* items whose documentation contains them.
*
* @remarks
* Tag names must begin with `@`.
*
* This list may include standard TSDoc tags as well as custom ones.
* For more information on defining custom TSDoc tags, see
* {@link https://api-extractor.com/pages/configs/tsdoc_json/#defining-your-own-tsdoc-tags | here}.
*
* Note that an item's release tag will always reported; this behavior cannot be overridden.
*
* @defaultValue `@sealed`, `@virtual`, `@override`, `@eventProperty`, and `@deprecated`
*
* @example Omitting default tags
* To omit the `@sealed` and `@virtual` tags from API reports, you would specify `tagsToReport` as follows:
* ```json
* "tagsToReport": {
* "@sealed": false,
* "@virtual": false
* }
* ```
*
* @example Including additional tags
* To include additional tags to the set included in API reports, you could specify `tagsToReport` like this:
* ```json
* "tagsToReport": {
* "@customTag": true
* }
* ```
* This will result in `@customTag` being included in addition to the default tags.
*/
tagsToReport?: Readonly<Record<`@${string}`, boolean>>;
}
/**
* Determines how the TypeScript compiler engine will be invoked by API Extractor.
*
* @remarks
* This is part of the {@link IConfigFile} structure.
*
* @public
*/
export declare interface IConfigCompiler {
/**
* Specifies the path to the tsconfig.json file to be used by API Extractor when analyzing the project.
*
* @remarks
* The path is resolved relative to the folder of the config file that contains the setting; to change this,
* prepend a folder token such as `<projectFolder>`.
*
* Note: This setting will be ignored if `overrideTsconfig` is used.
*/
tsconfigFilePath?: string;
/**
* Provides a compiler configuration that will be used instead of reading the tsconfig.json file from disk.
*
* @remarks
* The value must conform to the TypeScript tsconfig schema:
*
* http://json.schemastore.org/tsconfig
*
* If omitted, then the tsconfig.json file will instead be read from the projectFolder.
*/
overrideTsconfig?: {};
/**
* This option causes the compiler to be invoked with the `--skipLibCheck` option.
*
* @remarks
* This option is not recommended and may cause API Extractor to produce incomplete or incorrect declarations,
* but it may be required when dependencies contain declarations that are incompatible with the TypeScript engine
* that API Extractor uses for its analysis. Where possible, the underlying issue should be fixed rather than
* relying on skipLibCheck.
*/
skipLibCheck?: boolean;
}
/**
* Configures how the doc model file (*.api.json) will be generated.
*
* @remarks
* This is part of the {@link IConfigFile} structure.
*
* @public
*/
export declare interface IConfigDocModel {
/**
* Whether to generate a doc model file.
*/
enabled: boolean;
/**
* The output path for the doc model file. The file extension should be ".api.json".
*
* @remarks
* The path is resolved relative to the folder of the config file that contains the setting; to change this,
* prepend a folder token such as `<projectFolder>`.
*/
apiJsonFilePath?: string;
/**
* Whether "forgotten exports" should be included in the doc model file.
*
* @remarks
* Forgotten exports are declarations flagged with `ae-forgotten-export` warnings. See
* https://api-extractor.com/pages/messages/ae-forgotten-export/ to learn more.
*
* @defaultValue `false`
*/
includeForgottenExports?: boolean;
/**
* The base URL where the project's source code can be viewed on a website such as GitHub or
* Azure DevOps. This URL path corresponds to the `<projectFolder>` path on disk.
*
* @remarks
* This URL is concatenated with the file paths serialized to the doc model to produce URL file paths to individual API items.
* For example, if the `projectFolderUrl` is "https://github.com/microsoft/rushstack/tree/main/apps/api-extractor" and an API
* item's file path is "api/ExtractorConfig.ts", the full URL file path would be
* "https://github.com/microsoft/rushstack/tree/main/apps/api-extractor/api/ExtractorConfig.js".
*
* Can be omitted if you don't need source code links in your API documentation reference.
*/
projectFolderUrl?: string;
/**
* Specifies a list of release tags that will be trimmed from the doc model.
*
* @defaultValue `["@internal"]`
*/
releaseTagsToTrim?: ReleaseTagForTrim[];
}
/**
* Configures how the .d.ts rollup file will be generated.
*
* @remarks
* This is part of the {@link IConfigFile} structure.
*
* @public
*/
export declare interface IConfigDtsRollup {
/**
* Whether to generate the .d.ts rollup file.
*/
enabled: boolean;
/**
* Specifies the output path for a .d.ts rollup file to be generated without any trimming.
*
* @remarks
* This file will include all declarations that are exported by the main entry point.
*
* If the path is an empty string, then this file will not be written.
*
* The path is resolved relative to the folder of the config file that contains the setting; to change this,
* prepend a folder token such as `<projectFolder>`.
*/
untrimmedFilePath?: string;
/**
* Specifies the output path for a .d.ts rollup file to be generated with trimming for an "alpha" release.
*
* @remarks
* This file will include only declarations that are marked as `@public`, `@beta`, or `@alpha`.
*
* The path is resolved relative to the folder of the config file that contains the setting; to change this,
* prepend a folder token such as `<projectFolder>`.
*/
alphaTrimmedFilePath?: string;
/**
* Specifies the output path for a .d.ts rollup file to be generated with trimming for a "beta" release.
*
* @remarks
* This file will include only declarations that are marked as `@public` or `@beta`.
*
* The path is resolved relative to the folder of the config file that contains the setting; to change this,
* prepend a folder token such as `<projectFolder>`.
*/
betaTrimmedFilePath?: string;
/**
* Specifies the output path for a .d.ts rollup file to be generated with trimming for a "public" release.
*
* @remarks
* This file will include only declarations that are marked as `@public`.
*
* If the path is an empty string, then this file will not be written.
*
* The path is resolved relative to the folder of the config file that contains the setting; to change this,
* prepend a folder token such as `<projectFolder>`.
*/
publicTrimmedFilePath?: string;
/**
* When a declaration is trimmed, by default it will be replaced by a code comment such as
* "Excluded from this release type: exampleMember". Set "omitTrimmingComments" to true to remove the
* declaration completely.
*/
omitTrimmingComments?: boolean;
}
/**
* Configuration options for the API Extractor tool. These options can be constructed programmatically
* or loaded from the api-extractor.json config file using the {@link ExtractorConfig} class.
*
* @public
*/
export declare interface IConfigFile {
/**
* Optionally specifies another JSON config file that this file extends from. This provides a way for
* standard settings to be shared across multiple projects.
*
* @remarks
* If the path starts with `./` or `../`, the path is resolved relative to the folder of the file that contains
* the `extends` field. Otherwise, the first path segment is interpreted as an NPM package name, and will be
* resolved using NodeJS `require()`.
*/
extends?: string;
/**
* Determines the `<projectFolder>` token that can be used with other config file settings. The project folder
* typically contains the tsconfig.json and package.json config files, but the path is user-defined.
*
* @remarks
*
* The path is resolved relative to the folder of the config file that contains the setting.
*
* The default value for `projectFolder` is the token `<lookup>`, which means the folder is determined using
* the following heuristics:
*
* If the config/rig.json system is used (as defined by {@link https://www.npmjs.com/package/@rushstack/rig-package
* | @rushstack/rig-package}), then the `<lookup>` value will be the package folder that referenced the rig.
*
* Otherwise, the `<lookup>` value is determined by traversing parent folders, starting from the folder containing
* api-extractor.json, and stopping at the first folder that contains a tsconfig.json file. If a tsconfig.json file
* cannot be found in this way, then an error will be reported.
*/
projectFolder?: string;
/**
* Specifies the .d.ts file to be used as the starting point for analysis. API Extractor
* analyzes the symbols exported by this module.
*
* @remarks
*
* The file extension must be ".d.ts" and not ".ts".
* The path is resolved relative to the "projectFolder" location.
*/
mainEntryPointFilePath: string;
/**
* A list of NPM package names whose exports should be treated as part of this package.
*
* @remarks
* Also supports glob patterns.
* Note: glob patterns will **only** be resolved against dependencies listed in the project's package.json file.
*
* * This is both a safety and a performance precaution.
*
* Exact package names will be applied against any dependency encountered while walking the type graph, regardless of
* dependencies listed in the package.json.
*
* @example
*
* Suppose that Webpack is used to generate a distributed bundle for the project `library1`,
* and another NPM package `library2` is embedded in this bundle. Some types from `library2` may become part
* of the exported API for `library1`, but by default API Extractor would generate a .d.ts rollup that explicitly
* imports `library2`. To avoid this, we can specify:
*
* ```js
* "bundledPackages": [ "library2" ],
* ```
*
* This would direct API Extractor to embed those types directly in the .d.ts rollup, as if they had been
* local files for `library1`.
*/
bundledPackages?: string[];
/**
* Specifies what type of newlines API Extractor should use when writing output files.
*
* @remarks
* By default, the output files will be written with Windows-style newlines.
* To use POSIX-style newlines, specify "lf" instead.
* To use the OS's default newline kind, specify "os".
*/
newlineKind?: 'crlf' | 'lf' | 'os';
/**
* Set to true when invoking API Extractor's test harness.
* @remarks
* When `testMode` is true, the `toolVersion` field in the .api.json file is assigned an empty string
* to prevent spurious diffs in output files tracked for tests.
*/
testMode?: boolean;
/**
* Specifies how API Extractor sorts members of an enum when generating the .api.json file.
*
* @remarks
* By default, the output files will be sorted alphabetically, which is "by-name".
* To keep the ordering in the source code, specify "preserve".
*
* @defaultValue `by-name`
*/
enumMemberOrder?: EnumMemberOrder;
/**
* {@inheritDoc IConfigCompiler}
*/
compiler?: IConfigCompiler;
/**
* {@inheritDoc IConfigApiReport}
*/
apiReport?: IConfigApiReport;
/**
* {@inheritDoc IConfigDocModel}
*/
docModel?: IConfigDocModel;
/**
* {@inheritDoc IConfigDtsRollup}
* @beta
*/
dtsRollup?: IConfigDtsRollup;
/**
* {@inheritDoc IConfigTsdocMetadata}
* @beta
*/
tsdocMetadata?: IConfigTsdocMetadata;
/**
* {@inheritDoc IExtractorMessagesConfig}
*/
messages?: IExtractorMessagesConfig;
}
/**
* Configures reporting for a given message identifier.
*
* @remarks
* This is part of the {@link IConfigFile} structure.
*
* @public
*/
export declare interface IConfigMessageReportingRule {
/**
* Specifies whether the message should be written to the the tool's output log.
*
* @remarks
* Note that the `addToApiReportFile` property may supersede this option.
*/
logLevel: ExtractorLogLevel;
/**
* When `addToApiReportFile` is true: If API Extractor is configured to write an API report file (.api.md),
* then the message will be written inside that file; otherwise, the message is instead logged according to
* the `logLevel` option.
*/
addToApiReportFile?: boolean;
}
/**
* Specifies a table of reporting rules for different message identifiers, and also the default rule used for
* identifiers that do not appear in the table.
*
* @remarks
* This is part of the {@link IConfigFile} structure.
*
* @public
*/
export declare interface IConfigMessageReportingTable {
/**
* The key is a message identifier for the associated type of message, or "default" to specify the default policy.
* For example, the key might be `TS2551` (a compiler message), `tsdoc-link-tag-unescaped-text` (a TSDOc message),
* or `ae-extra-release-tag` (a message related to the API Extractor analysis).
*/
[messageId: string]: IConfigMessageReportingRule;
}
/**
* Configures how the tsdoc-metadata.json file will be generated.
*
* @remarks
* This is part of the {@link IConfigFile} structure.
*
* @public
*/
export declare interface IConfigTsdocMetadata {
/**
* Whether to generate the tsdoc-metadata.json file.
*/
enabled: boolean;
/**
* Specifies where the TSDoc metadata file should be written.
*
* @remarks
* The path is resolved relative to the folder of the config file that contains the setting; to change this,
* prepend a folder token such as `<projectFolder>`.
*
* The default value is `<lookup>`, which causes the path to be automatically inferred from the `tsdocMetadata`,
* `typings` or `main` fields of the project's package.json. If none of these fields are set, the lookup
* falls back to `tsdoc-metadata.json` in the package folder.
*/
tsdocMetadataFilePath?: string;
}
/**
* Configuration for a single API report, including its {@link IExtractorConfigApiReport.variant}.
*
* @public
*/
export declare interface IExtractorConfigApiReport {
/**
* Report variant.
* Determines which API items will be included in the report output, based on their tagged release levels.
*/
variant: ApiReportVariant;
/**
* Name of the output report file.
* @remarks Relative to the configured report directory path.
*/
fileName: string;
}
/**
* Options for {@link ExtractorConfig.tryLoadForFolder}.
*
* @public
*/
export declare interface IExtractorConfigLoadForFolderOptions {
/**
* The folder path to start from when searching for api-extractor.json.
*/
startingFolder: string;
/**
* An already constructed `PackageJsonLookup` cache object to use. If omitted, a temporary one will
* be constructed.
*/
packageJsonLookup?: PackageJsonLookup;
/**
* An already constructed `RigConfig` object. If omitted, then a new `RigConfig` object will be constructed.
*/
rigConfig?: IRigConfig;
}
/**
* Options for {@link ExtractorConfig.prepare}.
*
* @public
*/
export declare interface IExtractorConfigPrepareOptions {
/**
* A configuration object as returned by {@link ExtractorConfig.loadFile}.
*/
configObject: IConfigFile;
/**
* The absolute path of the file that the `configObject` object was loaded from. This is used for error messages
* and when probing for `tsconfig.json`.
*
* @remarks
*
* If `configObjectFullPath` and `projectFolderLookupToken` are both unspecified, then the api-extractor.json
* config file must explicitly specify a `projectFolder` setting rather than relying on the `<lookup>` token.
*/
configObjectFullPath: string | undefined;
/**
* The parsed package.json file for the working package, or undefined if API Extractor was invoked without
* a package.json file.
*
* @remarks
*
* If omitted, then the `<unscopedPackageName>` and `<packageName>` tokens will have default values.
*/
packageJson?: INodePackageJson | undefined;
/**
* The absolute path of the file that the `packageJson` object was loaded from, or undefined if API Extractor
* was invoked without a package.json file.
*
* @remarks
*
* This is used for error messages and when resolving paths found in package.json.
*
* If `packageJsonFullPath` is specified but `packageJson` is omitted, the file will be loaded automatically.
*/
packageJsonFullPath: string | undefined;
/**
* The default value for the `projectFolder` setting is the `<lookup>` token, which uses a heuristic to guess
* an appropriate project folder. Use `projectFolderLookupValue` to manually specify the `<lookup>` token value
* instead.
*
* @remarks
* If the `projectFolder` setting is explicitly specified in api-extractor.json file, it should take precedence
* over a value specified via the API. Thus the `projectFolderLookupToken` option provides a way to override
* the default value for `projectFolder` setting while still honoring a manually specified value.
*/
projectFolderLookupToken?: string;
/**
* Allow customization of the tsdoc.json config file. If omitted, this file will be loaded from its default
* location. If the file does not exist, then the standard definitions will be used from
* `@microsoft/api-extractor/extends/tsdoc-base.json`.
*/
tsdocConfigFile?: TSDocConfigFile;
/**
* When preparing the configuration object, folder and file paths referenced in the configuration are checked
* for existence, and an error is reported if they are not found. This option can be used to disable this
* check for the main entry point module. This may be useful when preparing a configuration file for an
* un-built project.
*/
ignoreMissingEntryPoint?: boolean;
}
/**
* Runtime options for Extractor.
*
* @public
*/
export declare interface IExtractorInvokeOptions {
/**
* An optional TypeScript compiler state. This allows an optimization where multiple invocations of API Extractor
* can reuse the same TypeScript compiler analysis.
*/
compilerState?: CompilerState;
/**
* Indicates that API Extractor is running as part of a local build, e.g. on developer's
* machine.
*
* @remarks
* This disables certain validation that would normally be performed for a ship/production build. For example,
* the *.api.md report file is automatically updated in a local build.
*
* The default value is false.
*/
localBuild?: boolean;
/**
* If true, API Extractor will include {@link ExtractorLogLevel.Verbose} messages in its output.
*/
showVerboseMessages?: boolean;
/**
* If true, API Extractor will print diagnostic information used for troubleshooting problems.
* These messages will be included as {@link ExtractorLogLevel.Verbose} output.
*
* @remarks
* Setting `showDiagnostics=true` forces `showVerboseMessages=true`.
*/
showDiagnostics?: boolean;
/**
* Specifies an alternate folder path to be used when loading the TypeScript system typings.
*
* @remarks
* API Extractor uses its own TypeScript compiler engine to analyze your project. If your project
* is built with a significantly different TypeScript version, sometimes API Extractor may report compilation
* errors due to differences in the system typings (e.g. lib.dom.d.ts). You can use the "--typescriptCompilerFolder"
* option to specify the folder path where you installed the TypeScript package, and API Extractor's compiler will
* use those system typings instead.
*/
typescriptCompilerFolder?: string;
/**
* An optional callback function that will be called for each `ExtractorMessage` before it is displayed by
* API Extractor. The callback can customize the message, handle it, or discard it.
*
* @remarks
* If a `messageCallback` is not provided, then by default API Extractor will print the messages to
* the STDERR/STDOUT console.
*/
messageCallback?: (message: ExtractorMessage) => void;
}
/**
* Constructor options for `ExtractorMessage`.
*/
declare interface IExtractorMessageOptions {
category: ExtractorMessageCategory;
messageId: tsdoc.TSDocMessageId | ExtractorMessageId | ConsoleMessageId | string;
text: string;
sourceFilePath?: string;
sourceFileLine?: number;
sourceFileColumn?: number;
properties?: IExtractorMessageProperties;
logLevel?: ExtractorLogLevel;
}
/**
* Used by {@link ExtractorMessage.properties}.
*
* @public
*/
export declare interface IExtractorMessageProperties {
/**
* A declaration can have multiple names if it is exported more than once.
* If an `ExtractorMessage` applies to a specific export name, this property can indicate that.
*
* @remarks
*
* Used by {@link ExtractorMessageId.InternalMissingUnderscore}.
*/
readonly exportName?: string;
}
/**
* Configures how API Extractor reports error and warning messages produced during analysis.
*
* @remarks
* This is part of the {@link IConfigFile} structure.
*
* @public
*/
export declare interface IExtractorMessagesConfig {
/**
* Configures handling of diagnostic messages generating the TypeScript compiler while analyzing the
* input .d.ts files.
*/
compilerMessageReporting?: IConfigMessageReportingTable;
/**
* Configures handling of messages reported by API Extractor during its analysis.
*/
extractorMessageReporting?: IConfigMessageReportingTable;
/**
* Configures handling of messages reported by the TSDoc parser when analyzing code comments.
*/
tsdocMessageReporting?: IConfigMessageReportingTable;
}
/**
* The allowed release tags that can be used to mark API items.
* @public
*/
export declare type ReleaseTagForTrim = '@internal' | '@alpha' | '@beta' | '@public';
export { }
// This file is read by tools that parse documentation comments conforming to the TSDoc standard.
// It should be published with your NPM package. It should not be tracked by Git.
{
"tsdocVersion": "0.12",
"toolPackages": [
{
"packageName": "@microsoft/api-extractor",
"packageVersion": "7.53.1"
}
]
}
/**
* This file defines the TSDoc custom tags for use with API Extractor.
*
* If your project has a custom tsdoc.json file, then it should use the "extends" field to
* inherit the definitions from this file. For example:
*
* ```
* {
* "$schema": "https://developer.microsoft.com/json-schemas/tsdoc/v0/tsdoc.schema.json",
* "extends": [ "@microsoft/api-extractor/extends/tsdoc-config.json" ],
* . . .
* }
* ```
*
* For details about this config file, please see: https://tsdoc.org/pages/packages/tsdoc-config/
*/
{
"$schema": "https://developer.microsoft.com/json-schemas/tsdoc/v0/tsdoc.schema.json",
/**
* The "AEDoc" custom tags:
*/
"tagDefinitions": [
{
"tagName": "@betaDocumentation",
"syntaxKind": "modifier"
},
{
"tagName": "@internalRemarks",
"syntaxKind": "block"
},
{
"tagName": "@preapproved",
"syntaxKind": "modifier"
}
],
/**
* TSDoc tags implemented by API Extractor:
*/
"supportForTags": {
"@alpha": true,
"@beta": true,
"@defaultValue": true,
"@decorator": true,
"@deprecated": true,
"@eventProperty": true,
"@example": true,
"@experimental": true,
"@inheritDoc": true,
"@internal": true,
"@label": true,
"@link": true,
"@override": true,
"@packageDocumentation": true,
"@param": true,
"@privateRemarks": true,
"@public": true,
"@readonly": true,
"@remarks": true,
"@returns": true,
"@sealed": true,
"@see": true,
"@throws": true,
"@typeParam": true,
"@virtual": true,
"@betaDocumentation": true,
"@internalRemarks": true,
"@preapproved": true
}
}
import * as ts from 'typescript';
import type { Collector } from '../collector/Collector';
export declare class PackageDocComment {
/**
* For the given source file, see if it starts with a TSDoc comment containing the `@packageDocumentation` tag.
*/
static tryFindInSourceFile(sourceFile: ts.SourceFile, collector: Collector): ts.TextRange | undefined;
}
//# sourceMappingURL=PackageDocComment.d.ts.map
\ No newline at end of file
{"version":3,"file":"PackageDocComment.d.ts","sourceRoot":"","sources":["../../src/aedoc/PackageDocComment.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,MAAM,YAAY,CAAC;AAEjC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAGxD,qBAAa,iBAAiB;IAC5B;;OAEG;WACW,mBAAmB,CAC/B,UAAU,EAAE,EAAE,CAAC,UAAU,EACzB,SAAS,EAAE,SAAS,GACnB,EAAE,CAAC,SAAS,GAAG,SAAS;CAyD5B"}
\ No newline at end of file
"use strict";
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
// See LICENSE in the project root for license information.
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || (function () {
var ownKeys = function(o) {
ownKeys = Object.getOwnPropertyNames || function (o) {
var ar = [];
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
return ar;
};
return ownKeys(o);
};
return function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
__setModuleDefault(result, mod);
return result;
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.PackageDocComment = void 0;
const ts = __importStar(require("typescript"));
const ExtractorMessageId_1 = require("../api/ExtractorMessageId");
class PackageDocComment {
/**
* For the given source file, see if it starts with a TSDoc comment containing the `@packageDocumentation` tag.
*/
static tryFindInSourceFile(sourceFile, collector) {
// The @packageDocumentation comment is special because it is not attached to an AST
// definition. Instead, it is part of the "trivia" tokens that the compiler treats
// as irrelevant white space.
//
// WARNING: If the comment doesn't precede an export statement, the compiler will omit
// it from the *.d.ts file, and API Extractor won't find it. If this happens, you need
// to rearrange your statements to ensure it is passed through.
//
// This implementation assumes that the "@packageDocumentation" will be in the first TSDoc comment
// that appears in the entry point *.d.ts file. We could possibly look in other places,
// but the above warning suggests enforcing a standardized layout. This design choice is open
// to feedback.
let packageCommentRange = undefined; // empty string
for (const commentRange of ts.getLeadingCommentRanges(sourceFile.text, sourceFile.getFullStart()) || []) {
if (commentRange.kind === ts.SyntaxKind.MultiLineCommentTrivia) {
const commentBody = sourceFile.text.substring(commentRange.pos, commentRange.end);
// Choose the first JSDoc-style comment
if (/^\s*\/\*\*/.test(commentBody)) {
// But only if it looks like it's trying to be @packageDocumentation
// (The TSDoc parser will validate this more rigorously)
if (/\@packageDocumentation/i.test(commentBody)) {
packageCommentRange = commentRange;
}
break;
}
}
}
if (!packageCommentRange) {
// If we didn't find the @packageDocumentation tag in the expected place, is it in some
// wrong place? This sanity check helps people to figure out why there comment isn't working.
for (const statement of sourceFile.statements) {
const ranges = [];
ranges.push(...(ts.getLeadingCommentRanges(sourceFile.text, statement.getFullStart()) || []));
ranges.push(...(ts.getTrailingCommentRanges(sourceFile.text, statement.getEnd()) || []));
for (const commentRange of ranges) {
const commentBody = sourceFile.text.substring(commentRange.pos, commentRange.end);
if (/\@packageDocumentation/i.test(commentBody)) {
collector.messageRouter.addAnalyzerIssueForPosition(ExtractorMessageId_1.ExtractorMessageId.MisplacedPackageTag, 'The @packageDocumentation comment must appear at the top of entry point *.d.ts file', sourceFile, commentRange.pos);
break;
}
}
}
}
return packageCommentRange;
}
}
exports.PackageDocComment = PackageDocComment;
//# sourceMappingURL=PackageDocComment.js.map
\ No newline at end of file
{"version":3,"file":"PackageDocComment.js","sourceRoot":"","sources":["../../src/aedoc/PackageDocComment.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAE3D,+CAAiC;AAGjC,kEAA+D;AAE/D,MAAa,iBAAiB;IAC5B;;OAEG;IACI,MAAM,CAAC,mBAAmB,CAC/B,UAAyB,EACzB,SAAoB;QAEpB,oFAAoF;QACpF,mFAAmF;QACnF,6BAA6B;QAC7B,EAAE;QACF,sFAAsF;QACtF,uFAAuF;QACvF,+DAA+D;QAC/D,EAAE;QACF,kGAAkG;QAClG,wFAAwF;QACxF,8FAA8F;QAC9F,eAAe;QACf,IAAI,mBAAmB,GAA6B,SAAS,CAAC,CAAC,eAAe;QAE9E,KAAK,MAAM,YAAY,IAAI,EAAE,CAAC,uBAAuB,CAAC,UAAU,CAAC,IAAI,EAAE,UAAU,CAAC,YAAY,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC;YACxG,IAAI,YAAY,CAAC,IAAI,KAAK,EAAE,CAAC,UAAU,CAAC,sBAAsB,EAAE,CAAC;gBAC/D,MAAM,WAAW,GAAW,UAAU,CAAC,IAAI,CAAC,SAAS,CAAC,YAAY,CAAC,GAAG,EAAE,YAAY,CAAC,GAAG,CAAC,CAAC;gBAE1F,uCAAuC;gBACvC,IAAI,YAAY,CAAC,IAAI,CAAC,WAAW,CAAC,EAAE,CAAC;oBACnC,oEAAoE;oBACpE,wDAAwD;oBACxD,IAAI,yBAAyB,CAAC,IAAI,CAAC,WAAW,CAAC,EAAE,CAAC;wBAChD,mBAAmB,GAAG,YAAY,CAAC;oBACrC,CAAC;oBACD,MAAM;gBACR,CAAC;YACH,CAAC;QACH,CAAC;QAED,IAAI,CAAC,mBAAmB,EAAE,CAAC;YACzB,uFAAuF;YACvF,8FAA8F;YAC9F,KAAK,MAAM,SAAS,IAAI,UAAU,CAAC,UAAU,EAAE,CAAC;gBAC9C,MAAM,MAAM,GAAsB,EAAE,CAAC;gBACrC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,uBAAuB,CAAC,UAAU,CAAC,IAAI,EAAE,SAAS,CAAC,YAAY,EAAE,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC;gBAC9F,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,wBAAwB,CAAC,UAAU,CAAC,IAAI,EAAE,SAAS,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC;gBAEzF,KAAK,MAAM,YAAY,IAAI,MAAM,EAAE,CAAC;oBAClC,MAAM,WAAW,GAAW,UAAU,CAAC,IAAI,CAAC,SAAS,CAAC,YAAY,CAAC,GAAG,EAAE,YAAY,CAAC,GAAG,CAAC,CAAC;oBAE1F,IAAI,yBAAyB,CAAC,IAAI,CAAC,WAAW,CAAC,EAAE,CAAC;wBAChD,SAAS,CAAC,aAAa,CAAC,2BAA2B,CACjD,uCAAkB,CAAC,mBAAmB,EACtC,qFAAqF,EACrF,UAAU,EACV,YAAY,CAAC,GAAG,CACjB,CAAC;wBACF,MAAM;oBACR,CAAC;gBACH,CAAC;YACH,CAAC;QACH,CAAC;QAED,OAAO,mBAAmB,CAAC;IAC7B,CAAC;CACF;AAhED,8CAgEC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport * as ts from 'typescript';\n\nimport type { Collector } from '../collector/Collector';\nimport { ExtractorMessageId } from '../api/ExtractorMessageId';\n\nexport class PackageDocComment {\n /**\n * For the given source file, see if it starts with a TSDoc comment containing the `@packageDocumentation` tag.\n */\n public static tryFindInSourceFile(\n sourceFile: ts.SourceFile,\n collector: Collector\n ): ts.TextRange | undefined {\n // The @packageDocumentation comment is special because it is not attached to an AST\n // definition. Instead, it is part of the \"trivia\" tokens that the compiler treats\n // as irrelevant white space.\n //\n // WARNING: If the comment doesn't precede an export statement, the compiler will omit\n // it from the *.d.ts file, and API Extractor won't find it. If this happens, you need\n // to rearrange your statements to ensure it is passed through.\n //\n // This implementation assumes that the \"@packageDocumentation\" will be in the first TSDoc comment\n // that appears in the entry point *.d.ts file. We could possibly look in other places,\n // but the above warning suggests enforcing a standardized layout. This design choice is open\n // to feedback.\n let packageCommentRange: ts.TextRange | undefined = undefined; // empty string\n\n for (const commentRange of ts.getLeadingCommentRanges(sourceFile.text, sourceFile.getFullStart()) || []) {\n if (commentRange.kind === ts.SyntaxKind.MultiLineCommentTrivia) {\n const commentBody: string = sourceFile.text.substring(commentRange.pos, commentRange.end);\n\n // Choose the first JSDoc-style comment\n if (/^\\s*\\/\\*\\*/.test(commentBody)) {\n // But only if it looks like it's trying to be @packageDocumentation\n // (The TSDoc parser will validate this more rigorously)\n if (/\\@packageDocumentation/i.test(commentBody)) {\n packageCommentRange = commentRange;\n }\n break;\n }\n }\n }\n\n if (!packageCommentRange) {\n // If we didn't find the @packageDocumentation tag in the expected place, is it in some\n // wrong place? This sanity check helps people to figure out why there comment isn't working.\n for (const statement of sourceFile.statements) {\n const ranges: ts.CommentRange[] = [];\n ranges.push(...(ts.getLeadingCommentRanges(sourceFile.text, statement.getFullStart()) || []));\n ranges.push(...(ts.getTrailingCommentRanges(sourceFile.text, statement.getEnd()) || []));\n\n for (const commentRange of ranges) {\n const commentBody: string = sourceFile.text.substring(commentRange.pos, commentRange.end);\n\n if (/\\@packageDocumentation/i.test(commentBody)) {\n collector.messageRouter.addAnalyzerIssueForPosition(\n ExtractorMessageId.MisplacedPackageTag,\n 'The @packageDocumentation comment must appear at the top of entry point *.d.ts file',\n sourceFile,\n commentRange.pos\n );\n break;\n }\n }\n }\n }\n\n return packageCommentRange;\n }\n}\n"]}
\ No newline at end of file
import * as ts from 'typescript';
import type { AstSymbol } from './AstSymbol';
import type { AstEntity } from './AstEntity';
/**
* Constructor options for AstDeclaration
*/
export interface IAstDeclarationOptions {
readonly declaration: ts.Declaration;
readonly astSymbol: AstSymbol;
readonly parent: AstDeclaration | undefined;
}
/**
* The AstDeclaration and AstSymbol classes are API Extractor's equivalent of the compiler's
* ts.Declaration and ts.Symbol objects. They are created by the `AstSymbolTable` class.
*
* @remarks
* The AstDeclaration represents one or more syntax components of a symbol. Usually there is
* only one AstDeclaration per AstSymbol, but certain TypeScript constructs can have multiple
* declarations (e.g. overloaded functions, merged declarations, etc.).
*
* Because of this, the `AstDeclaration` manages the parent/child nesting hierarchy (e.g. with
* declaration merging, each declaration has its own children) and becomes the main focus
* of analyzing AEDoc and emitting *.d.ts files.
*
* The AstDeclarations correspond to items from the compiler's ts.Node hierarchy, but
* omitting/skipping any nodes that don't match the AstDeclaration.isSupportedSyntaxKind()
* criteria. This simplification makes the other API Extractor stages easier to implement.
*/
export declare class AstDeclaration {
readonly declaration: ts.Declaration;
readonly astSymbol: AstSymbol;
/**
* The parent, if this object is nested inside another AstDeclaration.
*/
readonly parent: AstDeclaration | undefined;
/**
* A bit set of TypeScript modifiers such as "private", "protected", etc.
*/
readonly modifierFlags: ts.ModifierFlags;
/**
* Additional information that is calculated later by the `Collector`. The actual type is `DeclarationMetadata`,
* but we declare it as `unknown` because consumers must obtain this object by calling
* `Collector.fetchDeclarationMetadata()`.
*/
declarationMetadata: unknown;
/**
* Additional information that is calculated later by the `Collector`. The actual type is `ApiItemMetadata`,
* but we declare it as `unknown` because consumers must obtain this object by calling
* `Collector.fetchApiItemMetadata()`.
*/
apiItemMetadata: unknown;
private readonly _analyzedChildren;
private readonly _analyzedReferencedAstEntitiesSet;
private _childrenByName;
constructor(options: IAstDeclarationOptions);
/**
* Returns the children for this AstDeclaration.
* @remarks
* The collection will be empty until AstSymbol.analyzed is true.
*/
get children(): ReadonlyArray<AstDeclaration>;
/**
* Returns the AstEntity objects referenced by this node.
* @remarks
* NOTE: The collection will be empty until AstSymbol.analyzed is true.
*
* Since we assume references are always collected by a traversal starting at the
* root of the nesting declarations, this array omits the following items because they
* would be redundant:
* - symbols corresponding to parents of this declaration (e.g. a method that returns its own class)
* - symbols already listed in the referencedAstSymbols property for parents of this declaration
* (e.g. a method that returns its own class's base class)
* - symbols that are referenced only by nested children of this declaration
* (e.g. if a method returns an enum, this doesn't imply that the method's class references that enum)
*/
get referencedAstEntities(): ReadonlyArray<AstEntity>;
/**
* This is an internal callback used when the AstSymbolTable attaches a new
* child AstDeclaration to this object.
* @internal
*/
_notifyChildAttach(child: AstDeclaration): void;
/**
* Returns a diagnostic dump of the tree, which reports the hierarchy of
* AstDefinition objects.
*/
getDump(indent?: string): string;
/**
* Returns a diagnostic dump using Span.getDump(), which reports the detailed
* compiler structure.
*/
getSpanDump(indent?: string): string;
/**
* This is an internal callback used when AstSymbolTable.analyze() discovers a new
* type reference associated with this declaration.
* @internal
*/
_notifyReferencedAstEntity(referencedAstEntity: AstEntity): void;
/**
* Visits all the current declaration and all children recursively in a depth-first traversal,
* and performs the specified action for each one.
*/
forEachDeclarationRecursive(action: (astDeclaration: AstDeclaration) => void): void;
/**
* Returns the list of child declarations whose `AstSymbol.localName` matches the provided `name`.
*
* @remarks
* This is an efficient O(1) lookup.
*/
findChildrenWithName(name: string): ReadonlyArray<AstDeclaration>;
/**
* This function determines which ts.Node kinds will generate an AstDeclaration.
* These correspond to the definitions that we can add AEDoc to.
*/
static isSupportedSyntaxKind(kind: ts.SyntaxKind): boolean;
}
//# sourceMappingURL=AstDeclaration.d.ts.map
\ No newline at end of file
{"version":3,"file":"AstDeclaration.d.ts","sourceRoot":"","sources":["../../src/analyzer/AstDeclaration.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,MAAM,YAAY,CAAC;AAIjC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAE7C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAE7C;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACrC,QAAQ,CAAC,WAAW,EAAE,EAAE,CAAC,WAAW,CAAC;IACrC,QAAQ,CAAC,SAAS,EAAE,SAAS,CAAC;IAC9B,QAAQ,CAAC,MAAM,EAAE,cAAc,GAAG,SAAS,CAAC;CAC7C;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,qBAAa,cAAc;IACzB,SAAgB,WAAW,EAAE,EAAE,CAAC,WAAW,CAAC;IAE5C,SAAgB,SAAS,EAAE,SAAS,CAAC;IAErC;;OAEG;IACH,SAAgB,MAAM,EAAE,cAAc,GAAG,SAAS,CAAC;IAEnD;;OAEG;IACH,SAAgB,aAAa,EAAE,EAAE,CAAC,aAAa,CAAC;IAEhD;;;;OAIG;IACI,mBAAmB,EAAE,OAAO,CAAC;IAEpC;;;;OAIG;IACI,eAAe,EAAE,OAAO,CAAC;IAGhC,OAAO,CAAC,QAAQ,CAAC,iBAAiB,CAAwB;IAE1D,OAAO,CAAC,QAAQ,CAAC,iCAAiC,CAAwC;IAG1F,OAAO,CAAC,eAAe,CAAwD;gBAE5D,OAAO,EAAE,sBAAsB;IA0BlD;;;;OAIG;IACH,IAAW,QAAQ,IAAI,aAAa,CAAC,cAAc,CAAC,CAEnD;IAED;;;;;;;;;;;;;OAaG;IACH,IAAW,qBAAqB,IAAI,aAAa,CAAC,SAAS,CAAC,CAE3D;IAED;;;;OAIG;IACI,kBAAkB,CAAC,KAAK,EAAE,cAAc,GAAG,IAAI;IAYtD;;;OAGG;IACI,OAAO,CAAC,MAAM,GAAE,MAAW,GAAG,MAAM;IAmB3C;;;OAGG;IACI,WAAW,CAAC,MAAM,GAAE,MAAW,GAAG,MAAM;IAK/C;;;;OAIG;IACI,0BAA0B,CAAC,mBAAmB,EAAE,SAAS,GAAG,IAAI;IAmBvE;;;OAGG;IACI,2BAA2B,CAAC,MAAM,EAAE,CAAC,cAAc,EAAE,cAAc,KAAK,IAAI,GAAG,IAAI;IAO1F;;;;;OAKG;IACI,oBAAoB,CAAC,IAAI,EAAE,MAAM,GAAG,aAAa,CAAC,cAAc,CAAC;IA4BxE;;;OAGG;WACW,qBAAqB,CAAC,IAAI,EAAE,EAAE,CAAC,UAAU,GAAG,OAAO;CAmClE"}
\ No newline at end of file
"use strict";
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
// See LICENSE in the project root for license information.
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || (function () {
var ownKeys = function(o) {
ownKeys = Object.getOwnPropertyNames || function (o) {
var ar = [];
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
return ar;
};
return ownKeys(o);
};
return function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
__setModuleDefault(result, mod);
return result;
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.AstDeclaration = void 0;
const ts = __importStar(require("typescript"));
const node_core_library_1 = require("@rushstack/node-core-library");
const Span_1 = require("./Span");
/**
* The AstDeclaration and AstSymbol classes are API Extractor's equivalent of the compiler's
* ts.Declaration and ts.Symbol objects. They are created by the `AstSymbolTable` class.
*
* @remarks
* The AstDeclaration represents one or more syntax components of a symbol. Usually there is
* only one AstDeclaration per AstSymbol, but certain TypeScript constructs can have multiple
* declarations (e.g. overloaded functions, merged declarations, etc.).
*
* Because of this, the `AstDeclaration` manages the parent/child nesting hierarchy (e.g. with
* declaration merging, each declaration has its own children) and becomes the main focus
* of analyzing AEDoc and emitting *.d.ts files.
*
* The AstDeclarations correspond to items from the compiler's ts.Node hierarchy, but
* omitting/skipping any nodes that don't match the AstDeclaration.isSupportedSyntaxKind()
* criteria. This simplification makes the other API Extractor stages easier to implement.
*/
class AstDeclaration {
constructor(options) {
// NOTE: This array becomes immutable after astSymbol.analyze() sets astSymbol.analyzed=true
this._analyzedChildren = [];
this._analyzedReferencedAstEntitiesSet = new Set();
// Reverse lookup used by findChildrenWithName()
this._childrenByName = undefined;
this.declaration = options.declaration;
this.astSymbol = options.astSymbol;
this.parent = options.parent;
this.astSymbol._notifyDeclarationAttach(this);
if (this.parent) {
this.parent._notifyChildAttach(this);
}
this.modifierFlags = ts.getCombinedModifierFlags(this.declaration);
// Check for ECMAScript private fields, for example:
//
// class Person { #name: string; }
//
const declarationName = ts.getNameOfDeclaration(this.declaration);
if (declarationName) {
if (ts.isPrivateIdentifier(declarationName)) {
// eslint-disable-next-line no-bitwise
this.modifierFlags |= ts.ModifierFlags.Private;
}
}
}
/**
* Returns the children for this AstDeclaration.
* @remarks
* The collection will be empty until AstSymbol.analyzed is true.
*/
get children() {
return this.astSymbol.analyzed ? this._analyzedChildren : [];
}
/**
* Returns the AstEntity objects referenced by this node.
* @remarks
* NOTE: The collection will be empty until AstSymbol.analyzed is true.
*
* Since we assume references are always collected by a traversal starting at the
* root of the nesting declarations, this array omits the following items because they
* would be redundant:
* - symbols corresponding to parents of this declaration (e.g. a method that returns its own class)
* - symbols already listed in the referencedAstSymbols property for parents of this declaration
* (e.g. a method that returns its own class's base class)
* - symbols that are referenced only by nested children of this declaration
* (e.g. if a method returns an enum, this doesn't imply that the method's class references that enum)
*/
get referencedAstEntities() {
return this.astSymbol.analyzed ? [...this._analyzedReferencedAstEntitiesSet] : [];
}
/**
* This is an internal callback used when the AstSymbolTable attaches a new
* child AstDeclaration to this object.
* @internal
*/
_notifyChildAttach(child) {
if (child.parent !== this) {
throw new node_core_library_1.InternalError('Invalid call to notifyChildAttach()');
}
if (this.astSymbol.analyzed) {
throw new node_core_library_1.InternalError('_notifyChildAttach() called after analysis is already complete');
}
this._analyzedChildren.push(child);
}
/**
* Returns a diagnostic dump of the tree, which reports the hierarchy of
* AstDefinition objects.
*/
getDump(indent = '') {
const declarationKind = ts.SyntaxKind[this.declaration.kind];
let result = indent + `+ ${this.astSymbol.localName} (${declarationKind})`;
if (this.astSymbol.nominalAnalysis) {
result += ' (nominal)';
}
result += '\n';
for (const referencedAstEntity of this._analyzedReferencedAstEntitiesSet.values()) {
result += indent + ` ref: ${referencedAstEntity.localName}\n`;
}
for (const child of this.children) {
result += child.getDump(indent + ' ');
}
return result;
}
/**
* Returns a diagnostic dump using Span.getDump(), which reports the detailed
* compiler structure.
*/
getSpanDump(indent = '') {
const span = new Span_1.Span(this.declaration);
return span.getDump(indent);
}
/**
* This is an internal callback used when AstSymbolTable.analyze() discovers a new
* type reference associated with this declaration.
* @internal
*/
_notifyReferencedAstEntity(referencedAstEntity) {
if (this.astSymbol.analyzed) {
throw new node_core_library_1.InternalError('_notifyReferencedAstEntity() called after analysis is already complete');
}
for (let current = this; current; current = current.parent) {
// Don't add references to symbols that are already referenced by a parent
if (current._analyzedReferencedAstEntitiesSet.has(referencedAstEntity)) {
return;
}
// Don't add the symbols of parents either
if (referencedAstEntity === current.astSymbol) {
return;
}
}
this._analyzedReferencedAstEntitiesSet.add(referencedAstEntity);
}
/**
* Visits all the current declaration and all children recursively in a depth-first traversal,
* and performs the specified action for each one.
*/
forEachDeclarationRecursive(action) {
action(this);
for (const child of this.children) {
child.forEachDeclarationRecursive(action);
}
}
/**
* Returns the list of child declarations whose `AstSymbol.localName` matches the provided `name`.
*
* @remarks
* This is an efficient O(1) lookup.
*/
findChildrenWithName(name) {
// The children property returns:
//
// return this.astSymbol.analyzed ? this._analyzedChildren : [];
//
if (!this.astSymbol.analyzed || this._analyzedChildren.length === 0) {
return [];
}
if (this._childrenByName === undefined) {
// Build the lookup table
const childrenByName = new Map();
for (const child of this._analyzedChildren) {
const childName = child.astSymbol.localName;
let array = childrenByName.get(childName);
if (array === undefined) {
array = [];
childrenByName.set(childName, array);
}
array.push(child);
}
this._childrenByName = childrenByName;
}
return this._childrenByName.get(name) || [];
}
/**
* This function determines which ts.Node kinds will generate an AstDeclaration.
* These correspond to the definitions that we can add AEDoc to.
*/
static isSupportedSyntaxKind(kind) {
// (alphabetical order)
switch (kind) {
case ts.SyntaxKind.CallSignature:
case ts.SyntaxKind.ClassDeclaration:
case ts.SyntaxKind.ConstructSignature: // Example: "new(x: number): IMyClass"
case ts.SyntaxKind.Constructor: // Example: "constructor(x: number)"
case ts.SyntaxKind.EnumDeclaration:
case ts.SyntaxKind.EnumMember:
case ts.SyntaxKind.FunctionDeclaration: // Example: "(x: number): number"
case ts.SyntaxKind.GetAccessor:
case ts.SyntaxKind.SetAccessor:
case ts.SyntaxKind.IndexSignature: // Example: "[key: string]: string"
case ts.SyntaxKind.InterfaceDeclaration:
case ts.SyntaxKind.MethodDeclaration:
case ts.SyntaxKind.MethodSignature:
case ts.SyntaxKind.ModuleDeclaration: // Used for both "module" and "namespace" declarations
case ts.SyntaxKind.PropertyDeclaration:
case ts.SyntaxKind.PropertySignature:
case ts.SyntaxKind.TypeAliasDeclaration: // Example: "type Shape = Circle | Square"
case ts.SyntaxKind.VariableDeclaration:
return true;
// NOTE: Prior to TypeScript 3.7, in the emitted .d.ts files, the compiler would merge a GetAccessor/SetAccessor
// pair into a single PropertyDeclaration.
// NOTE: In contexts where a source file is treated as a module, we do create "nominal analysis"
// AstSymbol objects corresponding to a ts.SyntaxKind.SourceFile node. However, a source file
// is NOT considered a nesting structure, and it does NOT act as a root for the declarations
// appearing in the file. This is because the *.d.ts generator is in the business of rolling up
// source files, and thus wants to ignore them in general.
}
return false;
}
}
exports.AstDeclaration = AstDeclaration;
//# sourceMappingURL=AstDeclaration.js.map
\ No newline at end of file
{"version":3,"file":"AstDeclaration.js","sourceRoot":"","sources":["../../src/analyzer/AstDeclaration.ts"],"names":[],"mappings":"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","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport * as ts from 'typescript';\n\nimport { InternalError } from '@rushstack/node-core-library';\n\nimport type { AstSymbol } from './AstSymbol';\nimport { Span } from './Span';\nimport type { AstEntity } from './AstEntity';\n\n/**\n * Constructor options for AstDeclaration\n */\nexport interface IAstDeclarationOptions {\n readonly declaration: ts.Declaration;\n readonly astSymbol: AstSymbol;\n readonly parent: AstDeclaration | undefined;\n}\n\n/**\n * The AstDeclaration and AstSymbol classes are API Extractor's equivalent of the compiler's\n * ts.Declaration and ts.Symbol objects. They are created by the `AstSymbolTable` class.\n *\n * @remarks\n * The AstDeclaration represents one or more syntax components of a symbol. Usually there is\n * only one AstDeclaration per AstSymbol, but certain TypeScript constructs can have multiple\n * declarations (e.g. overloaded functions, merged declarations, etc.).\n *\n * Because of this, the `AstDeclaration` manages the parent/child nesting hierarchy (e.g. with\n * declaration merging, each declaration has its own children) and becomes the main focus\n * of analyzing AEDoc and emitting *.d.ts files.\n *\n * The AstDeclarations correspond to items from the compiler's ts.Node hierarchy, but\n * omitting/skipping any nodes that don't match the AstDeclaration.isSupportedSyntaxKind()\n * criteria. This simplification makes the other API Extractor stages easier to implement.\n */\nexport class AstDeclaration {\n public readonly declaration: ts.Declaration;\n\n public readonly astSymbol: AstSymbol;\n\n /**\n * The parent, if this object is nested inside another AstDeclaration.\n */\n public readonly parent: AstDeclaration | undefined;\n\n /**\n * A bit set of TypeScript modifiers such as \"private\", \"protected\", etc.\n */\n public readonly modifierFlags: ts.ModifierFlags;\n\n /**\n * Additional information that is calculated later by the `Collector`. The actual type is `DeclarationMetadata`,\n * but we declare it as `unknown` because consumers must obtain this object by calling\n * `Collector.fetchDeclarationMetadata()`.\n */\n public declarationMetadata: unknown;\n\n /**\n * Additional information that is calculated later by the `Collector`. The actual type is `ApiItemMetadata`,\n * but we declare it as `unknown` because consumers must obtain this object by calling\n * `Collector.fetchApiItemMetadata()`.\n */\n public apiItemMetadata: unknown;\n\n // NOTE: This array becomes immutable after astSymbol.analyze() sets astSymbol.analyzed=true\n private readonly _analyzedChildren: AstDeclaration[] = [];\n\n private readonly _analyzedReferencedAstEntitiesSet: Set<AstEntity> = new Set<AstEntity>();\n\n // Reverse lookup used by findChildrenWithName()\n private _childrenByName: Map<string, AstDeclaration[]> | undefined = undefined;\n\n public constructor(options: IAstDeclarationOptions) {\n this.declaration = options.declaration;\n this.astSymbol = options.astSymbol;\n this.parent = options.parent;\n\n this.astSymbol._notifyDeclarationAttach(this);\n\n if (this.parent) {\n this.parent._notifyChildAttach(this);\n }\n\n this.modifierFlags = ts.getCombinedModifierFlags(this.declaration);\n\n // Check for ECMAScript private fields, for example:\n //\n // class Person { #name: string; }\n //\n const declarationName: ts.DeclarationName | undefined = ts.getNameOfDeclaration(this.declaration);\n if (declarationName) {\n if (ts.isPrivateIdentifier(declarationName)) {\n // eslint-disable-next-line no-bitwise\n this.modifierFlags |= ts.ModifierFlags.Private;\n }\n }\n }\n\n /**\n * Returns the children for this AstDeclaration.\n * @remarks\n * The collection will be empty until AstSymbol.analyzed is true.\n */\n public get children(): ReadonlyArray<AstDeclaration> {\n return this.astSymbol.analyzed ? this._analyzedChildren : [];\n }\n\n /**\n * Returns the AstEntity objects referenced by this node.\n * @remarks\n * NOTE: The collection will be empty until AstSymbol.analyzed is true.\n *\n * Since we assume references are always collected by a traversal starting at the\n * root of the nesting declarations, this array omits the following items because they\n * would be redundant:\n * - symbols corresponding to parents of this declaration (e.g. a method that returns its own class)\n * - symbols already listed in the referencedAstSymbols property for parents of this declaration\n * (e.g. a method that returns its own class's base class)\n * - symbols that are referenced only by nested children of this declaration\n * (e.g. if a method returns an enum, this doesn't imply that the method's class references that enum)\n */\n public get referencedAstEntities(): ReadonlyArray<AstEntity> {\n return this.astSymbol.analyzed ? [...this._analyzedReferencedAstEntitiesSet] : [];\n }\n\n /**\n * This is an internal callback used when the AstSymbolTable attaches a new\n * child AstDeclaration to this object.\n * @internal\n */\n public _notifyChildAttach(child: AstDeclaration): void {\n if (child.parent !== this) {\n throw new InternalError('Invalid call to notifyChildAttach()');\n }\n\n if (this.astSymbol.analyzed) {\n throw new InternalError('_notifyChildAttach() called after analysis is already complete');\n }\n\n this._analyzedChildren.push(child);\n }\n\n /**\n * Returns a diagnostic dump of the tree, which reports the hierarchy of\n * AstDefinition objects.\n */\n public getDump(indent: string = ''): string {\n const declarationKind: string = ts.SyntaxKind[this.declaration.kind];\n let result: string = indent + `+ ${this.astSymbol.localName} (${declarationKind})`;\n if (this.astSymbol.nominalAnalysis) {\n result += ' (nominal)';\n }\n result += '\\n';\n\n for (const referencedAstEntity of this._analyzedReferencedAstEntitiesSet.values()) {\n result += indent + ` ref: ${referencedAstEntity.localName}\\n`;\n }\n\n for (const child of this.children) {\n result += child.getDump(indent + ' ');\n }\n\n return result;\n }\n\n /**\n * Returns a diagnostic dump using Span.getDump(), which reports the detailed\n * compiler structure.\n */\n public getSpanDump(indent: string = ''): string {\n const span: Span = new Span(this.declaration);\n return span.getDump(indent);\n }\n\n /**\n * This is an internal callback used when AstSymbolTable.analyze() discovers a new\n * type reference associated with this declaration.\n * @internal\n */\n public _notifyReferencedAstEntity(referencedAstEntity: AstEntity): void {\n if (this.astSymbol.analyzed) {\n throw new InternalError('_notifyReferencedAstEntity() called after analysis is already complete');\n }\n\n for (let current: AstDeclaration | undefined = this; current; current = current.parent) {\n // Don't add references to symbols that are already referenced by a parent\n if (current._analyzedReferencedAstEntitiesSet.has(referencedAstEntity)) {\n return;\n }\n // Don't add the symbols of parents either\n if (referencedAstEntity === current.astSymbol) {\n return;\n }\n }\n\n this._analyzedReferencedAstEntitiesSet.add(referencedAstEntity);\n }\n\n /**\n * Visits all the current declaration and all children recursively in a depth-first traversal,\n * and performs the specified action for each one.\n */\n public forEachDeclarationRecursive(action: (astDeclaration: AstDeclaration) => void): void {\n action(this);\n for (const child of this.children) {\n child.forEachDeclarationRecursive(action);\n }\n }\n\n /**\n * Returns the list of child declarations whose `AstSymbol.localName` matches the provided `name`.\n *\n * @remarks\n * This is an efficient O(1) lookup.\n */\n public findChildrenWithName(name: string): ReadonlyArray<AstDeclaration> {\n // The children property returns:\n //\n // return this.astSymbol.analyzed ? this._analyzedChildren : [];\n //\n if (!this.astSymbol.analyzed || this._analyzedChildren.length === 0) {\n return [];\n }\n\n if (this._childrenByName === undefined) {\n // Build the lookup table\n const childrenByName: Map<string, AstDeclaration[]> = new Map<string, AstDeclaration[]>();\n\n for (const child of this._analyzedChildren) {\n const childName: string = child.astSymbol.localName;\n let array: AstDeclaration[] | undefined = childrenByName.get(childName);\n if (array === undefined) {\n array = [];\n childrenByName.set(childName, array);\n }\n array.push(child);\n }\n this._childrenByName = childrenByName;\n }\n\n return this._childrenByName.get(name) || [];\n }\n\n /**\n * This function determines which ts.Node kinds will generate an AstDeclaration.\n * These correspond to the definitions that we can add AEDoc to.\n */\n public static isSupportedSyntaxKind(kind: ts.SyntaxKind): boolean {\n // (alphabetical order)\n switch (kind) {\n case ts.SyntaxKind.CallSignature:\n case ts.SyntaxKind.ClassDeclaration:\n case ts.SyntaxKind.ConstructSignature: // Example: \"new(x: number): IMyClass\"\n case ts.SyntaxKind.Constructor: // Example: \"constructor(x: number)\"\n case ts.SyntaxKind.EnumDeclaration:\n case ts.SyntaxKind.EnumMember:\n case ts.SyntaxKind.FunctionDeclaration: // Example: \"(x: number): number\"\n case ts.SyntaxKind.GetAccessor:\n case ts.SyntaxKind.SetAccessor:\n case ts.SyntaxKind.IndexSignature: // Example: \"[key: string]: string\"\n case ts.SyntaxKind.InterfaceDeclaration:\n case ts.SyntaxKind.MethodDeclaration:\n case ts.SyntaxKind.MethodSignature:\n case ts.SyntaxKind.ModuleDeclaration: // Used for both \"module\" and \"namespace\" declarations\n case ts.SyntaxKind.PropertyDeclaration:\n case ts.SyntaxKind.PropertySignature:\n case ts.SyntaxKind.TypeAliasDeclaration: // Example: \"type Shape = Circle | Square\"\n case ts.SyntaxKind.VariableDeclaration:\n return true;\n\n // NOTE: Prior to TypeScript 3.7, in the emitted .d.ts files, the compiler would merge a GetAccessor/SetAccessor\n // pair into a single PropertyDeclaration.\n\n // NOTE: In contexts where a source file is treated as a module, we do create \"nominal analysis\"\n // AstSymbol objects corresponding to a ts.SyntaxKind.SourceFile node. However, a source file\n // is NOT considered a nesting structure, and it does NOT act as a root for the declarations\n // appearing in the file. This is because the *.d.ts generator is in the business of rolling up\n // source files, and thus wants to ignore them in general.\n }\n\n return false;\n }\n}\n"]}
\ No newline at end of file
/**
* `AstEntity` is the abstract base class for analyzer objects that can become a `CollectorEntity`.
*
* @remarks
*
* The subclasses are:
* ```
* - AstEntity
* - AstSymbol
* - AstSyntheticEntity
* - AstImport
* - AstNamespaceImport
* ```
*/
export declare abstract class AstEntity {
/**
* The original name of the symbol, as exported from the module (i.e. source file)
* containing the original TypeScript definition. Constructs such as
* `import { X as Y } from` may introduce other names that differ from the local name.
*
* @remarks
* For the most part, `localName` corresponds to `followedSymbol.name`, but there
* are some edge cases. For example, the ts.Symbol.name for `export default class X { }`
* is actually `"default"`, not `"X"`.
*/
abstract readonly localName: string;
}
/**
* `AstSyntheticEntity` is the abstract base class for analyzer objects whose emitted declarations
* are not text transformations performed by the `Span` helper.
*
* @remarks
* Most of API Extractor's output is produced by using the using the `Span` utility to regurgitate strings from
* the input .d.ts files. If we need to rename an identifier, the `Span` visitor can pick out an interesting
* node and rewrite its string, but otherwise the transformation operates on dumb text and not compiler concepts.
* (Historically we did this because the compiler's emitter was an internal API, but it still has some advantages,
* for example preserving syntaxes generated by an older compiler to avoid incompatibilities.)
*
* This strategy does not work for cases where the output looks very different from the input. Today these
* cases are always kinds of `import` statements, but that may change in the future.
*/
export declare abstract class AstSyntheticEntity extends AstEntity {
}
//# sourceMappingURL=AstEntity.d.ts.map
\ No newline at end of file
{"version":3,"file":"AstEntity.d.ts","sourceRoot":"","sources":["../../src/analyzer/AstEntity.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;GAaG;AACH,8BAAsB,SAAS;IAC7B;;;;;;;;;OASG;IACH,kBAAyB,SAAS,EAAE,MAAM,CAAC;CAC5C;AAED;;;;;;;;;;;;;GAaG;AACH,8BAAsB,kBAAmB,SAAQ,SAAS;CAAG"}
\ No newline at end of file
"use strict";
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
// See LICENSE in the project root for license information.
Object.defineProperty(exports, "__esModule", { value: true });
exports.AstSyntheticEntity = exports.AstEntity = void 0;
/**
* `AstEntity` is the abstract base class for analyzer objects that can become a `CollectorEntity`.
*
* @remarks
*
* The subclasses are:
* ```
* - AstEntity
* - AstSymbol
* - AstSyntheticEntity
* - AstImport
* - AstNamespaceImport
* ```
*/
class AstEntity {
}
exports.AstEntity = AstEntity;
/**
* `AstSyntheticEntity` is the abstract base class for analyzer objects whose emitted declarations
* are not text transformations performed by the `Span` helper.
*
* @remarks
* Most of API Extractor's output is produced by using the using the `Span` utility to regurgitate strings from
* the input .d.ts files. If we need to rename an identifier, the `Span` visitor can pick out an interesting
* node and rewrite its string, but otherwise the transformation operates on dumb text and not compiler concepts.
* (Historically we did this because the compiler's emitter was an internal API, but it still has some advantages,
* for example preserving syntaxes generated by an older compiler to avoid incompatibilities.)
*
* This strategy does not work for cases where the output looks very different from the input. Today these
* cases are always kinds of `import` statements, but that may change in the future.
*/
class AstSyntheticEntity extends AstEntity {
}
exports.AstSyntheticEntity = AstSyntheticEntity;
//# sourceMappingURL=AstEntity.js.map
\ No newline at end of file
{"version":3,"file":"AstEntity.js","sourceRoot":"","sources":["../../src/analyzer/AstEntity.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAE3D;;;;;;;;;;;;;GAaG;AACH,MAAsB,SAAS;CAY9B;AAZD,8BAYC;AAED;;;;;;;;;;;;;GAaG;AACH,MAAsB,kBAAmB,SAAQ,SAAS;CAAG;AAA7D,gDAA6D","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\n/**\n * `AstEntity` is the abstract base class for analyzer objects that can become a `CollectorEntity`.\n *\n * @remarks\n *\n * The subclasses are:\n * ```\n * - AstEntity\n * - AstSymbol\n * - AstSyntheticEntity\n * - AstImport\n * - AstNamespaceImport\n * ```\n */\nexport abstract class AstEntity {\n /**\n * The original name of the symbol, as exported from the module (i.e. source file)\n * containing the original TypeScript definition. Constructs such as\n * `import { X as Y } from` may introduce other names that differ from the local name.\n *\n * @remarks\n * For the most part, `localName` corresponds to `followedSymbol.name`, but there\n * are some edge cases. For example, the ts.Symbol.name for `export default class X { }`\n * is actually `\"default\"`, not `\"X\"`.\n */\n public abstract readonly localName: string;\n}\n\n/**\n * `AstSyntheticEntity` is the abstract base class for analyzer objects whose emitted declarations\n * are not text transformations performed by the `Span` helper.\n *\n * @remarks\n * Most of API Extractor's output is produced by using the using the `Span` utility to regurgitate strings from\n * the input .d.ts files. If we need to rename an identifier, the `Span` visitor can pick out an interesting\n * node and rewrite its string, but otherwise the transformation operates on dumb text and not compiler concepts.\n * (Historically we did this because the compiler's emitter was an internal API, but it still has some advantages,\n * for example preserving syntaxes generated by an older compiler to avoid incompatibilities.)\n *\n * This strategy does not work for cases where the output looks very different from the input. Today these\n * cases are always kinds of `import` statements, but that may change in the future.\n */\nexport abstract class AstSyntheticEntity extends AstEntity {}\n"]}
\ No newline at end of file
import type { AstSymbol } from './AstSymbol';
import { AstSyntheticEntity } from './AstEntity';
/**
* Indicates the import kind for an `AstImport`.
*/
export declare enum AstImportKind {
/**
* An import statement such as `import X from "y";`.
*/
DefaultImport = 0,
/**
* An import statement such as `import { X } from "y";`.
*/
NamedImport = 1,
/**
* An import statement such as `import * as x from "y";`.
*/
StarImport = 2,
/**
* An import statement such as `import x = require("y");`.
*/
EqualsImport = 3,
/**
* An import statement such as `interface foo { foo: import("bar").a.b.c }`.
*/
ImportType = 4
}
/**
* Constructor parameters for AstImport
*
* @privateRemarks
* Our naming convention is to use I____Parameters for constructor options and
* I____Options for general function options. However the word "parameters" is
* confusingly similar to the terminology for function parameters modeled by API Extractor,
* so we use I____Options for both cases in this code base.
*/
export interface IAstImportOptions {
readonly importKind: AstImportKind;
readonly modulePath: string;
readonly exportName: string;
readonly isTypeOnly: boolean;
}
/**
* For a symbol that was imported from an external package, this tracks the import
* statement that was used to reach it.
*/
export declare class AstImport extends AstSyntheticEntity {
readonly importKind: AstImportKind;
/**
* The name of the external package (and possibly module path) that this definition
* was imported from.
*
* Example: "@rushstack/node-core-library/lib/FileSystem"
*/
readonly modulePath: string;
/**
* The name of the symbol being imported.
*
* @remarks
*
* The name depends on the type of import:
*
* ```ts
* // For AstImportKind.DefaultImport style, exportName would be "X" in this example:
* import X from "y";
*
* // For AstImportKind.NamedImport style, exportName would be "X" in this example:
* import { X } from "y";
*
* // For AstImportKind.StarImport style, exportName would be "x" in this example:
* import * as x from "y";
*
* // For AstImportKind.EqualsImport style, exportName would be "x" in this example:
* import x = require("y");
*
* // For AstImportKind.ImportType style, exportName would be "a.b.c" in this example:
* interface foo { foo: import('bar').a.b.c };
* ```
*/
readonly exportName: string;
/**
* Whether it is a type-only import, for example:
*
* ```ts
* import type { X } from "y";
* ```
*
* This is set to true ONLY if the type-only form is used in *every* reference to this AstImport.
*/
isTypeOnlyEverywhere: boolean;
/**
* If this import statement refers to an API from an external package that is tracked by API Extractor
* (according to `PackageMetadataManager.isAedocSupportedFor()`), then this property will return the
* corresponding AstSymbol. Otherwise, it is undefined.
*/
astSymbol: AstSymbol | undefined;
/**
* If modulePath and exportName are defined, then this is a dictionary key
* that combines them with a colon (":").
*
* Example: "@rushstack/node-core-library/lib/FileSystem:FileSystem"
*/
readonly key: string;
constructor(options: IAstImportOptions);
/** {@inheritdoc} */
get localName(): string;
/**
* Calculates the lookup key used with `AstImport.key`
*/
static getKey(options: IAstImportOptions): string;
}
//# sourceMappingURL=AstImport.d.ts.map
\ No newline at end of file
{"version":3,"file":"AstImport.d.ts","sourceRoot":"","sources":["../../src/analyzer/AstImport.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAEjD;;GAEG;AACH,oBAAY,aAAa;IACvB;;OAEG;IACH,aAAa,IAAA;IAEb;;OAEG;IACH,WAAW,IAAA;IAEX;;OAEG;IACH,UAAU,IAAA;IAEV;;OAEG;IACH,YAAY,IAAA;IAEZ;;OAEG;IACH,UAAU,IAAA;CACX;AAED;;;;;;;;GAQG;AACH,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,UAAU,EAAE,aAAa,CAAC;IACnC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAC;CAC9B;AAED;;;GAGG;AACH,qBAAa,SAAU,SAAQ,kBAAkB;IAC/C,SAAgB,UAAU,EAAE,aAAa,CAAC;IAE1C;;;;;OAKG;IACH,SAAgB,UAAU,EAAE,MAAM,CAAC;IAEnC;;;;;;;;;;;;;;;;;;;;;;;OAuBG;IACH,SAAgB,UAAU,EAAE,MAAM,CAAC;IAEnC;;;;;;;;OAQG;IACI,oBAAoB,EAAE,OAAO,CAAC;IAErC;;;;OAIG;IACI,SAAS,EAAE,SAAS,GAAG,SAAS,CAAC;IAExC;;;;;OAKG;IACH,SAAgB,GAAG,EAAE,MAAM,CAAC;gBAET,OAAO,EAAE,iBAAiB;IAa7C,oBAAoB;IACpB,IAAW,SAAS,IAAI,MAAM,CAG7B;IAED;;OAEG;WACW,MAAM,CAAC,OAAO,EAAE,iBAAiB,GAAG,MAAM;CAsBzD"}
\ No newline at end of file
"use strict";
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
// See LICENSE in the project root for license information.
Object.defineProperty(exports, "__esModule", { value: true });
exports.AstImport = exports.AstImportKind = void 0;
const node_core_library_1 = require("@rushstack/node-core-library");
const AstEntity_1 = require("./AstEntity");
/**
* Indicates the import kind for an `AstImport`.
*/
var AstImportKind;
(function (AstImportKind) {
/**
* An import statement such as `import X from "y";`.
*/
AstImportKind[AstImportKind["DefaultImport"] = 0] = "DefaultImport";
/**
* An import statement such as `import { X } from "y";`.
*/
AstImportKind[AstImportKind["NamedImport"] = 1] = "NamedImport";
/**
* An import statement such as `import * as x from "y";`.
*/
AstImportKind[AstImportKind["StarImport"] = 2] = "StarImport";
/**
* An import statement such as `import x = require("y");`.
*/
AstImportKind[AstImportKind["EqualsImport"] = 3] = "EqualsImport";
/**
* An import statement such as `interface foo { foo: import("bar").a.b.c }`.
*/
AstImportKind[AstImportKind["ImportType"] = 4] = "ImportType";
})(AstImportKind || (exports.AstImportKind = AstImportKind = {}));
/**
* For a symbol that was imported from an external package, this tracks the import
* statement that was used to reach it.
*/
class AstImport extends AstEntity_1.AstSyntheticEntity {
constructor(options) {
super();
this.importKind = options.importKind;
this.modulePath = options.modulePath;
this.exportName = options.exportName;
// We start with this assumption, but it may get changed later if non-type-only import is encountered.
this.isTypeOnlyEverywhere = options.isTypeOnly;
this.key = AstImport.getKey(options);
}
/** {@inheritdoc} */
get localName() {
// abstract
return this.exportName;
}
/**
* Calculates the lookup key used with `AstImport.key`
*/
static getKey(options) {
switch (options.importKind) {
case AstImportKind.DefaultImport:
return `${options.modulePath}:${options.exportName}`;
case AstImportKind.NamedImport:
return `${options.modulePath}:${options.exportName}`;
case AstImportKind.StarImport:
return `${options.modulePath}:*`;
case AstImportKind.EqualsImport:
return `${options.modulePath}:=`;
case AstImportKind.ImportType: {
const subKey = !options.exportName
? '*' // Equivalent to StarImport
: options.exportName.includes('.') // Equivalent to a named export
? options.exportName.split('.')[0]
: options.exportName;
return `${options.modulePath}:${subKey}`;
}
default:
throw new node_core_library_1.InternalError('Unknown AstImportKind');
}
}
}
exports.AstImport = AstImport;
//# sourceMappingURL=AstImport.js.map
\ No newline at end of file
{"version":3,"file":"AstImport.js","sourceRoot":"","sources":["../../src/analyzer/AstImport.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAE3D,oEAA6D;AAG7D,2CAAiD;AAEjD;;GAEG;AACH,IAAY,aAyBX;AAzBD,WAAY,aAAa;IACvB;;OAEG;IACH,mEAAa,CAAA;IAEb;;OAEG;IACH,+DAAW,CAAA;IAEX;;OAEG;IACH,6DAAU,CAAA;IAEV;;OAEG;IACH,iEAAY,CAAA;IAEZ;;OAEG;IACH,6DAAU,CAAA;AACZ,CAAC,EAzBW,aAAa,6BAAb,aAAa,QAyBxB;AAkBD;;;GAGG;AACH,MAAa,SAAU,SAAQ,8BAAkB;IA+D/C,YAAmB,OAA0B;QAC3C,KAAK,EAAE,CAAC;QAER,IAAI,CAAC,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC;QACrC,IAAI,CAAC,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC;QACrC,IAAI,CAAC,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC;QAErC,sGAAsG;QACtG,IAAI,CAAC,oBAAoB,GAAG,OAAO,CAAC,UAAU,CAAC;QAE/C,IAAI,CAAC,GAAG,GAAG,SAAS,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IACvC,CAAC;IAED,oBAAoB;IACpB,IAAW,SAAS;QAClB,WAAW;QACX,OAAO,IAAI,CAAC,UAAU,CAAC;IACzB,CAAC;IAED;;OAEG;IACI,MAAM,CAAC,MAAM,CAAC,OAA0B;QAC7C,QAAQ,OAAO,CAAC,UAAU,EAAE,CAAC;YAC3B,KAAK,aAAa,CAAC,aAAa;gBAC9B,OAAO,GAAG,OAAO,CAAC,UAAU,IAAI,OAAO,CAAC,UAAU,EAAE,CAAC;YACvD,KAAK,aAAa,CAAC,WAAW;gBAC5B,OAAO,GAAG,OAAO,CAAC,UAAU,IAAI,OAAO,CAAC,UAAU,EAAE,CAAC;YACvD,KAAK,aAAa,CAAC,UAAU;gBAC3B,OAAO,GAAG,OAAO,CAAC,UAAU,IAAI,CAAC;YACnC,KAAK,aAAa,CAAC,YAAY;gBAC7B,OAAO,GAAG,OAAO,CAAC,UAAU,IAAI,CAAC;YACnC,KAAK,aAAa,CAAC,UAAU,CAAC,CAAC,CAAC;gBAC9B,MAAM,MAAM,GAAW,CAAC,OAAO,CAAC,UAAU;oBACxC,CAAC,CAAC,GAAG,CAAC,2BAA2B;oBACjC,CAAC,CAAC,OAAO,CAAC,UAAU,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,+BAA+B;wBAChE,CAAC,CAAC,OAAO,CAAC,UAAU,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;wBAClC,CAAC,CAAC,OAAO,CAAC,UAAU,CAAC;gBACzB,OAAO,GAAG,OAAO,CAAC,UAAU,IAAI,MAAM,EAAE,CAAC;YAC3C,CAAC;YACD;gBACE,MAAM,IAAI,iCAAa,CAAC,uBAAuB,CAAC,CAAC;QACrD,CAAC;IACH,CAAC;CACF;AA3GD,8BA2GC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport { InternalError } from '@rushstack/node-core-library';\n\nimport type { AstSymbol } from './AstSymbol';\nimport { AstSyntheticEntity } from './AstEntity';\n\n/**\n * Indicates the import kind for an `AstImport`.\n */\nexport enum AstImportKind {\n /**\n * An import statement such as `import X from \"y\";`.\n */\n DefaultImport,\n\n /**\n * An import statement such as `import { X } from \"y\";`.\n */\n NamedImport,\n\n /**\n * An import statement such as `import * as x from \"y\";`.\n */\n StarImport,\n\n /**\n * An import statement such as `import x = require(\"y\");`.\n */\n EqualsImport,\n\n /**\n * An import statement such as `interface foo { foo: import(\"bar\").a.b.c }`.\n */\n ImportType\n}\n\n/**\n * Constructor parameters for AstImport\n *\n * @privateRemarks\n * Our naming convention is to use I____Parameters for constructor options and\n * I____Options for general function options. However the word \"parameters\" is\n * confusingly similar to the terminology for function parameters modeled by API Extractor,\n * so we use I____Options for both cases in this code base.\n */\nexport interface IAstImportOptions {\n readonly importKind: AstImportKind;\n readonly modulePath: string;\n readonly exportName: string;\n readonly isTypeOnly: boolean;\n}\n\n/**\n * For a symbol that was imported from an external package, this tracks the import\n * statement that was used to reach it.\n */\nexport class AstImport extends AstSyntheticEntity {\n public readonly importKind: AstImportKind;\n\n /**\n * The name of the external package (and possibly module path) that this definition\n * was imported from.\n *\n * Example: \"@rushstack/node-core-library/lib/FileSystem\"\n */\n public readonly modulePath: string;\n\n /**\n * The name of the symbol being imported.\n *\n * @remarks\n *\n * The name depends on the type of import:\n *\n * ```ts\n * // For AstImportKind.DefaultImport style, exportName would be \"X\" in this example:\n * import X from \"y\";\n *\n * // For AstImportKind.NamedImport style, exportName would be \"X\" in this example:\n * import { X } from \"y\";\n *\n * // For AstImportKind.StarImport style, exportName would be \"x\" in this example:\n * import * as x from \"y\";\n *\n * // For AstImportKind.EqualsImport style, exportName would be \"x\" in this example:\n * import x = require(\"y\");\n *\n * // For AstImportKind.ImportType style, exportName would be \"a.b.c\" in this example:\n * interface foo { foo: import('bar').a.b.c };\n * ```\n */\n public readonly exportName: string;\n\n /**\n * Whether it is a type-only import, for example:\n *\n * ```ts\n * import type { X } from \"y\";\n * ```\n *\n * This is set to true ONLY if the type-only form is used in *every* reference to this AstImport.\n */\n public isTypeOnlyEverywhere: boolean;\n\n /**\n * If this import statement refers to an API from an external package that is tracked by API Extractor\n * (according to `PackageMetadataManager.isAedocSupportedFor()`), then this property will return the\n * corresponding AstSymbol. Otherwise, it is undefined.\n */\n public astSymbol: AstSymbol | undefined;\n\n /**\n * If modulePath and exportName are defined, then this is a dictionary key\n * that combines them with a colon (\":\").\n *\n * Example: \"@rushstack/node-core-library/lib/FileSystem:FileSystem\"\n */\n public readonly key: string;\n\n public constructor(options: IAstImportOptions) {\n super();\n\n this.importKind = options.importKind;\n this.modulePath = options.modulePath;\n this.exportName = options.exportName;\n\n // We start with this assumption, but it may get changed later if non-type-only import is encountered.\n this.isTypeOnlyEverywhere = options.isTypeOnly;\n\n this.key = AstImport.getKey(options);\n }\n\n /** {@inheritdoc} */\n public get localName(): string {\n // abstract\n return this.exportName;\n }\n\n /**\n * Calculates the lookup key used with `AstImport.key`\n */\n public static getKey(options: IAstImportOptions): string {\n switch (options.importKind) {\n case AstImportKind.DefaultImport:\n return `${options.modulePath}:${options.exportName}`;\n case AstImportKind.NamedImport:\n return `${options.modulePath}:${options.exportName}`;\n case AstImportKind.StarImport:\n return `${options.modulePath}:*`;\n case AstImportKind.EqualsImport:\n return `${options.modulePath}:=`;\n case AstImportKind.ImportType: {\n const subKey: string = !options.exportName\n ? '*' // Equivalent to StarImport\n : options.exportName.includes('.') // Equivalent to a named export\n ? options.exportName.split('.')[0]\n : options.exportName;\n return `${options.modulePath}:${subKey}`;\n }\n default:\n throw new InternalError('Unknown AstImportKind');\n }\n }\n}\n"]}
\ No newline at end of file
import type * as ts from 'typescript';
import type { AstEntity } from './AstEntity';
/**
* Represents information collected by {@link AstSymbolTable.fetchAstModuleExportInfo}
*/
export interface IAstModuleExportInfo {
readonly visitedAstModules: Set<AstModule>;
readonly exportedLocalEntities: Map<string, AstEntity>;
readonly starExportedExternalModules: Set<AstModule>;
}
/**
* Constructor parameters for AstModule
*
* @privateRemarks
* Our naming convention is to use I____Parameters for constructor options and
* I____Options for general function options. However the word "parameters" is
* confusingly similar to the terminology for function parameters modeled by API Extractor,
* so we use I____Options for both cases in this code base.
*/
export interface IAstModuleOptions {
sourceFile: ts.SourceFile;
moduleSymbol: ts.Symbol;
externalModulePath: string | undefined;
}
/**
* An internal data structure that represents a source file that is analyzed by AstSymbolTable.
*/
export declare class AstModule {
/**
* The source file that declares this TypeScript module. In most cases, the source file's
* top-level exports constitute the module.
*/
readonly sourceFile: ts.SourceFile;
/**
* The symbol for the module. Typically this corresponds to ts.SourceFile itself, however
* in some cases the ts.SourceFile may contain multiple modules declared using the `module` keyword.
*/
readonly moduleSymbol: ts.Symbol;
/**
* Example: "@rushstack/node-core-library/lib/FileSystem"
* but never: "./FileSystem"
*/
readonly externalModulePath: string | undefined;
/**
* A list of other `AstModule` objects that appear in `export * from "___";` statements.
*/
readonly starExportedModules: Set<AstModule>;
/**
* A partial map of entities exported by this module. The key is the exported name.
*/
readonly cachedExportedEntities: Map<string, AstEntity>;
/**
* Additional state calculated by `AstSymbolTable.fetchWorkingPackageModule()`.
*/
astModuleExportInfo: IAstModuleExportInfo | undefined;
constructor(options: IAstModuleOptions);
/**
* If false, then this source file is part of the working package being processed by the `Collector`.
*/
get isExternal(): boolean;
}
//# sourceMappingURL=AstModule.d.ts.map
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment