Skip to content

Commit fd20ea0

Browse files
authored
Merge pull request #3619 from zelliott/namespace-import-fix
[api-extractor] Fix a bug where an item is exported from both the entry point and an exported `AstNamespaceImport`.
2 parents 1f58fa1 + 7119c81 commit fd20ea0

File tree

19 files changed

+833
-194
lines changed

19 files changed

+833
-194
lines changed

apps/api-extractor/src/collector/CollectorEntity.ts

+9-23
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,13 @@ export class CollectorEntity {
9595
return false;
9696
}
9797

98+
/**
99+
* Indicates that this entity is exported from the package entry point. Compare to `CollectorEntity.exported`.
100+
*/
101+
public get exportedFromEntryPoint(): boolean {
102+
return this.exportNames.size > 0;
103+
}
104+
98105
/**
99106
* Indicates that this entity is exported from its parent module (i.e. either the package entry point or
100107
* a local namespace). Compare to `CollectorEntity.consumable`.
@@ -116,7 +123,7 @@ export class CollectorEntity {
116123
*/
117124
public get exported(): boolean {
118125
// Exported from top-level?
119-
if (this.exportNames.size > 0) return true;
126+
if (this.exportedFromEntryPoint) return true;
120127

121128
// Exported from parent?
122129
for (const localExportNames of this._localExportNamesByParent.values()) {
@@ -156,7 +163,7 @@ export class CollectorEntity {
156163
*/
157164
public get consumable(): boolean {
158165
// Exported from top-level?
159-
if (this.exportNames.size > 0) return true;
166+
if (this.exportedFromEntryPoint) return true;
160167

161168
// Exported from consumable parent?
162169
for (const [parent, localExportNames] of this._localExportNamesByParent) {
@@ -168,27 +175,6 @@ export class CollectorEntity {
168175
return false;
169176
}
170177

171-
/**
172-
* Whether the entity has any parent entities.
173-
*
174-
* @remarks
175-
* In the example below:
176-
*
177-
* ```ts
178-
* declare function add(): void;
179-
* declare namespace calculator {
180-
* export {
181-
* add
182-
* }
183-
* }
184-
* ```
185-
*
186-
* The `CollectorEntity` for `calculator` is the parent of the `CollectorEntity` for `add`.
187-
*/
188-
public get hasParents(): boolean {
189-
return this._localExportNamesByParent.size > 0;
190-
}
191-
192178
/**
193179
* Adds a new export name to the entity.
194180
*/

0 commit comments

Comments
 (0)