UNPKG

3.7 kBTypeScriptView Raw
1import { AstEntity } from '../analyzer/AstEntity';
2import { AstNamespaceImport } from '../analyzer/AstNamespaceImport';
3/**
4 * This is a data structure used by the Collector to track an AstEntity that may be emitted in the *.d.ts file.
5 *
6 * @remarks
7 * The additional contextual state beyond AstSymbol is:
8 * - Whether it's an export of this entry point or not
9 * - The nameForEmit, which may get renamed by DtsRollupGenerator._makeUniqueNames()
10 * - The export name (or names, if the same symbol is exported multiple times)
11 */
12export declare class CollectorEntity {
13 /**
14 * The AstEntity that this entry represents.
15 */
16 readonly astEntity: AstEntity;
17 private _exportNames;
18 private _exportNamesSorted;
19 private _singleExportName;
20 private _nameForEmit;
21 private _sortKey;
22 private _astNamespaceImports;
23 constructor(astEntity: AstEntity);
24 /**
25 * The declaration name that will be emitted in a .d.ts rollup. For non-exported declarations,
26 * Collector._makeUniqueNames() may need to rename the declaration to avoid conflicts with other declarations
27 * in that module.
28 */
29 get nameForEmit(): string | undefined;
30 set nameForEmit(value: string | undefined);
31 /**
32 * If this symbol is exported from the entry point, the list of export names.
33 *
34 * @remarks
35 * Note that a given symbol may be exported more than once:
36 * ```
37 * class X { }
38 * export { X }
39 * export { X as Y }
40 * ```
41 */
42 get exportNames(): ReadonlySet<string>;
43 /**
44 * If exportNames contains only one string, then singleExportName is that string.
45 * In all other cases, it is undefined.
46 */
47 get singleExportName(): string | undefined;
48 /**
49 * This is true if exportNames contains only one string, and the declaration can be exported using the inline syntax
50 * such as "export class X { }" instead of "export { X }".
51 */
52 get shouldInlineExport(): boolean;
53 /**
54 * Returns true if this symbol is an export for the entry point being analyzed.
55 */
56 get exported(): boolean;
57 /**
58 * Indicates that it is possible for a consumer of the API to access this declaration, either by importing
59 * it directly, or via some other alias such as a member of a namespace. If a collector entity is not consumable,
60 * then API Extractor will report a ExtractorMessageId.ForgottenExport warning.
61 *
62 * @remarks
63 * Generally speaking, an API item is consumable if:
64 *
65 * - The collector encounters it while crawling the entry point, and it is a root symbol
66 * (i.e. there is a corresponding a CollectorEntity)
67 *
68 * - AND it is exported by the entry point
69 *
70 * However a special case occurs with `AstNamespaceImport` which produces a rollup like this:
71 *
72 * ```ts
73 * declare interface IForgottenExport { }
74 *
75 * declare function member(): IForgottenExport;
76 *
77 * declare namespace ns {
78 * export {
79 * member
80 * }
81 * }
82 * export { ns }
83 * ```
84 *
85 * In this example, `IForgottenExport` is not consumable. Whereas `member()` is consumable as `ns.member()`
86 * even though `member()` itself is not exported.
87 */
88 get consumable(): boolean;
89 /**
90 * Associates this entity with a `AstNamespaceImport`.
91 */
92 addAstNamespaceImports(astNamespaceImport: AstNamespaceImport): void;
93 /**
94 * Adds a new exportName to the exportNames set.
95 */
96 addExportName(exportName: string): void;
97 /**
98 * A sorting key used by DtsRollupGenerator._makeUniqueNames()
99 */
100 getSortKey(): string;
101}
102//# sourceMappingURL=CollectorEntity.d.ts.map
\No newline at end of file