1 | /**
|
2 | * API Extractor helps with validation, documentation, and reviewing of the exported API for a TypeScript library.
|
3 | * The `@microsoft/api-extractor` package provides the command-line tool. It also exposes a developer API that you
|
4 | * can use to invoke API Extractor programmatically.
|
5 | *
|
6 | * @packageDocumentation
|
7 | */
|
8 |
|
9 | import { EnumMemberOrder } from '@microsoft/api-extractor-model';
|
10 | import { INodePackageJson } from '@rushstack/node-core-library';
|
11 | import { IRigConfig } from '@rushstack/rig-package';
|
12 | import { JsonSchema } from '@rushstack/node-core-library';
|
13 | import { NewlineKind } from '@rushstack/node-core-library';
|
14 | import { PackageJsonLookup } from '@rushstack/node-core-library';
|
15 | import type * as tsdoc from '@microsoft/tsdoc';
|
16 | import { TSDocConfigFile } from '@microsoft/tsdoc-config';
|
17 | import { TSDocConfiguration } from '@microsoft/tsdoc';
|
18 |
|
19 | /**
|
20 | * The allowed variations of API reports.
|
21 | *
|
22 | * @public
|
23 | */
|
24 | export declare type ApiReportVariant = 'public' | 'beta' | 'alpha' | 'complete';
|
25 |
|
26 | /**
|
27 | * This class represents the TypeScript compiler state. This allows an optimization where multiple invocations
|
28 | * of API Extractor can reuse the same TypeScript compiler analysis.
|
29 | *
|
30 | * @public
|
31 | */
|
32 | export declare class CompilerState {
|
33 | /**
|
34 | * The TypeScript compiler's `Program` object, which represents a complete scope of analysis.
|
35 | */
|
36 | readonly program: unknown;
|
37 | private constructor();
|
38 | /**
|
39 | * Create a compiler state for use with the specified `IExtractorInvokeOptions`.
|
40 | */
|
41 | static create(extractorConfig: ExtractorConfig, options?: ICompilerStateCreateOptions): CompilerState;
|
42 | /**
|
43 | * Given a list of absolute file paths, return a list containing only the declaration
|
44 | * files. Duplicates are also eliminated.
|
45 | *
|
46 | * @remarks
|
47 | * The tsconfig.json settings specify the compiler's input (a set of *.ts source files,
|
48 | * plus some *.d.ts declaration files used for legacy typings). However API Extractor
|
49 | * analyzes the compiler's output (a set of *.d.ts entry point files, plus any legacy
|
50 | * typings). This requires API Extractor to generate a special file list when it invokes
|
51 | * the compiler.
|
52 | *
|
53 | * Duplicates are removed so that entry points can be appended without worrying whether they
|
54 | * may already appear in the tsconfig.json file list.
|
55 | */
|
56 | private static _generateFilePathsForAnalysis;
|
57 | private static _createCompilerHost;
|
58 | }
|
59 |
|
60 | /**
|
61 | * Unique identifiers for console messages reported by API Extractor.
|
62 | *
|
63 | * @remarks
|
64 | *
|
65 | * These strings are possible values for the { ExtractorMessage.messageId} property
|
66 | * when the `ExtractorMessage.category` is { ExtractorMessageCategory.Console}.
|
67 | *
|
68 | *
|
69 | */
|
70 | export declare enum ConsoleMessageId {
|
71 | /**
|
72 | * "Analysis will use the bundled TypeScript version ___"
|
73 | */
|
74 | Preamble = "console-preamble",
|
75 | /**
|
76 | * "The target project appears to use TypeScript ___ which is newer than the bundled compiler engine;
|
77 | * consider upgrading API Extractor."
|
78 | */
|
79 | CompilerVersionNotice = "console-compiler-version-notice",
|
80 | /**
|
81 | * "Using custom TSDoc config from ___"
|
82 | */
|
83 | UsingCustomTSDocConfig = "console-using-custom-tsdoc-config",
|
84 | /**
|
85 | * "Found metadata in ___"
|
86 | */
|
87 | FoundTSDocMetadata = "console-found-tsdoc-metadata",
|
88 | /**
|
89 | * "Writing: ___"
|
90 | */
|
91 | WritingDocModelFile = "console-writing-doc-model-file",
|
92 | /**
|
93 | * "Writing package typings: ___"
|
94 | */
|
95 | WritingDtsRollup = "console-writing-dts-rollup",
|
96 | /**
|
97 | * "Generating ___ API report: ___"
|
98 | */
|
99 | WritingApiReport = "console-writing-api-report",
|
100 | /**
|
101 | * "You have changed the public API signature for this project.
|
102 | * Please copy the file ___ to ___, or perform a local build (which does this automatically).
|
103 | * See the Git repo documentation for more info."
|
104 | *
|
105 | * OR
|
106 | *
|
107 | * "The API report file is missing.
|
108 | * Please copy the file ___ to ___, or perform a local build (which does this automatically).
|
109 | * See the Git repo documentation for more info."
|
110 | */
|
111 | ApiReportNotCopied = "console-api-report-not-copied",
|
112 | /**
|
113 | * "You have changed the public API signature for this project. Updating ___"
|
114 | */
|
115 | ApiReportCopied = "console-api-report-copied",
|
116 | /**
|
117 | * "The API report is up to date: ___"
|
118 | */
|
119 | ApiReportUnchanged = "console-api-report-unchanged",
|
120 | /**
|
121 | * "The API report file was missing, so a new file was created. Please add this file to Git: ___"
|
122 | */
|
123 | ApiReportCreated = "console-api-report-created",
|
124 | /**
|
125 | * "Unable to create the API report file. Please make sure the target folder exists: ___"
|
126 | */
|
127 | ApiReportFolderMissing = "console-api-report-folder-missing",
|
128 | /**
|
129 | * Used for the information printed when the "--diagnostics" flag is enabled.
|
130 | */
|
131 | Diagnostics = "console-diagnostics"
|
132 | }
|
133 |
|
134 | /**
|
135 | * The starting point for invoking the API Extractor tool.
|
136 | * @public
|
137 | */
|
138 | export declare class Extractor {
|
139 | /**
|
140 | * Returns the version number of the API Extractor NPM package.
|
141 | */
|
142 | static get version(): string;
|
143 | /**
|
144 | * Returns the package name of the API Extractor NPM package.
|
145 | */
|
146 | static get packageName(): string;
|
147 | private static _getPackageJson;
|
148 | /**
|
149 | * Load the api-extractor.json config file from the specified path, and then invoke API Extractor.
|
150 | */
|
151 | static loadConfigAndInvoke(configFilePath: string, options?: IExtractorInvokeOptions): ExtractorResult;
|
152 | /**
|
153 | * Invoke API Extractor using an already prepared `ExtractorConfig` object.
|
154 | */
|
155 | static invoke(extractorConfig: ExtractorConfig, options?: IExtractorInvokeOptions): ExtractorResult;
|
156 | /**
|
157 | * Generates the API report at the specified release level, writes it to the specified file path, and compares
|
158 | * the output to the existing report (if one exists).
|
159 | *
|
160 | * @param reportTempDirectoryPath - The path to the directory under which the temp report file will be written prior
|
161 | * to comparison with an existing report.
|
162 | * @param reportDirectoryPath - The path to the directory under which the existing report file is located, and to
|
163 | * which the new report will be written post-comparison.
|
164 | * @param reportConfig - API report configuration, including its file name and {@link ApiReportVariant}.
|
165 | *
|
166 | * @returns Whether or not the newly generated report differs from the existing report (if one exists).
|
167 | */
|
168 | private static _writeApiReport;
|
169 | private static _checkCompilerCompatibility;
|
170 | private static _generateRollupDtsFile;
|
171 | }
|
172 |
|
173 | /**
|
174 | * The `ExtractorConfig` class loads, validates, interprets, and represents the api-extractor.json config file.
|
175 | * @sealed
|
176 | * @public
|
177 | */
|
178 | export declare class ExtractorConfig {
|
179 | /**
|
180 | * The JSON Schema for API Extractor config file (api-extractor.schema.json).
|
181 | */
|
182 | static readonly jsonSchema: JsonSchema;
|
183 | /**
|
184 | * The config file name "api-extractor.json".
|
185 | */
|
186 | static readonly FILENAME: 'api-extractor.json';
|
187 | /**
|
188 | * The full path to `extends/tsdoc-base.json` which contains the standard TSDoc configuration
|
189 | * for API Extractor.
|
190 | * @internal
|
191 | */
|
192 | static readonly _tsdocBaseFilePath: string;
|
193 | private static readonly _defaultConfig;
|
194 | /** Match all three flavors for type declaration files (.d.ts, .d.mts, .d.cts) */
|
195 | private static readonly _declarationFileExtensionRegExp;
|
196 | /** {@inheritDoc IConfigFile.projectFolder} */
|
197 | readonly projectFolder: string;
|
198 | /**
|
199 | * The parsed package.json file for the working package, or undefined if API Extractor was invoked without
|
200 | * a package.json file.
|
201 | */
|
202 | readonly packageJson: INodePackageJson | undefined;
|
203 | /**
|
204 | * The absolute path of the folder containing the package.json file for the working package, or undefined
|
205 | * if API Extractor was invoked without a package.json file.
|
206 | */
|
207 | readonly packageFolder: string | undefined;
|
208 | /** {@inheritDoc IConfigFile.mainEntryPointFilePath} */
|
209 | readonly mainEntryPointFilePath: string;
|
210 | /** {@inheritDoc IConfigFile.bundledPackages} */
|
211 | readonly bundledPackages: string[];
|
212 | /** {@inheritDoc IConfigCompiler.tsconfigFilePath} */
|
213 | readonly tsconfigFilePath: string;
|
214 | /** {@inheritDoc IConfigCompiler.overrideTsconfig} */
|
215 | readonly overrideTsconfig: {} | undefined;
|
216 | /** {@inheritDoc IConfigCompiler.skipLibCheck} */
|
217 | readonly skipLibCheck: boolean;
|
218 | /** {@inheritDoc IConfigApiReport.enabled} */
|
219 | readonly apiReportEnabled: boolean;
|
220 | /**
|
221 | * List of configurations for report files to be generated.
|
222 | * @remarks Derived from {@link IConfigApiReport.reportFileName} and {@link IConfigApiReport.reportVariants}.
|
223 | */
|
224 | readonly reportConfigs: readonly IExtractorConfigApiReport[];
|
225 | /** {@inheritDoc IConfigApiReport.reportFolder} */
|
226 | readonly reportFolder: string;
|
227 | /** {@inheritDoc IConfigApiReport.reportTempFolder} */
|
228 | readonly reportTempFolder: string;
|
229 | /**
|
230 | * Gets the file path for the "complete" (default) report configuration, if one was specified.
|
231 | * Otherwise, returns an empty string.
|
232 | * @deprecated Use {@link ExtractorConfig.reportConfigs} to access all report configurations.
|
233 | */
|
234 | get reportFilePath(): string;
|
235 | /**
|
236 | * Gets the temp file path for the "complete" (default) report configuration, if one was specified.
|
237 | * Otherwise, returns an empty string.
|
238 | * @deprecated Use {@link ExtractorConfig.reportConfigs} to access all report configurations.
|
239 | */
|
240 | get reportTempFilePath(): string;
|
241 | /** {@inheritDoc IConfigApiReport.includeForgottenExports} */
|
242 | readonly apiReportIncludeForgottenExports: boolean;
|
243 | /** {@inheritDoc IConfigDocModel.enabled} */
|
244 | readonly docModelEnabled: boolean;
|
245 | /** {@inheritDoc IConfigDocModel.apiJsonFilePath} */
|
246 | readonly apiJsonFilePath: string;
|
247 | /** {@inheritDoc IConfigDocModel.includeForgottenExports} */
|
248 | readonly docModelIncludeForgottenExports: boolean;
|
249 | /** {@inheritDoc IConfigDocModel.projectFolderUrl} */
|
250 | readonly projectFolderUrl: string | undefined;
|
251 | /** {@inheritDoc IConfigDtsRollup.enabled} */
|
252 | readonly rollupEnabled: boolean;
|
253 | /** {@inheritDoc IConfigDtsRollup.untrimmedFilePath} */
|
254 | readonly untrimmedFilePath: string;
|
255 | /** {@inheritDoc IConfigDtsRollup.alphaTrimmedFilePath} */
|
256 | readonly alphaTrimmedFilePath: string;
|
257 | /** {@inheritDoc IConfigDtsRollup.betaTrimmedFilePath} */
|
258 | readonly betaTrimmedFilePath: string;
|
259 | /** {@inheritDoc IConfigDtsRollup.publicTrimmedFilePath} */
|
260 | readonly publicTrimmedFilePath: string;
|
261 | /** {@inheritDoc IConfigDtsRollup.omitTrimmingComments} */
|
262 | readonly omitTrimmingComments: boolean;
|
263 | /** {@inheritDoc IConfigTsdocMetadata.enabled} */
|
264 | readonly tsdocMetadataEnabled: boolean;
|
265 | /** {@inheritDoc IConfigTsdocMetadata.tsdocMetadataFilePath} */
|
266 | readonly tsdocMetadataFilePath: string;
|
267 | /**
|
268 | * The tsdoc.json configuration that will be used when parsing doc comments.
|
269 | */
|
270 | readonly tsdocConfigFile: TSDocConfigFile;
|
271 | /**
|
272 | * The `TSDocConfiguration` loaded from {@link ExtractorConfig.tsdocConfigFile}.
|
273 | */
|
274 | readonly tsdocConfiguration: TSDocConfiguration;
|
275 | /**
|
276 | * Specifies what type of newlines API Extractor should use when writing output files. By default, the output files
|
277 | * will be written with Windows-style newlines.
|
278 | */
|
279 | readonly newlineKind: NewlineKind;
|
280 | /** {@inheritDoc IConfigFile.messages} */
|
281 | readonly messages: IExtractorMessagesConfig;
|
282 | /** {@inheritDoc IConfigFile.testMode} */
|
283 | readonly testMode: boolean;
|
284 | /** {@inheritDoc IConfigFile.enumMemberOrder} */
|
285 | readonly enumMemberOrder: EnumMemberOrder;
|
286 | private constructor();
|
287 | /**
|
288 | * Returns a JSON-like string representing the `ExtractorConfig` state, which can be printed to a console
|
289 | * for diagnostic purposes.
|
290 | *
|
291 | * @remarks
|
292 | * This is used by the "--diagnostics" command-line option. The string is not intended to be deserialized;
|
293 | * its format may be changed at any time.
|
294 | */
|
295 | getDiagnosticDump(): string;
|
296 | /**
|
297 | * Returns a simplified file path for use in error messages.
|
298 | * @internal
|
299 | */
|
300 | _getShortFilePath(absolutePath: string): string;
|
301 | /**
|
302 | * Searches for the api-extractor.json config file associated with the specified starting folder,
|
303 | * and loads the file if found. This lookup supports
|
304 | * {//www.npmjs.com/package/@rushstack/rig-package | rig packages}.
https: |
305 | *
|
306 | *
|
307 | * The search will first look for a package.json file in a parent folder of the starting folder;
|
308 | * if found, that will be used as the base folder instead of the starting folder. If the config
|
309 | * file is not found in `<baseFolder>/api-extractor.json` or `<baseFolder>/config/api-extractor.json`,
|
310 | * then `<baseFolder/config/rig.json` will be checked to see whether a
|
311 | * {//www.npmjs.com/package/@rushstack/rig-package | rig package} is referenced; if so then
https: |
312 | * the rig's api-extractor.json file will be used instead. If a config file is found, it will be loaded
|
313 | * and returned with the `IExtractorConfigPrepareOptions` object. Otherwise, `undefined` is returned
|
314 | * to indicate that API Extractor does not appear to be configured for the specified folder.
|
315 | *
|
316 | * `undefined`
An options object that can be passed to { ExtractorConfig.prepare}, or |
317 | * if not api-extractor.json file was found.
|
318 | */
|
319 | static tryLoadForFolder(options: IExtractorConfigLoadForFolderOptions): IExtractorConfigPrepareOptions | undefined;
|
320 | /**
|
321 | * Loads the api-extractor.json config file from the specified file path, and prepares an `ExtractorConfig` object.
|
322 | *
|
323 | * @remarks
|
324 | * Loads the api-extractor.json config file from the specified file path. If the "extends" field is present,
|
325 | * the referenced file(s) will be merged. For any omitted fields, the API Extractor default values are merged.
|
326 | *
|
327 | * The result is prepared using `ExtractorConfig.prepare()`.
|
328 | */
|
329 | static loadFileAndPrepare(configJsonFilePath: string): ExtractorConfig;
|
330 | /**
|
331 | * Performs only the first half of {@link ExtractorConfig.loadFileAndPrepare}, providing an opportunity to
|
332 | * modify the object before it is passed to {@link ExtractorConfig.prepare}.
|
333 | *
|
334 | * @remarks
|
335 | * Loads the api-extractor.json config file from the specified file path. If the "extends" field is present,
|
336 | * the referenced file(s) will be merged. For any omitted fields, the API Extractor default values are merged.
|
337 | */
|
338 | static loadFile(jsonFilePath: string): IConfigFile;
|
339 | private static _resolveConfigFileRelativePaths;
|
340 | private static _resolveConfigFileRelativePath;
|
341 | /**
|
342 | * Prepares an `ExtractorConfig` object using a configuration that is provided as a runtime object,
|
343 | * rather than reading it from disk. This allows configurations to be constructed programmatically,
|
344 | * loaded from an alternate source, and/or customized after loading.
|
345 | */
|
346 | static prepare(options: IExtractorConfigPrepareOptions): ExtractorConfig;
|
347 | /**
|
348 | * Gets the report configuration for the "complete" (default) report configuration, if one was specified.
|
349 | */
|
350 | private _getCompleteReportConfig;
|
351 | private static _resolvePathWithTokens;
|
352 | private static _expandStringWithTokens;
|
353 | /**
|
354 | * Returns true if the specified file path has the ".d.ts" file extension.
|
355 | */
|
356 | static hasDtsFileExtension(filePath: string): boolean;
|
357 | /**
|
358 | * Given a path string that may have originally contained expandable tokens such as `<projectFolder>"`
|
359 | * this reports an error if any token-looking substrings remain after expansion (e.g. `c:\blah\<invalid>\blah`).
|
360 | */
|
361 | private static _rejectAnyTokensInPath;
|
362 | }
|
363 |
|
364 | /**
|
365 | * Used with {@link IConfigMessageReportingRule.logLevel} and {@link IExtractorInvokeOptions.messageCallback}.
|
366 | *
|
367 | * @remarks
|
368 | * This is part of the {@link IConfigFile} structure.
|
369 | *
|
370 | * @public
|
371 | */
|
372 | export declare enum ExtractorLogLevel {
|
373 | /**
|
374 | * The message will be displayed as an error.
|
375 | *
|
376 | * @remarks
|
377 | * Errors typically cause the build to fail and return a nonzero exit code.
|
378 | */
|
379 | Error = "error",
|
380 | /**
|
381 | * The message will be displayed as an warning.
|
382 | *
|
383 | * @remarks
|
384 | * Warnings typically cause a production build fail and return a nonzero exit code. For a non-production build
|
385 | * (e.g. using the `--local` option with `api-extractor run`), the warning is displayed but the build will not fail.
|
386 | */
|
387 | Warning = "warning",
|
388 | /**
|
389 | * The message will be displayed as an informational message.
|
390 | *
|
391 | * @remarks
|
392 | * Informational messages may contain newlines to ensure nice formatting of the output,
|
393 | * however word-wrapping is the responsibility of the message handler.
|
394 | */
|
395 | Info = "info",
|
396 | /**
|
397 | * The message will be displayed only when "verbose" output is requested, e.g. using the `--verbose`
|
398 | * command line option.
|
399 | */
|
400 | Verbose = "verbose",
|
401 | /**
|
402 | * The message will be discarded entirely.
|
403 | */
|
404 | None = "none"
|
405 | }
|
406 |
|
407 | /**
|
408 | * This object is used to report an error or warning that occurred during API Extractor's analysis.
|
409 | *
|
410 | * @public
|
411 | */
|
412 | export declare class ExtractorMessage {
|
413 | private _handled;
|
414 | private _logLevel;
|
415 | /**
|
416 | * The category of issue.
|
417 | */
|
418 | readonly category: ExtractorMessageCategory;
|
419 | /**
|
420 | * A text string that uniquely identifies the issue type. This identifier can be used to suppress
|
421 | * or configure the reporting of issues, and also to search for help about an issue.
|
422 | */
|
423 | readonly messageId: tsdoc.TSDocMessageId | ExtractorMessageId | ConsoleMessageId | string;
|
424 | /**
|
425 | * The text description of this issue.
|
426 | */
|
427 | readonly text: string;
|
428 | /**
|
429 | * The absolute path to the affected input source file, if there is one.
|
430 | */
|
431 | readonly sourceFilePath: string | undefined;
|
432 | /**
|
433 | * The line number where the issue occurred in the input source file. This is not used if `sourceFilePath`
|
434 | * is undefined. The first line number is 1.
|
435 | */
|
436 | readonly sourceFileLine: number | undefined;
|
437 | /**
|
438 | * The column number where the issue occurred in the input source file. This is not used if `sourceFilePath`
|
439 | * is undefined. The first column number is 1.
|
440 | */
|
441 | readonly sourceFileColumn: number | undefined;
|
442 | /**
|
443 | * Additional contextual information about the message that may be useful when reporting errors.
|
444 | * All properties are optional.
|
445 | */
|
446 | readonly properties: IExtractorMessageProperties;
|
447 | /** @internal */
|
448 | constructor(options: IExtractorMessageOptions);
|
449 | /**
|
450 | * If the {this property to true, it will prevent the message
IExtractorInvokeOptions.messageCallback} sets |
451 | * from being displayed by API Extractor.
|
452 | *
|
453 | *
|
454 | * If the `messageCallback` routes the message to a custom handler (e.g. a toolchain logger), it should
|
455 | * assign `handled = true` to prevent API Extractor from displaying it. Assigning `handled = true` for all messages
|
456 | * would effectively disable all console output from the `Extractor` API.
|
457 | *
|
458 | * If `handled` is set to true, the message will still be included in the count of errors/warnings;
|
459 | * to discard a message entirely, instead assign `logLevel = none`.
|
460 | */
|
461 | get handled(): boolean;
|
462 | set handled(value: boolean);
|
463 | /**
|
464 | * Specifies how the message should be reported.
|
465 | *
|
466 | * @remarks
|
467 | * If the {@link IExtractorInvokeOptions.messageCallback} handles the message (i.e. sets `handled = true`),
|
468 | * it can use the `logLevel` to determine how to display the message.
|
469 | *
|
470 | * Alternatively, if API Extractor is handling the message, the `messageCallback` could assign `logLevel` to change
|
471 | * how it will be processed. However, in general the recommended practice is to configure message routing
|
472 | * using the `messages` section in api-extractor.json.
|
473 | *
|
474 | * To discard a message entirely, assign `logLevel = none`.
|
475 | */
|
476 | get logLevel(): ExtractorLogLevel;
|
477 | set logLevel(value: ExtractorLogLevel);
|
478 | /**
|
479 | * Returns the message formatted with its identifier and file position.
|
480 | * @remarks
|
481 | * Example:
|
482 | * ```
|
483 | * src/folder/File.ts:123:4 - (ae-extra-release-tag) The doc comment should not contain more than one release tag.
|
484 | * ```
|
485 | */
|
486 | formatMessageWithLocation(workingPackageFolderPath: string | undefined): string;
|
487 | formatMessageWithoutLocation(): string;
|
488 | }
|
489 |
|
490 | /**
|
491 | * Specifies a category of messages for use with {@link ExtractorMessage}.
|
492 | * @public
|
493 | */
|
494 | export declare enum ExtractorMessageCategory {
|
495 | /**
|
496 | * Messages originating from the TypeScript compiler.
|
497 | *
|
498 | * @remarks
|
499 | * These strings begin with the prefix "TS" and have a numeric error code.
|
500 | * Example: `TS2551`
|
501 | */
|
502 | Compiler = "Compiler",
|
503 | /**
|
504 | * Messages related to parsing of TSDoc comments.
|
505 | *
|
506 | * @remarks
|
507 | * These strings begin with the prefix "tsdoc-".
|
508 | * Example: `tsdoc-link-tag-unescaped-text`
|
509 | */
|
510 | TSDoc = "TSDoc",
|
511 | /**
|
512 | * Messages related to API Extractor's analysis.
|
513 | *
|
514 | * @remarks
|
515 | * These strings begin with the prefix "ae-".
|
516 | * Example: `ae-extra-release-tag`
|
517 | */
|
518 | Extractor = "Extractor",
|
519 | /**
|
520 | * Console messages communicate the progress of the overall operation. They may include newlines to ensure
|
521 | * nice formatting. They are output in real time, and cannot be routed to the API Report file.
|
522 | *
|
523 | * @remarks
|
524 | * These strings begin with the prefix "console-".
|
525 | * Example: `console-writing-typings-file`
|
526 | */
|
527 | Console = "console"
|
528 | }
|
529 |
|
530 | /**
|
531 | * Unique identifiers for messages reported by API Extractor during its analysis.
|
532 | *
|
533 | * @remarks
|
534 | *
|
535 | * These strings are possible values for the {@link ExtractorMessage.messageId} property
|
536 | * when the `ExtractorMessage.category` is {@link ExtractorMessageCategory.Extractor}.
|
537 | *
|
538 | * @public
|
539 | */
|
540 | export declare enum ExtractorMessageId {
|
541 | /**
|
542 | * "The doc comment should not contain more than one release tag."
|
543 | */
|
544 | ExtraReleaseTag = "ae-extra-release-tag",
|
545 | /**
|
546 | * "Missing documentation for ___."
|
547 | * @remarks
|
548 | * The `ae-undocumented` message is only generated if the API report feature is enabled.
|
549 | *
|
550 | * Because the API report file already annotates undocumented items with `// (undocumented)`,
|
551 | * the `ae-undocumented` message is not logged by default. To see it, add a setting such as:
|
552 | * ```json
|
553 | * "messages": {
|
554 | * "extractorMessageReporting": {
|
555 | * "ae-undocumented": {
|
556 | * "logLevel": "warning"
|
557 | * }
|
558 | * }
|
559 | * }
|
560 | * ```
|
561 | */
|
562 | Undocumented = "ae-undocumented",
|
563 | /**
|
564 | * "This symbol has another declaration with a different release tag."
|
565 | */
|
566 | DifferentReleaseTags = "ae-different-release-tags",
|
567 | /**
|
568 | * "The symbol ___ is marked as ___, but its signature references ___ which is marked as ___."
|
569 | */
|
570 | IncompatibleReleaseTags = "ae-incompatible-release-tags",
|
571 | /**
|
572 | * "___ is part of the package's API, but it is missing a release tag (`@alpha`, `@beta`, `@public`, or `@internal`)."
|
573 | */
|
574 | MissingReleaseTag = "ae-missing-release-tag",
|
575 | /**
|
576 | * "The `@packageDocumentation` comment must appear at the top of entry point *.d.ts file."
|
577 | */
|
578 | MisplacedPackageTag = "ae-misplaced-package-tag",
|
579 | /**
|
580 | * "The symbol ___ needs to be exported by the entry point ___."
|
581 | */
|
582 | ForgottenExport = "ae-forgotten-export",
|
583 | /**
|
584 | * "The name ___ should be prefixed with an underscore because the declaration is marked as `@internal`."
|
585 | */
|
586 | InternalMissingUnderscore = "ae-internal-missing-underscore",
|
587 | /**
|
588 | * "Mixed release tags are not allowed for ___ because one of its declarations is marked as `@internal`."
|
589 | */
|
590 | InternalMixedReleaseTag = "ae-internal-mixed-release-tag",
|
591 | /**
|
592 | * "The `@preapproved` tag cannot be applied to ___ because it is not a supported declaration type."
|
593 | */
|
594 | PreapprovedUnsupportedType = "ae-preapproved-unsupported-type",
|
595 | /**
|
596 | * "The `@preapproved` tag cannot be applied to ___ without an `@internal` release tag."
|
597 | */
|
598 | PreapprovedBadReleaseTag = "ae-preapproved-bad-release-tag",
|
599 | /**
|
600 | * "The `@inheritDoc` reference could not be resolved."
|
601 | */
|
602 | UnresolvedInheritDocReference = "ae-unresolved-inheritdoc-reference",
|
603 | /**
|
604 | * "The `@inheritDoc` tag needs a TSDoc declaration reference; signature matching is not supported yet."
|
605 | *
|
606 | * @privateRemarks
|
607 | * In the future, we will implement signature matching so that you can write `{@inheritDoc}` and API Extractor
|
608 | * will find a corresponding member from a base class (or implemented interface). Until then, the tag
|
609 | * always needs an explicit declaration reference such as `{@inhertDoc MyBaseClass.sameMethod}`.
|
610 | */
|
611 | UnresolvedInheritDocBase = "ae-unresolved-inheritdoc-base",
|
612 | /**
|
613 | * "The `@inheritDoc` tag for ___ refers to its own declaration."
|
614 | */
|
615 | CyclicInheritDoc = "ae-cyclic-inherit-doc",
|
616 | /**
|
617 | * "The `@link` reference could not be resolved."
|
618 | */
|
619 | UnresolvedLink = "ae-unresolved-link",
|
620 | /**
|
621 | * "The doc comment for the property ___ must appear on the getter, not the setter."
|
622 | */
|
623 | SetterWithDocs = "ae-setter-with-docs",
|
624 | /**
|
625 | * "The property ___ has a setter but no getter."
|
626 | */
|
627 | MissingGetter = "ae-missing-getter",
|
628 | /**
|
629 | * "Incorrect file type; API Extractor expects to analyze compiler outputs with the .d.ts file extension.
|
630 | * Troubleshooting tips: `https://api-extractor.com/link/dts-error`"
|
631 | */
|
632 | WrongInputFileType = "ae-wrong-input-file-type"
|
633 | }
|
634 |
|
635 | /**
|
636 | * This object represents the outcome of an invocation of API Extractor.
|
637 | *
|
638 | * @public
|
639 | */
|
640 | export declare class ExtractorResult {
|
641 | /**
|
642 | * The TypeScript compiler state that was used.
|
643 | */
|
644 | readonly compilerState: CompilerState;
|
645 | /**
|
646 | * The API Extractor configuration that was used.
|
647 | */
|
648 | readonly extractorConfig: ExtractorConfig;
|
649 | /**
|
650 | * Whether the invocation of API Extractor was successful. For example, if `succeeded` is false, then the build task
|
651 | * would normally return a nonzero process exit code, indicating that the operation failed.
|
652 | *
|
653 | * @remarks
|
654 | *
|
655 | * Normally the operation "succeeds" if `errorCount` and `warningCount` are both zero. However if
|
656 | * {@link IExtractorInvokeOptions.localBuild} is `true`, then the operation "succeeds" if `errorCount` is zero
|
657 | * (i.e. warnings are ignored).
|
658 | */
|
659 | readonly succeeded: boolean;
|
660 | /**
|
661 | * Returns true if the API report was found to have changed.
|
662 | */
|
663 | readonly apiReportChanged: boolean;
|
664 | /**
|
665 | * Reports the number of errors encountered during analysis.
|
666 | *
|
667 | * @remarks
|
668 | * This does not count exceptions, where unexpected issues prematurely abort the operation.
|
669 | */
|
670 | readonly errorCount: number;
|
671 | /**
|
672 | * Reports the number of warnings encountered during analysis.
|
673 | *
|
674 | * @remarks
|
675 | * This does not count warnings that are emitted in the API report file.
|
676 | */
|
677 | readonly warningCount: number;
|
678 | /** @internal */
|
679 | constructor(properties: ExtractorResult);
|
680 | }
|
681 |
|
682 | /**
|
683 | * Options for { CompilerState.create}
|
684 | *
|
685 | */
|
686 | export declare interface ICompilerStateCreateOptions {
|
687 | /** {@inheritDoc IExtractorInvokeOptions.typescriptCompilerFolder} */
|
688 | typescriptCompilerFolder?: string;
|
689 | /**
|
690 | * Additional .d.ts files to include in the analysis.
|
691 | */
|
692 | additionalEntryPoints?: string[];
|
693 | }
|
694 |
|
695 | /**
|
696 | * Configures how the API report files (*.api.md) will be generated.
|
697 | *
|
698 | * @remarks
|
699 | * This is part of the {@link IConfigFile} structure.
|
700 | *
|
701 | * @public
|
702 | */
|
703 | export declare interface IConfigApiReport {
|
704 | /**
|
705 | * Whether to generate an API report.
|
706 | */
|
707 | enabled: boolean;
|
708 | /**
|
709 | * The base filename for the API report files, to be combined with {@link IConfigApiReport.reportFolder} or
|
710 | * {@link IConfigApiReport.reportTempFolder} to produce the full file path.
|
711 | *
|
712 | * @remarks
|
713 | * The `reportFileName` should not include any path separators such as `\` or `/`. The `reportFileName` should
|
714 | * not include a file extension, since API Extractor will automatically append an appropriate file extension such
|
715 | * as `.api.md`. If the {@link IConfigApiReport.reportVariants} setting is used, then the file extension includes
|
716 | * the variant name, for example `my-report.public.api.md` or `my-report.beta.api.md`. The `complete` variant always
|
717 | * uses the simple extension `my-report.api.md`.
|
718 | *
|
719 | * Previous versions of API Extractor required `reportFileName` to include the `.api.md` extension explicitly;
|
720 | * for backwards compatibility, that is still accepted but will be discarded before applying the above rules.
|
721 | *
|
722 | * @defaultValue `<unscopedPackageName>`
|
723 | */
|
724 | reportFileName?: string;
|
725 | /**
|
726 | * The set of report variants to generate.
|
727 | *
|
728 | * @remarks
|
729 | * To support different approval requirements for different API levels, multiple "variants" of the API report can
|
730 | * be generated. The `reportVariants` setting specifies a list of variants to be generated. If omitted,
|
731 | * by default only the `complete` variant will be generated, which includes all `@internal`, `@alpha`, `@beta`,
|
732 | * and `@public` items. Other possible variants are `alpha` (`@alpha` + `@beta` + `@public`),
|
733 | * `beta` (`@beta` + `@public`), and `public` (`@public only`).
|
734 | *
|
735 | * The resulting API report file names will be derived from the {@link IConfigApiReport.reportFileName}.
|
736 | *
|
737 | * @defaultValue `[ "complete" ]`
|
738 | */
|
739 | reportVariants?: ApiReportVariant[];
|
740 | /**
|
741 | * Specifies the folder where the API report file is written. The file name portion is determined by
|
742 | * the `reportFileName` setting.
|
743 | *
|
744 | * @remarks
|
745 | * The API report file is normally tracked by Git. Changes to it can be used to trigger a branch policy,
|
746 | * e.g. for an API review.
|
747 | *
|
748 | * The path is resolved relative to the folder of the config file that contains the setting; to change this,
|
749 | * prepend a folder token such as `<projectFolder>`.
|
750 | */
|
751 | reportFolder?: string;
|
752 | /**
|
753 | * Specifies the folder where the temporary report file is written. The file name portion is determined by
|
754 | * the `reportFileName` setting.
|
755 | *
|
756 | * @remarks
|
757 | * After the temporary file is written to disk, it is compared with the file in the `reportFolder`.
|
758 | * If they are different, a production build will fail.
|
759 | *
|
760 | * The path is resolved relative to the folder of the config file that contains the setting; to change this,
|
761 | * prepend a folder token such as `<projectFolder>`.
|
762 | */
|
763 | reportTempFolder?: string;
|
764 | /**
|
765 | * Whether "forgotten exports" should be included in the API report file.
|
766 | *
|
767 | * @remarks
|
768 | * Forgotten exports are declarations flagged with `ae-forgotten-export` warnings. See
|
769 | * https://api-extractor.com/pages/messages/ae-forgotten-export/ to learn more.
|
770 | *
|
771 | * @defaultValue `false`
|
772 | */
|
773 | includeForgottenExports?: boolean;
|
774 | }
|
775 |
|
776 | /**
|
777 | * Determines how the TypeScript compiler engine will be invoked by API Extractor.
|
778 | *
|
779 | * @remarks
|
780 | * This is part of the {@link IConfigFile} structure.
|
781 | *
|
782 | * @public
|
783 | */
|
784 | export declare interface IConfigCompiler {
|
785 | /**
|
786 | * Specifies the path to the tsconfig.json file to be used by API Extractor when analyzing the project.
|
787 | *
|
788 | * @remarks
|
789 | * The path is resolved relative to the folder of the config file that contains the setting; to change this,
|
790 | * prepend a folder token such as `<projectFolder>`.
|
791 | *
|
792 | * Note: This setting will be ignored if `overrideTsconfig` is used.
|
793 | */
|
794 | tsconfigFilePath?: string;
|
795 | /**
|
796 | * Provides a compiler configuration that will be used instead of reading the tsconfig.json file from disk.
|
797 | *
|
798 | * @remarks
|
799 | * The value must conform to the TypeScript tsconfig schema:
|
800 | *
|
801 | * http://json.schemastore.org/tsconfig
|
802 | *
|
803 | * If omitted, then the tsconfig.json file will instead be read from the projectFolder.
|
804 | */
|
805 | overrideTsconfig?: {};
|
806 | /**
|
807 | * This option causes the compiler to be invoked with the `--skipLibCheck` option.
|
808 | *
|
809 | * @remarks
|
810 | * This option is not recommended and may cause API Extractor to produce incomplete or incorrect declarations,
|
811 | * but it may be required when dependencies contain declarations that are incompatible with the TypeScript engine
|
812 | * that API Extractor uses for its analysis. Where possible, the underlying issue should be fixed rather than
|
813 | * relying on skipLibCheck.
|
814 | */
|
815 | skipLibCheck?: boolean;
|
816 | }
|
817 |
|
818 | /**
|
819 | * Configures how the doc model file (*.api.json) will be generated.
|
820 | *
|
821 | * @remarks
|
822 | * This is part of the {@link IConfigFile} structure.
|
823 | *
|
824 | * @public
|
825 | */
|
826 | export declare interface IConfigDocModel {
|
827 | /**
|
828 | * Whether to generate a doc model file.
|
829 | */
|
830 | enabled: boolean;
|
831 | /**
|
832 | * The output path for the doc model file. The file extension should be ".api.json".
|
833 | *
|
834 | * @remarks
|
835 | * The path is resolved relative to the folder of the config file that contains the setting; to change this,
|
836 | * prepend a folder token such as `<projectFolder>`.
|
837 | */
|
838 | apiJsonFilePath?: string;
|
839 | /**
|
840 | * Whether "forgotten exports" should be included in the doc model file.
|
841 | *
|
842 | * @remarks
|
843 | * Forgotten exports are declarations flagged with `ae-forgotten-export` warnings. See
|
844 | * https://api-extractor.com/pages/messages/ae-forgotten-export/ to learn more.
|
845 | *
|
846 | * @defaultValue `false`
|
847 | */
|
848 | includeForgottenExports?: boolean;
|
849 | /**
|
850 | * The base URL where the project's source code can be viewed on a website such as GitHub or
|
851 | * Azure DevOps. This URL path corresponds to the `<projectFolder>` path on disk.
|
852 | *
|
853 | * @remarks
|
854 | * This URL is concatenated with the file paths serialized to the doc model to produce URL file paths to individual API items.
|
855 | * For example, if the `projectFolderUrl` is "https://github.com/microsoft/rushstack/tree/main/apps/api-extractor" and an API
|
856 | * item's file path is "api/ExtractorConfig.ts", the full URL file path would be
|
857 | * "https://github.com/microsoft/rushstack/tree/main/apps/api-extractor/api/ExtractorConfig.js".
|
858 | *
|
859 | * Can be omitted if you don't need source code links in your API documentation reference.
|
860 | */
|
861 | projectFolderUrl?: string;
|
862 | }
|
863 |
|
864 | /**
|
865 | * Configures how the .d.ts rollup file will be generated.
|
866 | *
|
867 | * @remarks
|
868 | * This is part of the {@link IConfigFile} structure.
|
869 | *
|
870 | * @public
|
871 | */
|
872 | export declare interface IConfigDtsRollup {
|
873 | /**
|
874 | * Whether to generate the .d.ts rollup file.
|
875 | */
|
876 | enabled: boolean;
|
877 | /**
|
878 | * Specifies the output path for a .d.ts rollup file to be generated without any trimming.
|
879 | *
|
880 | * @remarks
|
881 | * This file will include all declarations that are exported by the main entry point.
|
882 | *
|
883 | * If the path is an empty string, then this file will not be written.
|
884 | *
|
885 | * The path is resolved relative to the folder of the config file that contains the setting; to change this,
|
886 | * prepend a folder token such as `<projectFolder>`.
|
887 | */
|
888 | untrimmedFilePath?: string;
|
889 | /**
|
890 | * Specifies the output path for a .d.ts rollup file to be generated with trimming for an "alpha" release.
|
891 | *
|
892 | * @remarks
|
893 | * This file will include only declarations that are marked as `@public`, `@beta`, or `@alpha`.
|
894 | *
|
895 | * The path is resolved relative to the folder of the config file that contains the setting; to change this,
|
896 | * prepend a folder token such as `<projectFolder>`.
|
897 | */
|
898 | alphaTrimmedFilePath?: string;
|
899 | /**
|
900 | * Specifies the output path for a .d.ts rollup file to be generated with trimming for a "beta" release.
|
901 | *
|
902 | * @remarks
|
903 | * This file will include only declarations that are marked as `@public` or `@beta`.
|
904 | *
|
905 | * The path is resolved relative to the folder of the config file that contains the setting; to change this,
|
906 | * prepend a folder token such as `<projectFolder>`.
|
907 | */
|
908 | betaTrimmedFilePath?: string;
|
909 | /**
|
910 | * Specifies the output path for a .d.ts rollup file to be generated with trimming for a "public" release.
|
911 | *
|
912 | * @remarks
|
913 | * This file will include only declarations that are marked as `@public`.
|
914 | *
|
915 | * If the path is an empty string, then this file will not be written.
|
916 | *
|
917 | * The path is resolved relative to the folder of the config file that contains the setting; to change this,
|
918 | * prepend a folder token such as `<projectFolder>`.
|
919 | */
|
920 | publicTrimmedFilePath?: string;
|
921 | /**
|
922 | * When a declaration is trimmed, by default it will be replaced by a code comment such as
|
923 | * "Excluded from this release type: exampleMember". Set "omitTrimmingComments" to true to remove the
|
924 | * declaration completely.
|
925 | */
|
926 | omitTrimmingComments?: boolean;
|
927 | }
|
928 |
|
929 | /**
|
930 | * Configuration options for the API Extractor tool. These options can be constructed programmatically
|
931 | * or loaded from the api-extractor.json config file using the {@link ExtractorConfig} class.
|
932 | *
|
933 | * @public
|
934 | */
|
935 | export declare interface IConfigFile {
|
936 | /**
|
937 | * Optionally specifies another JSON config file that this file extends from. This provides a way for
|
938 | * standard settings to be shared across multiple projects.
|
939 | *
|
940 | * @remarks
|
941 | * If the path starts with `./` or `../`, the path is resolved relative to the folder of the file that contains
|
942 | * the `extends` field. Otherwise, the first path segment is interpreted as an NPM package name, and will be
|
943 | * resolved using NodeJS `require()`.
|
944 | */
|
945 | extends?: string;
|
946 | /**
|
947 | * Determines the `<projectFolder>` token that can be used with other config file settings. The project folder
|
948 | * typically contains the tsconfig.json and package.json config files, but the path is user-defined.
|
949 | *
|
950 | * @remarks
|
951 | *
|
952 | * The path is resolved relative to the folder of the config file that contains the setting.
|
953 | *
|
954 | * The default value for `projectFolder` is the token `<lookup>`, which means the folder is determined using
|
955 | * the following heuristics:
|
956 | *
|
957 | * If the config/rig.json system is used (as defined by {@link https://www.npmjs.com/package/@rushstack/rig-package
|
958 | * | @rushstack/rig-package}), then the `<lookup>` value will be the package folder that referenced the rig.
|
959 | *
|
960 | * Otherwise, the `<lookup>` value is determined by traversing parent folders, starting from the folder containing
|
961 | * api-extractor.json, and stopping at the first folder that contains a tsconfig.json file. If a tsconfig.json file
|
962 | * cannot be found in this way, then an error will be reported.
|
963 | */
|
964 | projectFolder?: string;
|
965 | /**
|
966 | * Specifies the .d.ts file to be used as the starting point for analysis. API Extractor
|
967 | * analyzes the symbols exported by this module.
|
968 | *
|
969 | * @remarks
|
970 | *
|
971 | * The file extension must be ".d.ts" and not ".ts".
|
972 | * The path is resolved relative to the "projectFolder" location.
|
973 | */
|
974 | mainEntryPointFilePath: string;
|
975 | /**
|
976 | * A list of NPM package names whose exports should be treated as part of this package.
|
977 | *
|
978 | * @remarks
|
979 | * Also supports glob patterns.
|
980 | * Note: glob patterns will **only** be resolved against dependencies listed in the project's package.json file.
|
981 | *
|
982 | * * This is both a safety and a performance precaution.
|
983 | *
|
984 | * Exact package names will be applied against any dependency encountered while walking the type graph, regardless of
|
985 | * dependencies listed in the package.json.
|
986 | *
|
987 | * @example
|
988 | *
|
989 | * Suppose that Webpack is used to generate a distributed bundle for the project `library1`,
|
990 | * and another NPM package `library2` is embedded in this bundle. Some types from `library2` may become part
|
991 | * of the exported API for `library1`, but by default API Extractor would generate a .d.ts rollup that explicitly
|
992 | * imports `library2`. To avoid this, we can specify:
|
993 | *
|
994 | * ```js
|
995 | * "bundledPackages": [ "library2" ],
|
996 | * ```
|
997 | *
|
998 | * This would direct API Extractor to embed those types directly in the .d.ts rollup, as if they had been
|
999 | * local files for `library1`.
|
1000 | */
|
1001 | bundledPackages?: string[];
|
1002 | /**
|
1003 | * Specifies what type of newlines API Extractor should use when writing output files.
|
1004 | *
|
1005 | * @remarks
|
1006 | * By default, the output files will be written with Windows-style newlines.
|
1007 | * To use POSIX-style newlines, specify "lf" instead.
|
1008 | * To use the OS's default newline kind, specify "os".
|
1009 | */
|
1010 | newlineKind?: 'crlf' | 'lf' | 'os';
|
1011 | /**
|
1012 | * Set to true when invoking API Extractor's test harness.
|
1013 | * @remarks
|
1014 | * When `testMode` is true, the `toolVersion` field in the .api.json file is assigned an empty string
|
1015 | * to prevent spurious diffs in output files tracked for tests.
|
1016 | */
|
1017 | testMode?: boolean;
|
1018 | /**
|
1019 | * Specifies how API Extractor sorts members of an enum when generating the .api.json file.
|
1020 | *
|
1021 | * @remarks
|
1022 | * By default, the output files will be sorted alphabetically, which is "by-name".
|
1023 | * To keep the ordering in the source code, specify "preserve".
|
1024 | *
|
1025 | * @defaultValue `by-name`
|
1026 | */
|
1027 | enumMemberOrder?: EnumMemberOrder;
|
1028 | /**
|
1029 | * {@inheritDoc IConfigCompiler}
|
1030 | */
|
1031 | compiler?: IConfigCompiler;
|
1032 | /**
|
1033 | * {@inheritDoc IConfigApiReport}
|
1034 | */
|
1035 | apiReport?: IConfigApiReport;
|
1036 | /**
|
1037 | * {@inheritDoc IConfigDocModel}
|
1038 | */
|
1039 | docModel?: IConfigDocModel;
|
1040 | /**
|
1041 | * {@inheritDoc IConfigDtsRollup}
|
1042 | * @beta
|
1043 | */
|
1044 | dtsRollup?: IConfigDtsRollup;
|
1045 | /**
|
1046 | * {@inheritDoc IConfigTsdocMetadata}
|
1047 | * @beta
|
1048 | */
|
1049 | tsdocMetadata?: IConfigTsdocMetadata;
|
1050 | /**
|
1051 | * {@inheritDoc IExtractorMessagesConfig}
|
1052 | */
|
1053 | messages?: IExtractorMessagesConfig;
|
1054 | }
|
1055 |
|
1056 | /**
|
1057 | * Configures reporting for a given message identifier.
|
1058 | *
|
1059 | * @remarks
|
1060 | * This is part of the {@link IConfigFile} structure.
|
1061 | *
|
1062 | * @public
|
1063 | */
|
1064 | export declare interface IConfigMessageReportingRule {
|
1065 | /**
|
1066 | * Specifies whether the message should be written to the the tool's output log.
|
1067 | *
|
1068 | * @remarks
|
1069 | * Note that the `addToApiReportFile` property may supersede this option.
|
1070 | */
|
1071 | logLevel: ExtractorLogLevel;
|
1072 | /**
|
1073 | * When `addToApiReportFile` is true: If API Extractor is configured to write an API report file (.api.md),
|
1074 | * then the message will be written inside that file; otherwise, the message is instead logged according to
|
1075 | * the `logLevel` option.
|
1076 | */
|
1077 | addToApiReportFile?: boolean;
|
1078 | }
|
1079 |
|
1080 | /**
|
1081 | * Specifies a table of reporting rules for different message identifiers, and also the default rule used for
|
1082 | * identifiers that do not appear in the table.
|
1083 | *
|
1084 | * @remarks
|
1085 | * This is part of the {@link IConfigFile} structure.
|
1086 | *
|
1087 | * @public
|
1088 | */
|
1089 | export declare interface IConfigMessageReportingTable {
|
1090 | /**
|
1091 | * The key is a message identifier for the associated type of message, or "default" to specify the default policy.
|
1092 | * For example, the key might be `TS2551` (a compiler message), `tsdoc-link-tag-unescaped-text` (a TSDOc message),
|
1093 | * or `ae-extra-release-tag` (a message related to the API Extractor analysis).
|
1094 | */
|
1095 | [messageId: string]: IConfigMessageReportingRule;
|
1096 | }
|
1097 |
|
1098 | /**
|
1099 | * Configures how the tsdoc-metadata.json file will be generated.
|
1100 | *
|
1101 | * @remarks
|
1102 | * This is part of the {@link IConfigFile} structure.
|
1103 | *
|
1104 | * @public
|
1105 | */
|
1106 | export declare interface IConfigTsdocMetadata {
|
1107 | /**
|
1108 | * Whether to generate the tsdoc-metadata.json file.
|
1109 | */
|
1110 | enabled: boolean;
|
1111 | /**
|
1112 | * Specifies where the TSDoc metadata file should be written.
|
1113 | *
|
1114 | * @remarks
|
1115 | * The path is resolved relative to the folder of the config file that contains the setting; to change this,
|
1116 | * prepend a folder token such as `<projectFolder>`.
|
1117 | *
|
1118 | * The default value is `<lookup>`, which causes the path to be automatically inferred from the `tsdocMetadata`,
|
1119 | * `typings` or `main` fields of the project's package.json. If none of these fields are set, the lookup
|
1120 | * falls back to `tsdoc-metadata.json` in the package folder.
|
1121 | */
|
1122 | tsdocMetadataFilePath?: string;
|
1123 | }
|
1124 |
|
1125 | /**
|
1126 | * Configuration for a single API report, including its {@link IExtractorConfigApiReport.variant}.
|
1127 | *
|
1128 | * @public
|
1129 | */
|
1130 | export declare interface IExtractorConfigApiReport {
|
1131 | /**
|
1132 | * Report variant.
|
1133 | * Determines which API items will be included in the report output, based on their tagged release levels.
|
1134 | */
|
1135 | variant: ApiReportVariant;
|
1136 | /**
|
1137 | * Name of the output report file.
|
1138 | * @remarks Relative to the configured report directory path.
|
1139 | */
|
1140 | fileName: string;
|
1141 | }
|
1142 |
|
1143 | /**
|
1144 | * Options for {@link ExtractorConfig.tryLoadForFolder}.
|
1145 | *
|
1146 | * @public
|
1147 | */
|
1148 | export declare interface IExtractorConfigLoadForFolderOptions {
|
1149 | /**
|
1150 | * The folder path to start from when searching for api-extractor.json.
|
1151 | */
|
1152 | startingFolder: string;
|
1153 | /**
|
1154 | * An already constructed `PackageJsonLookup` cache object to use. If omitted, a temporary one will
|
1155 | * be constructed.
|
1156 | */
|
1157 | packageJsonLookup?: PackageJsonLookup;
|
1158 | /**
|
1159 | * An already constructed `RigConfig` object. If omitted, then a new `RigConfig` object will be constructed.
|
1160 | */
|
1161 | rigConfig?: IRigConfig;
|
1162 | }
|
1163 |
|
1164 | /**
|
1165 | * Options for {@link ExtractorConfig.prepare}.
|
1166 | *
|
1167 | * @public
|
1168 | */
|
1169 | export declare interface IExtractorConfigPrepareOptions {
|
1170 | /**
|
1171 | * A configuration object as returned by {@link ExtractorConfig.loadFile}.
|
1172 | */
|
1173 | configObject: IConfigFile;
|
1174 | /**
|
1175 | * The absolute path of the file that the `configObject` object was loaded from. This is used for error messages
|
1176 | * and when probing for `tsconfig.json`.
|
1177 | *
|
1178 | * @remarks
|
1179 | *
|
1180 | * If `configObjectFullPath` and `projectFolderLookupToken` are both unspecified, then the api-extractor.json
|
1181 | * config file must explicitly specify a `projectFolder` setting rather than relying on the `<lookup>` token.
|
1182 | */
|
1183 | configObjectFullPath: string | undefined;
|
1184 | /**
|
1185 | * The parsed package.json file for the working package, or undefined if API Extractor was invoked without
|
1186 | * a package.json file.
|
1187 | *
|
1188 | * @remarks
|
1189 | *
|
1190 | * If omitted, then the `<unscopedPackageName>` and `<packageName>` tokens will have default values.
|
1191 | */
|
1192 | packageJson?: INodePackageJson | undefined;
|
1193 | /**
|
1194 | * The absolute path of the file that the `packageJson` object was loaded from, or undefined if API Extractor
|
1195 | * was invoked without a package.json file.
|
1196 | *
|
1197 | * @remarks
|
1198 | *
|
1199 | * This is used for error messages and when resolving paths found in package.json.
|
1200 | *
|
1201 | * If `packageJsonFullPath` is specified but `packageJson` is omitted, the file will be loaded automatically.
|
1202 | */
|
1203 | packageJsonFullPath: string | undefined;
|
1204 | /**
|
1205 | * The default value for the `projectFolder` setting is the `<lookup>` token, which uses a heuristic to guess
|
1206 | * an appropriate project folder. Use `projectFolderLookupValue` to manually specify the `<lookup>` token value
|
1207 | * instead.
|
1208 | *
|
1209 | * @remarks
|
1210 | * If the `projectFolder` setting is explicitly specified in api-extractor.json file, it should take precedence
|
1211 | * over a value specified via the API. Thus the `projectFolderLookupToken` option provides a way to override
|
1212 | * the default value for `projectFolder` setting while still honoring a manually specified value.
|
1213 | */
|
1214 | projectFolderLookupToken?: string;
|
1215 | /**
|
1216 | * Allow customization of the tsdoc.json config file. If omitted, this file will be loaded from its default
|
1217 | * location. If the file does not exist, then the standard definitions will be used from
|
1218 | * `@microsoft/api-extractor/extends/tsdoc-base.json`.
|
1219 | */
|
1220 | tsdocConfigFile?: TSDocConfigFile;
|
1221 | /**
|
1222 | * When preparing the configuration object, folder and file paths referenced in the configuration are checked
|
1223 | * for existence, and an error is reported if they are not found. This option can be used to disable this
|
1224 | * check for the main entry point module. This may be useful when preparing a configuration file for an
|
1225 | * un-built project.
|
1226 | */
|
1227 | ignoreMissingEntryPoint?: boolean;
|
1228 | }
|
1229 |
|
1230 | /**
|
1231 | * Runtime options for Extractor.
|
1232 | *
|
1233 | * @public
|
1234 | */
|
1235 | export declare interface IExtractorInvokeOptions {
|
1236 | /**
|
1237 | * An optional TypeScript compiler state. This allows an optimization where multiple invocations of API Extractor
|
1238 | * can reuse the same TypeScript compiler analysis.
|
1239 | */
|
1240 | compilerState?: CompilerState;
|
1241 | /**
|
1242 | * Indicates that API Extractor is running as part of a local build, e.g. on developer's
|
1243 | * machine.
|
1244 | *
|
1245 | * @remarks
|
1246 | * This disables certain validation that would normally be performed for a ship/production build. For example,
|
1247 | * the *.api.md report file is automatically updated in a local build.
|
1248 | *
|
1249 | * The default value is false.
|
1250 | */
|
1251 | localBuild?: boolean;
|
1252 | /**
|
1253 | * If true, API Extractor will include {@link ExtractorLogLevel.Verbose} messages in its output.
|
1254 | */
|
1255 | showVerboseMessages?: boolean;
|
1256 | /**
|
1257 | * If true, API Extractor will print diagnostic information used for troubleshooting problems.
|
1258 | * These messages will be included as {@link ExtractorLogLevel.Verbose} output.
|
1259 | *
|
1260 | * @remarks
|
1261 | * Setting `showDiagnostics=true` forces `showVerboseMessages=true`.
|
1262 | */
|
1263 | showDiagnostics?: boolean;
|
1264 | /**
|
1265 | * Specifies an alternate folder path to be used when loading the TypeScript system typings.
|
1266 | *
|
1267 | * @remarks
|
1268 | * API Extractor uses its own TypeScript compiler engine to analyze your project. If your project
|
1269 | * is built with a significantly different TypeScript version, sometimes API Extractor may report compilation
|
1270 | * errors due to differences in the system typings (e.g. lib.dom.d.ts). You can use the "--typescriptCompilerFolder"
|
1271 | * option to specify the folder path where you installed the TypeScript package, and API Extractor's compiler will
|
1272 | * use those system typings instead.
|
1273 | */
|
1274 | typescriptCompilerFolder?: string;
|
1275 | /**
|
1276 | * An optional callback function that will be called for each `ExtractorMessage` before it is displayed by
|
1277 | * API Extractor. The callback can customize the message, handle it, or discard it.
|
1278 | *
|
1279 | * @remarks
|
1280 | * If a `messageCallback` is not provided, then by default API Extractor will print the messages to
|
1281 | * the STDERR/STDOUT console.
|
1282 | */
|
1283 | messageCallback?: (message: ExtractorMessage) => void;
|
1284 | }
|
1285 |
|
1286 | /**
|
1287 | * Constructor options for `ExtractorMessage`.
|
1288 | */
|
1289 | declare interface IExtractorMessageOptions {
|
1290 | category: ExtractorMessageCategory;
|
1291 | messageId: tsdoc.TSDocMessageId | ExtractorMessageId | ConsoleMessageId | string;
|
1292 | text: string;
|
1293 | sourceFilePath?: string;
|
1294 | sourceFileLine?: number;
|
1295 | sourceFileColumn?: number;
|
1296 | properties?: IExtractorMessageProperties;
|
1297 | logLevel?: ExtractorLogLevel;
|
1298 | }
|
1299 |
|
1300 | /**
|
1301 | * Used by {@link ExtractorMessage.properties}.
|
1302 | *
|
1303 | * @public
|
1304 | */
|
1305 | export declare interface IExtractorMessageProperties {
|
1306 | /**
|
1307 | * A declaration can have multiple names if it is exported more than once.
|
1308 | * If an `ExtractorMessage` applies to a specific export name, this property can indicate that.
|
1309 | *
|
1310 | * @remarks
|
1311 | *
|
1312 | * Used by {@link ExtractorMessageId.InternalMissingUnderscore}.
|
1313 | */
|
1314 | readonly exportName?: string;
|
1315 | }
|
1316 |
|
1317 | /**
|
1318 | * Configures how API Extractor reports error and warning messages produced during analysis.
|
1319 | *
|
1320 | * @remarks
|
1321 | * This is part of the {@link IConfigFile} structure.
|
1322 | *
|
1323 | * @public
|
1324 | */
|
1325 | export declare interface IExtractorMessagesConfig {
|
1326 | /**
|
1327 | * Configures handling of diagnostic messages generating the TypeScript compiler while analyzing the
|
1328 | * input .d.ts files.
|
1329 | */
|
1330 | compilerMessageReporting?: IConfigMessageReportingTable;
|
1331 | /**
|
1332 | * Configures handling of messages reported by API Extractor during its analysis.
|
1333 | */
|
1334 | extractorMessageReporting?: IConfigMessageReportingTable;
|
1335 | /**
|
1336 | * Configures handling of messages reported by the TSDoc parser when analyzing code comments.
|
1337 | */
|
1338 | tsdocMessageReporting?: IConfigMessageReportingTable;
|
1339 | }
|
1340 |
|
1341 | export { }
|