UNPKG

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