UNPKG

40.6 kBTypeScriptView Raw
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
9import { INodePackageJson } from '@rushstack/node-core-library';
10import { JsonSchema } from '@rushstack/node-core-library';
11import { NewlineKind } from '@rushstack/node-core-library';
12import * as tsdoc from '@microsoft/tsdoc';
13
14/**
15 * This class represents the TypeScript compiler state. This allows an optimization where multiple invocations
16 * of API Extractor can reuse the same TypeScript compiler analysis.
17 *
18 * @public
19 */
20export declare class CompilerState {
21 /**
22 * The TypeScript compiler's `Program` object, which represents a complete scope of analysis.
23 */
24 readonly program: unknown;
25 private constructor();
26 /**
27 * Create a compiler state for use with the specified `IExtractorInvokeOptions`.
28 */
29 static create(extractorConfig: ExtractorConfig, options?: ICompilerStateCreateOptions): CompilerState;
30 /**
31 * Given a list of absolute file paths, return a list containing only the declaration
32 * files. Duplicates are also eliminated.
33 *
34 * @remarks
35 * The tsconfig.json settings specify the compiler's input (a set of *.ts source files,
36 * plus some *.d.ts declaration files used for legacy typings). However API Extractor
37 * analyzes the compiler's output (a set of *.d.ts entry point files, plus any legacy
38 * typings). This requires API Extractor to generate a special file list when it invokes
39 * the compiler.
40 *
41 * Duplicates are removed so that entry points can be appended without worrying whether they
42 * may already appear in the tsconfig.json file list.
43 */
44 private static _generateFilePathsForAnalysis;
45 private static _createCompilerHost;
46}
47
48/**
49 * Unique identifiers for console messages reported by API Extractor.
50 *
51 * @remarks
52 *
53 * These strings are possible values for the {@link ExtractorMessage.messageId} property
54 * when the `ExtractorMessage.category` is {@link ExtractorMessageCategory.Console}.
55 *
56 * @public
57 */
58export declare const enum ConsoleMessageId {
59 /**
60 * "Analysis will use the bundled TypeScript version ___"
61 */
62 Preamble = "console-preamble",
63 /**
64 * "The target project appears to use TypeScript ___ which is newer than the bundled compiler engine;
65 * consider upgrading API Extractor."
66 */
67 CompilerVersionNotice = "console-compiler-version-notice",
68 /**
69 * "Found metadata in ___"
70 */
71 FoundTSDocMetadata = "console-found-tsdoc-metadata",
72 /**
73 * "Writing: ___"
74 */
75 WritingDocModelFile = "console-writing-doc-model-file",
76 /**
77 * "Writing package typings: ___"
78 */
79 WritingDtsRollup = "console-writing-dts-rollup",
80 /**
81 * "You have changed the public API signature for this project.
82 * Please copy the file ___ to ___, or perform a local build (which does this automatically).
83 * See the Git repo documentation for more info."
84 *
85 * OR
86 *
87 * "The API report file is missing.
88 * Please copy the file ___ to ___, or perform a local build (which does this automatically).
89 * See the Git repo documentation for more info."
90 */
91 ApiReportNotCopied = "console-api-report-not-copied",
92 /**
93 * "You have changed the public API signature for this project. Updating ___"
94 */
95 ApiReportCopied = "console-api-report-copied",
96 /**
97 * "The API report is up to date: ___"
98 */
99 ApiReportUnchanged = "console-api-report-unchanged",
100 /**
101 * "The API report file was missing, so a new file was created. Please add this file to Git: ___"
102 */
103 ApiReportCreated = "console-api-report-created",
104 /**
105 * "Unable to create the API report file. Please make sure the target folder exists: ___"
106 */
107 ApiReportFolderMissing = "console-api-report-folder-missing",
108 /**
109 * Used for the information printed when the "--diagnostics" flag is enabled.
110 */
111 Diagnostics = "console-diagnostics"
112}
113
114/**
115 * The starting point for invoking the API Extractor tool.
116 * @public
117 */
118export declare class Extractor {
119 /**
120 * Returns the version number of the API Extractor NPM package.
121 */
122 static readonly version: string;
123 /**
124 * Returns the package name of the API Extractor NPM package.
125 */
126 static readonly packageName: string;
127 private static _getPackageJson;
128 /**
129 * Load the api-extractor.json config file from the specified path, and then invoke API Extractor.
130 */
131 static loadConfigAndInvoke(configFilePath: string, options?: IExtractorInvokeOptions): ExtractorResult;
132 /**
133 * Invoke API Extractor using an already prepared `ExtractorConfig` object.
134 */
135 static invoke(extractorConfig: ExtractorConfig, options?: IExtractorInvokeOptions): ExtractorResult;
136 private static _checkCompilerCompatibility;
137 private static _generateRollupDtsFile;
138}
139
140/**
141 * The `ExtractorConfig` class loads, validates, interprets, and represents the api-extractor.json config file.
142 * @public
143 */
144export declare class ExtractorConfig {
145 /**
146 * The JSON Schema for API Extractor config file (api-extractor.schema.json).
147 */
148 static readonly jsonSchema: JsonSchema;
149 /**
150 * The config file name "api-extractor.json".
151 */
152 static readonly FILENAME: string;
153 private static readonly _defaultConfig;
154 private static readonly _declarationFileExtensionRegExp;
155 /** {@inheritDoc IConfigFile.projectFolder} */
156 readonly projectFolder: string;
157 /**
158 * The parsed package.json file for the working package, or undefined if API Extractor was invoked without
159 * a package.json file.
160 */
161 readonly packageJson: INodePackageJson | undefined;
162 /**
163 * The absolute path of the folder containing the package.json file for the working package, or undefined
164 * if API Extractor was invoked without a package.json file.
165 */
166 readonly packageFolder: string | undefined;
167 /** {@inheritDoc IConfigFile.mainEntryPointFilePath} */
168 readonly mainEntryPointFilePath: string;
169 /** {@inheritDoc IConfigFile.bundledPackages} */
170 readonly bundledPackages: string[];
171 /** {@inheritDoc IConfigCompiler.tsconfigFilePath} */
172 readonly tsconfigFilePath: string;
173 /** {@inheritDoc IConfigCompiler.overrideTsconfig} */
174 readonly overrideTsconfig: {} | undefined;
175 /** {@inheritDoc IConfigCompiler.skipLibCheck} */
176 readonly skipLibCheck: boolean;
177 /** {@inheritDoc IConfigApiReport.enabled} */
178 readonly apiReportEnabled: boolean;
179 /** The `reportFolder` path combined with the `reportFileName`. */
180 readonly reportFilePath: string;
181 /** The `reportTempFolder` path combined with the `reportFileName`. */
182 readonly reportTempFilePath: string;
183 /** {@inheritDoc IConfigDocModel.enabled} */
184 readonly docModelEnabled: boolean;
185 /** {@inheritDoc IConfigDocModel.apiJsonFilePath} */
186 readonly apiJsonFilePath: string;
187 /** {@inheritDoc IConfigDtsRollup.enabled} */
188 readonly rollupEnabled: boolean;
189 /** {@inheritDoc IConfigDtsRollup.untrimmedFilePath} */
190 readonly untrimmedFilePath: string;
191 /** {@inheritDoc IConfigDtsRollup.betaTrimmedFilePath} */
192 readonly betaTrimmedFilePath: string;
193 /** {@inheritDoc IConfigDtsRollup.publicTrimmedFilePath} */
194 readonly publicTrimmedFilePath: string;
195 /** {@inheritDoc IConfigDtsRollup.omitTrimmingComments} */
196 readonly omitTrimmingComments: boolean;
197 /** {@inheritDoc IConfigTsdocMetadata.enabled} */
198 readonly tsdocMetadataEnabled: boolean;
199 /** {@inheritDoc IConfigTsdocMetadata.tsdocMetadataFilePath} */
200 readonly tsdocMetadataFilePath: string;
201 /**
202 * Specifies what type of newlines API Extractor should use when writing output files. By default, the output files
203 * will be written with Windows-style newlines.
204 */
205 readonly newlineKind: NewlineKind;
206 /** {@inheritDoc IConfigFile.messages} */
207 readonly messages: IExtractorMessagesConfig;
208 /** {@inheritDoc IConfigFile.testMode} */
209 readonly testMode: boolean;
210 private constructor();
211 /**
212 * Returns a JSON-like string representing the `ExtractorConfig` state, which can be printed to a console
213 * for diagnostic purposes.
214 *
215 * @remarks
216 * This is used by the "--diagnostics" command-line option. The string is not intended to be deserialized;
217 * its format may be changed at any time.
218 */
219 getDiagnosticDump(): string;
220 /**
221 * Returns a simplified file path for use in error messages.
222 * @internal
223 */
224 _getShortFilePath(absolutePath: string): string;
225 /**
226 * Loads the api-extractor.json config file from the specified file path, and prepares an `ExtractorConfig` object.
227 *
228 * @remarks
229 * Loads the api-extractor.json config file from the specified file path. If the "extends" field is present,
230 * the referenced file(s) will be merged. For any omitted fields, the API Extractor default values are merged.
231 *
232 * The result is prepared using `ExtractorConfig.prepare()`.
233 */
234 static loadFileAndPrepare(configJsonFilePath: string): ExtractorConfig;
235 /**
236 * Performs only the first half of {@link ExtractorConfig.loadFileAndPrepare}, providing an opportunity to
237 * modify the object before it is passed to {@link ExtractorConfig.prepare}.
238 *
239 * @remarks
240 * Loads the api-extractor.json config file from the specified file path. If the "extends" field is present,
241 * the referenced file(s) will be merged. For any omitted fields, the API Extractor default values are merged.
242 */
243 static loadFile(jsonFilePath: string): IConfigFile;
244 private static _resolveConfigFileRelativePaths;
245 private static _resolveConfigFileRelativePath;
246 /**
247 * Prepares an `ExtractorConfig` object using a configuration that is provided as a runtime object,
248 * rather than reading it from disk. This allows configurations to be constructed programmatically,
249 * loaded from an alternate source, and/or customized after loading.
250 */
251 static prepare(options: IExtractorConfigPrepareOptions): ExtractorConfig;
252 private static _resolvePathWithTokens;
253 private static _expandStringWithTokens;
254 /**
255 * Returns true if the specified file path has the ".d.ts" file extension.
256 */
257 static hasDtsFileExtension(filePath: string): boolean;
258 /**
259 * Given a path string that may have originally contained expandable tokens such as `<projectFolder>"`
260 * this reports an error if any token-looking substrings remain after expansion (e.g. `c:\blah\<invalid>\blah`).
261 */
262 private static _rejectAnyTokensInPath;
263}
264
265/**
266 * Used with {@link IConfigMessageReportingRule.logLevel} and {@link IExtractorInvokeOptions.messageCallback}.
267 *
268 * @remarks
269 * This is part of the {@link IConfigFile} structure.
270 *
271 * @public
272 */
273export declare const enum ExtractorLogLevel {
274 /**
275 * The message will be displayed as an error.
276 *
277 * @remarks
278 * Errors typically cause the build to fail and return a nonzero exit code.
279 */
280 Error = "error",
281 /**
282 * The message will be displayed as an warning.
283 *
284 * @remarks
285 * Warnings typically cause a production build fail and return a nonzero exit code. For a non-production build
286 * (e.g. using the `--local` option with `api-extractor run`), the warning is displayed but the build will not fail.
287 */
288 Warning = "warning",
289 /**
290 * The message will be displayed as an informational message.
291 *
292 * @remarks
293 * Informational messages may contain newlines to ensure nice formatting of the output,
294 * however word-wrapping is the responsibility of the message handler.
295 */
296 Info = "info",
297 /**
298 * The message will be displayed only when "verbose" output is requested, e.g. using the `--verbose`
299 * command line option.
300 */
301 Verbose = "verbose",
302 /**
303 * The message will be discarded entirely.
304 */
305 None = "none"
306}
307
308/**
309 * This object is used to report an error or warning that occurred during API Extractor's analysis.
310 *
311 * @public
312 */
313export declare class ExtractorMessage {
314 private _handled;
315 private _logLevel;
316 /**
317 * The category of issue.
318 */
319 readonly category: ExtractorMessageCategory;
320 /**
321 * A text string that uniquely identifies the issue type. This identifier can be used to suppress
322 * or configure the reporting of issues, and also to search for help about an issue.
323 */
324 readonly messageId: tsdoc.TSDocMessageId | ExtractorMessageId | ConsoleMessageId | string;
325 /**
326 * The text description of this issue.
327 */
328 readonly text: string;
329 /**
330 * The absolute path to the affected input source file, if there is one.
331 */
332 readonly sourceFilePath: string | undefined;
333 /**
334 * The line number where the issue occurred in the input source file. This is not used if `sourceFilePath`
335 * is undefined. The first line number is 1.
336 */
337 readonly sourceFileLine: number | undefined;
338 /**
339 * The column number where the issue occurred in the input source file. This is not used if `sourceFilePath`
340 * is undefined. The first column number is 1.
341 */
342 readonly sourceFileColumn: number | undefined;
343 /**
344 * Additional contextual information about the message that may be useful when reporting errors.
345 * All properties are optional.
346 */
347 readonly properties: IExtractorMessageProperties;
348 /** @internal */
349 constructor(options: IExtractorMessageOptions);
350 /**
351 * If the {@link IExtractorInvokeOptions.messageCallback} sets this property to true, it will prevent the message
352 * from being displayed by API Extractor.
353 *
354 * @remarks
355 * If the `messageCallback` routes the message to a custom handler (e.g. a toolchain logger), it should
356 * assign `handled = true` to prevent API Extractor from displaying it. Assigning `handled = true` for all messages
357 * would effectively disable all console output from the `Extractor` API.
358 *
359 * If `handled` is set to true, the message will still be included in the count of errors/warnings;
360 * to discard a message entirely, instead assign `logLevel = none`.
361 */
362 handled: boolean;
363 /**
364 * Specifies how the message should be reported.
365 *
366 * @remarks
367 * If the {@link IExtractorInvokeOptions.messageCallback} handles the message (i.e. sets `handled = true`),
368 * it can use the `logLevel` to determine how to display the message.
369 *
370 * Alternatively, if API Extractor is handling the message, the `messageCallback` could assign `logLevel` to change
371 * how it will be processed. However, in general the recommended practice is to configure message routing
372 * using the `messages` section in api-extractor.json.
373 *
374 * To discard a message entirely, assign `logLevel = none`.
375 */
376 logLevel: ExtractorLogLevel;
377 /**
378 * Returns the message formatted with its identifier and file position.
379 * @remarks
380 * Example:
381 * ```
382 * src/folder/File.ts:123:4 - (ae-extra-release-tag) The doc comment should not contain more than one release tag.
383 * ```
384 */
385 formatMessageWithLocation(workingPackageFolderPath: string | undefined): string;
386 formatMessageWithoutLocation(): string;
387}
388
389/**
390 * Specifies a category of messages for use with {@link ExtractorMessage}.
391 * @public
392 */
393export declare const enum ExtractorMessageCategory {
394 /**
395 * Messages originating from the TypeScript compiler.
396 *
397 * @remarks
398 * These strings begin with the prefix "TS" and have a numeric error code.
399 * Example: `TS2551`
400 */
401 Compiler = "Compiler",
402 /**
403 * Messages related to parsing of TSDoc comments.
404 *
405 * @remarks
406 * These strings begin with the prefix "tsdoc-".
407 * Example: `tsdoc-link-tag-unescaped-text`
408 */
409 TSDoc = "TSDoc",
410 /**
411 * Messages related to API Extractor's analysis.
412 *
413 * @remarks
414 * These strings begin with the prefix "ae-".
415 * Example: `ae-extra-release-tag`
416 */
417 Extractor = "Extractor",
418 /**
419 * Console messages communicate the progress of the overall operation. They may include newlines to ensure
420 * nice formatting. They are output in real time, and cannot be routed to the API Report file.
421 *
422 * @remarks
423 * These strings begin with the prefix "console-".
424 * Example: `console-writing-typings-file`
425 */
426 Console = "console"
427}
428
429/**
430 * Unique identifiers for messages reported by API Extractor during its analysis.
431 *
432 * @remarks
433 *
434 * These strings are possible values for the {@link ExtractorMessage.messageId} property
435 * when the `ExtractorMessage.category` is {@link ExtractorMessageCategory.Extractor}.
436 *
437 * @public
438 */
439export declare const enum ExtractorMessageId {
440 /**
441 * "The doc comment should not contain more than one release tag."
442 */
443 ExtraReleaseTag = "ae-extra-release-tag",
444 /**
445 * "This symbol has another declaration with a different release tag."
446 */
447 DifferentReleaseTags = "ae-different-release-tags",
448 /**
449 * "The symbol ___ is marked as ___, but its signature references ___ which is marked as ___."
450 */
451 IncompatibleReleaseTags = "ae-incompatible-release-tags",
452 /**
453 * "___ is exported by the package, but it is missing a release tag (`@alpha`, `@beta`, `@public`, or `@internal`)."
454 */
455 MissingReleaseTag = "ae-missing-release-tag",
456 /**
457 * "The `@packageDocumentation` comment must appear at the top of entry point *.d.ts file."
458 */
459 MisplacedPackageTag = "ae-misplaced-package-tag",
460 /**
461 * "The symbol ___ needs to be exported by the entry point ___."
462 */
463 ForgottenExport = "ae-forgotten-export",
464 /**
465 * "The name ___ should be prefixed with an underscore because the declaration is marked as `@internal`."
466 */
467 InternalMissingUnderscore = "ae-internal-missing-underscore",
468 /**
469 * "Mixed release tags are not allowed for ___ because one of its declarations is marked as `@internal`."
470 */
471 InternalMixedReleaseTag = "ae-internal-mixed-release-tag",
472 /**
473 * "The `@preapproved` tag cannot be applied to ___ because it is not a supported declaration type."
474 */
475 PreapprovedUnsupportedType = "ae-preapproved-unsupported-type",
476 /**
477 * "The `@preapproved` tag cannot be applied to ___ without an `@internal` release tag."
478 */
479 PreapprovedBadReleaseTag = "ae-preapproved-bad-release-tag",
480 /**
481 * "The `@inheritDoc` reference could not be resolved."
482 */
483 UnresolvedInheritDocReference = "ae-unresolved-inheritdoc-reference",
484 /**
485 * "The `@inheritDoc` tag needs a TSDoc declaration reference; signature matching is not supported yet."
486 *
487 * @privateRemarks
488 * In the future, we will implement signature matching so that you can write `{@inheritDoc}` and API Extractor
489 * will find a corresponding member from a base class (or implemented interface). Until then, the tag
490 * always needs an explicit declaration reference such as `{@inhertDoc MyBaseClass.sameMethod}`.
491 */
492 UnresolvedInheritDocBase = "ae-unresolved-inheritdoc-base",
493 /**
494 * "The `@inheritDoc` tag for ___ refers to its own declaration."
495 */
496 CyclicInheritDoc = "ae-cyclic-inherit-doc",
497 /**
498 * "The `@link` reference could not be resolved."
499 */
500 UnresolvedLink = "ae-unresolved-link",
501 /**
502 * "The doc comment for the property ___ must appear on the getter, not the setter."
503 */
504 SetterWithDocs = "ae-setter-with-docs",
505 /**
506 * "The property ___ has a setter but no getter."
507 */
508 MissingGetter = "ae-missing-getter"
509}
510
511/**
512 * This object represents the outcome of an invocation of API Extractor.
513 *
514 * @public
515 */
516export declare class ExtractorResult {
517 /**
518 * The TypeScript compiler state that was used.
519 */
520 readonly compilerState: CompilerState;
521 /**
522 * The API Extractor configuration that was used.
523 */
524 readonly extractorConfig: ExtractorConfig;
525 /**
526 * Whether the invocation of API Extractor was successful. For example, if `succeeded` is false, then the build task
527 * would normally return a nonzero process exit code, indicating that the operation failed.
528 *
529 * @remarks
530 *
531 * Normally the operation "succeeds" if `errorCount` and `warningCount` are both zero. However if
532 * {@link IExtractorInvokeOptions.localBuild} is `true`, then the operation "succeeds" if `errorCount` is zero
533 * (i.e. warnings are ignored).
534 */
535 readonly succeeded: boolean;
536 /**
537 * Returns true if the API report was found to have changed.
538 */
539 readonly apiReportChanged: boolean;
540 /**
541 * Reports the number of errors encountered during analysis.
542 *
543 * @remarks
544 * This does not count exceptions, where unexpected issues prematurely abort the operation.
545 */
546 readonly errorCount: number;
547 /**
548 * Reports the number of warnings encountered during analysis.
549 *
550 * @remarks
551 * This does not count warnings that are emitted in the API report file.
552 */
553 readonly warningCount: number;
554 /** @internal */
555 constructor(properties: ExtractorResult);
556}
557
558/**
559 * Options for {@link CompilerState.create}
560 * @public
561 */
562export declare interface ICompilerStateCreateOptions {
563 /** {@inheritDoc IExtractorInvokeOptions.typescriptCompilerFolder} */
564 typescriptCompilerFolder?: string;
565 /**
566 * Additional .d.ts files to include in the analysis.
567 */
568 additionalEntryPoints?: string[];
569}
570
571/**
572 * Configures how the API report files (*.api.md) will be generated.
573 *
574 * @remarks
575 * This is part of the {@link IConfigFile} structure.
576 *
577 * @public
578 */
579export declare interface IConfigApiReport {
580 /**
581 * Whether to generate an API report.
582 */
583 enabled: boolean;
584 /**
585 * The filename for the API report files. It will be combined with `reportFolder` or `reportTempFolder` to produce
586 * a full output filename.
587 *
588 * @remarks
589 * The file extension should be ".api.md", and the string should not contain a path separator such as `\` or `/`.
590 */
591 reportFileName?: string;
592 /**
593 * Specifies the folder where the API report file is written. The file name portion is determined by
594 * the `reportFileName` setting.
595 *
596 * @remarks
597 * The API report file is normally tracked by Git. Changes to it can be used to trigger a branch policy,
598 * e.g. for an API review.
599 *
600 * The path is resolved relative to the folder of the config file that contains the setting; to change this,
601 * prepend a folder token such as `<projectFolder>`.
602 */
603 reportFolder?: string;
604 /**
605 * Specifies the folder where the temporary report file is written. The file name portion is determined by
606 * the `reportFileName` setting.
607 *
608 * @remarks
609 * After the temporary file is written to disk, it is compared with the file in the `reportFolder`.
610 * If they are different, a production build will fail.
611 *
612 * The path is resolved relative to the folder of the config file that contains the setting; to change this,
613 * prepend a folder token such as `<projectFolder>`.
614 */
615 reportTempFolder?: string;
616}
617
618/**
619 * Determines how the TypeScript compiler engine will be invoked by API Extractor.
620 *
621 * @remarks
622 * This is part of the {@link IConfigFile} structure.
623 *
624 * @public
625 */
626export declare interface IConfigCompiler {
627 /**
628 * Specifies the path to the tsconfig.json file to be used by API Extractor when analyzing the project.
629 *
630 * @remarks
631 * The path is resolved relative to the folder of the config file that contains the setting; to change this,
632 * prepend a folder token such as `<projectFolder>`.
633 *
634 * Note: This setting will be ignored if `overrideTsconfig` is used.
635 */
636 tsconfigFilePath?: string;
637 /**
638 * Provides a compiler configuration that will be used instead of reading the tsconfig.json file from disk.
639 *
640 * @remarks
641 * The value must conform to the TypeScript tsconfig schema:
642 *
643 * http://json.schemastore.org/tsconfig
644 *
645 * If omitted, then the tsconfig.json file will instead be read from the projectFolder.
646 */
647 overrideTsconfig?: {};
648 /**
649 * This option causes the compiler to be invoked with the `--skipLibCheck` option.
650 *
651 * @remarks
652 * This option is not recommended and may cause API Extractor to produce incomplete or incorrect declarations,
653 * but it may be required when dependencies contain declarations that are incompatible with the TypeScript engine
654 * that API Extractor uses for its analysis. Where possible, the underlying issue should be fixed rather than
655 * relying on skipLibCheck.
656 */
657 skipLibCheck?: boolean;
658}
659
660/**
661 * Configures how the doc model file (*.api.json) will be generated.
662 *
663 * @remarks
664 * This is part of the {@link IConfigFile} structure.
665 *
666 * @public
667 */
668export declare interface IConfigDocModel {
669 /**
670 * Whether to generate a doc model file.
671 */
672 enabled: boolean;
673 /**
674 * The output path for the doc model file. The file extension should be ".api.json".
675 *
676 * @remarks
677 * The path is resolved relative to the folder of the config file that contains the setting; to change this,
678 * prepend a folder token such as `<projectFolder>`.
679 */
680 apiJsonFilePath?: string;
681}
682
683/**
684 * Configures how the .d.ts rollup file will be generated.
685 *
686 * @remarks
687 * This is part of the {@link IConfigFile} structure.
688 *
689 * @public
690 */
691export declare interface IConfigDtsRollup {
692 /**
693 * Whether to generate the .d.ts rollup file.
694 */
695 enabled: boolean;
696 /**
697 * Specifies the output path for a .d.ts rollup file to be generated without any trimming.
698 *
699 * @remarks
700 * This file will include all declarations that are exported by the main entry point.
701 *
702 * If the path is an empty string, then this file will not be written.
703 *
704 * The path is resolved relative to the folder of the config file that contains the setting; to change this,
705 * prepend a folder token such as `<projectFolder>`.
706 */
707 untrimmedFilePath?: string;
708 /**
709 * Specifies the output path for a .d.ts rollup file to be generated with trimming for a "beta" release.
710 *
711 * @remarks
712 * This file will include only declarations that are marked as `@public` or `@beta`.
713 *
714 * The path is resolved relative to the folder of the config file that contains the setting; to change this,
715 * prepend a folder token such as `<projectFolder>`.
716 */
717 betaTrimmedFilePath?: string;
718 /**
719 * Specifies the output path for a .d.ts rollup file to be generated with trimming for a "public" release.
720 *
721 * @remarks
722 * This file will include only declarations that are marked as `@public`.
723 *
724 * If the path is an empty string, then this file will not be written.
725 *
726 * The path is resolved relative to the folder of the config file that contains the setting; to change this,
727 * prepend a folder token such as `<projectFolder>`.
728 */
729 publicTrimmedFilePath?: string;
730 /**
731 * When a declaration is trimmed, by default it will be replaced by a code comment such as
732 * "Excluded from this release type: exampleMember". Set "omitTrimmingComments" to true to remove the
733 * declaration completely.
734 */
735 omitTrimmingComments?: boolean;
736}
737
738/**
739 * Configuration options for the API Extractor tool. These options can be constructed programmatically
740 * or loaded from the api-extractor.json config file using the {@link ExtractorConfig} class.
741 *
742 * @public
743 */
744export declare interface IConfigFile {
745 /**
746 * Optionally specifies another JSON config file that this file extends from. This provides a way for
747 * standard settings to be shared across multiple projects.
748 *
749 * @remarks
750 * If the path starts with `./` or `../`, the path is resolved relative to the folder of the file that contains
751 * the `extends` field. Otherwise, the first path segment is interpreted as an NPM package name, and will be
752 * resolved using NodeJS `require()`.
753 */
754 extends?: string;
755 /**
756 * Determines the `<projectFolder>` token that can be used with other config file settings. The project folder
757 * typically contains the tsconfig.json and package.json config files, but the path is user-defined.
758 *
759 * @remarks
760 *
761 * The path is resolved relative to the folder of the config file that contains the setting.
762 *
763 * The default value for `projectFolder` is the token `<lookup>`, which means the folder is determined by traversing
764 * parent folders, starting from the folder containing api-extractor.json, and stopping at the first folder
765 * that contains a tsconfig.json file. If a tsconfig.json file cannot be found in this way, then an error
766 * will be reported.
767 */
768 projectFolder?: string;
769 /**
770 * Specifies the .d.ts file to be used as the starting point for analysis. API Extractor
771 * analyzes the symbols exported by this module.
772 *
773 * @remarks
774 *
775 * The file extension must be ".d.ts" and not ".ts".
776 * The path is resolved relative to the "projectFolder" location.
777 */
778 mainEntryPointFilePath: string;
779 /**
780 * A list of NPM package names whose exports should be treated as part of this package.
781 *
782 * @remarks
783 *
784 * For example, suppose that Webpack is used to generate a distributed bundle for the project `library1`,
785 * and another NPM package `library2` is embedded in this bundle. Some types from `library2` may become part
786 * of the exported API for `library1`, but by default API Extractor would generate a .d.ts rollup that explicitly
787 * imports `library2`. To avoid this, we can specify:
788 *
789 * ```js
790 * "bundledPackages": [ "library2" ],
791 * ```
792 *
793 * This would direct API Extractor to embed those types directly in the .d.ts rollup, as if they had been
794 * local files for `library1`.
795 */
796 bundledPackages?: string[];
797 /**
798 * {@inheritDoc IConfigCompiler}
799 */
800 compiler?: IConfigCompiler;
801 /**
802 * {@inheritDoc IConfigApiReport}
803 */
804 apiReport?: IConfigApiReport;
805 /**
806 * {@inheritDoc IConfigDocModel}
807 */
808 docModel?: IConfigDocModel;
809 /**
810 * {@inheritDoc IConfigDtsRollup}
811 * @beta
812 */
813 dtsRollup?: IConfigDtsRollup;
814 /**
815 * {@inheritDoc IConfigTsdocMetadata}
816 * @beta
817 */
818 tsdocMetadata?: IConfigTsdocMetadata;
819 /**
820 * Specifies what type of newlines API Extractor should use when writing output files.
821 *
822 * @remarks
823 * By default, the output files will be written with Windows-style newlines.
824 * To use POSIX-style newlines, specify "lf" instead.
825 * To use the OS's default newline kind, specify "os".
826 */
827 newlineKind?: 'crlf' | 'lf' | 'os';
828 /**
829 * {@inheritDoc IExtractorMessagesConfig}
830 */
831 messages?: IExtractorMessagesConfig;
832 /**
833 * Set to true when invoking API Extractor's test harness.
834 * @remarks
835 * When `testMode` is true, the `toolVersion` field in the .api.json file is assigned an empty string
836 * to prevent spurious diffs in output files tracked for tests.
837 */
838 testMode?: boolean;
839}
840
841/**
842 * Configures reporting for a given message identifier.
843 *
844 * @remarks
845 * This is part of the {@link IConfigFile} structure.
846 *
847 * @public
848 */
849export declare interface IConfigMessageReportingRule {
850 /**
851 * Specifies whether the message should be written to the the tool's output log.
852 *
853 * @remarks
854 * Note that the `addToApiReportFile` property may supersede this option.
855 */
856 logLevel: ExtractorLogLevel;
857 /**
858 * When `addToApiReportFile` is true: If API Extractor is configured to write an API report file (.api.md),
859 * then the message will be written inside that file; otherwise, the message is instead logged according to
860 * the `logLevel` option.
861 */
862 addToApiReportFile?: boolean;
863}
864
865/**
866 * Specifies a table of reporting rules for different message identifiers, and also the default rule used for
867 * identifiers that do not appear in the table.
868 *
869 * @remarks
870 * This is part of the {@link IConfigFile} structure.
871 *
872 * @public
873 */
874export declare interface IConfigMessageReportingTable {
875 /**
876 * The key is a message identifier for the associated type of message, or "default" to specify the default policy.
877 * For example, the key might be `TS2551` (a compiler message), `tsdoc-link-tag-unescaped-text` (a TSDOc message),
878 * or `ae-extra-release-tag` (a message related to the API Extractor analysis).
879 */
880 [messageId: string]: IConfigMessageReportingRule;
881}
882
883/**
884 * Configures how the tsdoc-metadata.json file will be generated.
885 *
886 * @remarks
887 * This is part of the {@link IConfigFile} structure.
888 *
889 * @public
890 */
891export declare interface IConfigTsdocMetadata {
892 /**
893 * Whether to generate the tsdoc-metadata.json file.
894 */
895 enabled: boolean;
896 /**
897 * Specifies where the TSDoc metadata file should be written.
898 *
899 * @remarks
900 * The path is resolved relative to the folder of the config file that contains the setting; to change this,
901 * prepend a folder token such as `<projectFolder>`.
902 *
903 * The default value is `<lookup>`, which causes the path to be automatically inferred from the `tsdocMetadata`,
904 * `typings` or `main` fields of the project's package.json. If none of these fields are set, the lookup
905 * falls back to `tsdoc-metadata.json` in the package folder.
906 */
907 tsdocMetadataFilePath?: string;
908}
909
910/**
911 * Options for {@link ExtractorConfig.prepare}.
912 *
913 * @public
914 */
915export declare interface IExtractorConfigPrepareOptions {
916 /**
917 * A configuration object as returned by {@link ExtractorConfig.loadFile}.
918 */
919 configObject: IConfigFile;
920 /**
921 * The absolute path of the file that the `configObject` object was loaded from. This is used for error messages
922 * and when probing for `tsconfig.json`.
923 *
924 * @remarks
925 *
926 * If this is omitted, then the `projectFolder` must not be specified using the `<lookup>` token.
927 */
928 configObjectFullPath: string | undefined;
929 /**
930 * The parsed package.json file for the working package, or undefined if API Extractor was invoked without
931 * a package.json file.
932 *
933 * @remarks
934 *
935 * If omitted, then the `<unscopedPackageName>` and `<packageName>` tokens will have default values.
936 */
937 packageJson?: INodePackageJson | undefined;
938 /**
939 * The absolute path of the file that the `packageJson` object was loaded from, or undefined if API Extractor
940 * was invoked without a package.json file.
941 *
942 * @remarks
943 *
944 * This is used for error messages and when resolving paths found in package.json.
945 *
946 * If `packageJsonFullPath` is specified but `packageJson` is omitted, the file will be loaded automatically.
947 */
948 packageJsonFullPath: string | undefined;
949}
950
951/**
952 * Runtime options for Extractor.
953 *
954 * @public
955 */
956export declare interface IExtractorInvokeOptions {
957 /**
958 * An optional TypeScript compiler state. This allows an optimization where multiple invocations of API Extractor
959 * can reuse the same TypeScript compiler analysis.
960 */
961 compilerState?: CompilerState;
962 /**
963 * Indicates that API Extractor is running as part of a local build, e.g. on developer's
964 * machine.
965 *
966 * @remarks
967 * This disables certain validation that would normally be performed for a ship/production build. For example,
968 * the *.api.md report file is automatically updated in a local build.
969 *
970 * The default value is false.
971 */
972 localBuild?: boolean;
973 /**
974 * If true, API Extractor will include {@link ExtractorLogLevel.Verbose} messages in its output.
975 */
976 showVerboseMessages?: boolean;
977 /**
978 * If true, API Extractor will print diagnostic information used for troubleshooting problems.
979 * These messages will be included as {@link ExtractorLogLevel.Verbose} output.
980 *
981 * @remarks
982 * Setting `showDiagnostics=true` forces `showVerboseMessages=true`.
983 */
984 showDiagnostics?: boolean;
985 /**
986 * Specifies an alternate folder path to be used when loading the TypeScript system typings.
987 *
988 * @remarks
989 * API Extractor uses its own TypeScript compiler engine to analyze your project. If your project
990 * is built with a significantly different TypeScript version, sometimes API Extractor may report compilation
991 * errors due to differences in the system typings (e.g. lib.dom.d.ts). You can use the "--typescriptCompilerFolder"
992 * option to specify the folder path where you installed the TypeScript package, and API Extractor's compiler will
993 * use those system typings instead.
994 */
995 typescriptCompilerFolder?: string;
996 /**
997 * An optional callback function that will be called for each `ExtractorMessage` before it is displayed by
998 * API Extractor. The callback can customize the message, handle it, or discard it.
999 *
1000 * @remarks
1001 * If a `messageCallback` is not provided, then by default API Extractor will print the messages to
1002 * the STDERR/STDOUT console.
1003 */
1004 messageCallback?: (message: ExtractorMessage) => void;
1005}
1006
1007/**
1008 * Constructor options for `ExtractorMessage`.
1009 */
1010declare interface IExtractorMessageOptions {
1011 category: ExtractorMessageCategory;
1012 messageId: tsdoc.TSDocMessageId | ExtractorMessageId | ConsoleMessageId | string;
1013 text: string;
1014 sourceFilePath?: string;
1015 sourceFileLine?: number;
1016 sourceFileColumn?: number;
1017 properties?: IExtractorMessageProperties;
1018 logLevel?: ExtractorLogLevel;
1019}
1020
1021/**
1022 * Used by {@link ExtractorMessage.properties}.
1023 *
1024 * @public
1025 */
1026export declare interface IExtractorMessageProperties {
1027 /**
1028 * A declaration can have multiple names if it is exported more than once.
1029 * If an `ExtractorMessage` applies to a specific export name, this property can indicate that.
1030 *
1031 * @remarks
1032 *
1033 * Used by {@link ExtractorMessageId.InternalMissingUnderscore}.
1034 */
1035 readonly exportName?: string;
1036}
1037
1038/**
1039 * Configures how API Extractor reports error and warning messages produced during analysis.
1040 *
1041 * @remarks
1042 * This is part of the {@link IConfigFile} structure.
1043 *
1044 * @public
1045 */
1046export declare interface IExtractorMessagesConfig {
1047 /**
1048 * Configures handling of diagnostic messages generating the TypeScript compiler while analyzing the
1049 * input .d.ts files.
1050 */
1051 compilerMessageReporting?: IConfigMessageReportingTable;
1052 /**
1053 * Configures handling of messages reported by API Extractor during its analysis.
1054 */
1055 extractorMessageReporting?: IConfigMessageReportingTable;
1056 /**
1057 * Configures handling of messages reported by the TSDoc parser when analyzing code comments.
1058 */
1059 tsdocMessageReporting?: IConfigMessageReportingTable;
1060}
1061
1062export { }