UNPKG

4.59 kBTypeScriptView Raw
1import { AstEntity } from '../analyzer/AstEntity';
2/**
3 * This is a data structure used by the Collector to track an AstEntity that may be emitted in the *.d.ts file.
4 *
5 * @remarks
6 * The additional contextual state beyond AstSymbol is:
7 * - Whether it's an export of this entry point or not
8 * - The nameForEmit, which may get renamed by DtsRollupGenerator._makeUniqueNames()
9 * - The export name (or names, if the same symbol is exported multiple times)
10 */
11export declare class CollectorEntity {
12 /**
13 * The AstEntity that this entry represents.
14 */
15 readonly astEntity: AstEntity;
16 private _exportNames;
17 private _exportNamesSorted;
18 private _singleExportName;
19 private _localExportNamesByParent;
20 private _nameForEmit;
21 private _sortKey;
22 constructor(astEntity: AstEntity);
23 /**
24 * The declaration name that will be emitted in the .d.ts rollup, .api.md, and .api.json files. Generated by
25 * `Collector._makeUniqueNames`. Be aware that the declaration may be renamed to avoid conflicts with (1)
26 * global names (e.g. `Promise`) and (2) if local, other local names across different files.
27 */
28 get nameForEmit(): string | undefined;
29 set nameForEmit(value: string | undefined);
30 /**
31 * The list of export names if this symbol is exported from the entry point.
32 *
33 * @remarks
34 * Note that a given symbol may be exported more than once:
35 * ```
36 * class X { }
37 * export { X }
38 * export { X as Y }
39 * ```
40 */
41 get exportNames(): ReadonlySet<string>;
42 /**
43 * If exportNames contains only one string, then singleExportName is that string.
44 * In all other cases, it is undefined.
45 */
46 get singleExportName(): string | undefined;
47 /**
48 * This is true if exportNames contains only one string, and the declaration can be exported using the inline syntax
49 * such as "export class X { }" instead of "export { X }".
50 */
51 get shouldInlineExport(): boolean;
52 /**
53 * Indicates that this entity is exported from the package entry point. Compare to `CollectorEntity.exported`.
54 */
55 get exportedFromEntryPoint(): boolean;
56 /**
57 * Indicates that this entity is exported from its parent module (i.e. either the package entry point or
58 * a local namespace). Compare to `CollectorEntity.consumable`.
59 *
60 * @remarks
61 * In the example below:
62 *
63 * ```ts
64 * declare function add(): void;
65 * declare namespace calculator {
66 * export {
67 * add
68 * }
69 * }
70 * ```
71 *
72 * Namespace `calculator` is neither exported nor consumable, function `add` is exported (from `calculator`)
73 * but not consumable.
74 */
75 get exported(): boolean;
76 /**
77 * Indicates that it is possible for a consumer of the API to "consume" this entity, either by importing
78 * it directly or via a namespace. If an entity is not consumable, then API Extractor will report an
79 * `ae-forgotten-export` warning. Compare to `CollectorEntity.exported`.
80 *
81 * @remarks
82 * An API item is consumable if:
83 *
84 * 1. It is exported from the top-level entry point OR
85 * 2. It is exported from a consumable parent entity.
86 *
87 * For an example of #2, consider how `AstNamespaceImport` entities are processed. A generated rollup.d.ts
88 * might look like this:
89 *
90 * ```ts
91 * declare function add(): void;
92 * declare namespace calculator {
93 * export {
94 * add
95 * }
96 * }
97 * export { calculator }
98 * ```
99 *
100 * In this example, `add` is exported via the consumable `calculator` namespace.
101 */
102 get consumable(): boolean;
103 /**
104 * Return the first consumable parent that exports this entity. If there is none, returns
105 * `undefined`.
106 */
107 getFirstExportingConsumableParent(): CollectorEntity | undefined;
108 /**
109 * Adds a new export name to the entity.
110 */
111 addExportName(exportName: string): void;
112 /**
113 * Adds a new local export name to the entity.
114 *
115 * @remarks
116 * In the example below:
117 *
118 * ```ts
119 * declare function add(): void;
120 * declare namespace calculator {
121 * export {
122 * add
123 * }
124 * }
125 * ```
126 *
127 * `add` is the local export name for the `CollectorEntity` for `add`.
128 */
129 addLocalExportName(localExportName: string, parent: CollectorEntity): void;
130 /**
131 * A sorting key used by DtsRollupGenerator._makeUniqueNames()
132 */
133 getSortKey(): string;
134}
135//# sourceMappingURL=CollectorEntity.d.ts.map
\No newline at end of file