Skip to content

Commit 55a4264

Browse files
committed
PR Feedback: Add EntryPoint.importPath property to clarify how ApiEntryPoint will participate in the ApiItem.canonicalReference in the future
1 parent 75fe2c3 commit 55a4264

2 files changed

Lines changed: 23 additions & 3 deletions

File tree

apps/api-extractor-model/src/model/ApiEntryPoint.ts

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,11 @@ export interface IApiEntryPointOptions extends IApiItemContainerMixinOptions, IA
2222
* This is part of the {@link ApiModel} hierarchy of classes, which are serializable representations of
2323
* API declarations.
2424
*
25-
* `ApiEntryPoint` represents the entry point to an NPM package. For example, suppose the package.json file
26-
* looks like this:
25+
* `ApiEntryPoint` represents the entry point to an NPM package. API Extractor does not currently support
26+
* analysis of multiple entry points, but the `ApiEntryPoint` object is included to support a future feature.
27+
* In the current implementation, `ApiEntryPoint.importPath` is always the empty string.
28+
*
29+
* For example, suppose the package.json file looks like this:
2730
*
2831
* ```json
2932
* {
@@ -54,11 +57,27 @@ export class ApiEntryPoint extends ApiItemContainerMixin(ApiNameMixin(ApiItem))
5457
return this.name;
5558
}
5659

60+
/**
61+
* The module path for this entry point, relative to the parent `ApiPackage`. In the current implementation,
62+
* this is always the empty string, indicating the default entry point.
63+
*
64+
* @remarks
65+
*
66+
* API Extractor does not currently support analysis of multiple entry points. If that feature is implemented
67+
* in the future, then the `ApiEntryPoint.importPath` will be used to distinguish different entry points,
68+
* for example: `controls/Button` in `import { Button } from "example-package/controls/Button";`.
69+
*
70+
* The `ApiEntryPoint.name` property stores the same value as `ApiEntryPoint.importPath`.
71+
*/
72+
public get importPath(): string {
73+
return this.name;
74+
}
75+
5776
/** @beta @override */
5877
public buildCanonicalReference(): DeclarationReference {
5978

6079
if (this.parent instanceof ApiPackage) {
61-
return DeclarationReference.package(this.parent.name, this.name);
80+
return DeclarationReference.package(this.parent.name, this.importPath);
6281
}
6382

6483
return DeclarationReference.empty();

common/reviews/api/api-extractor-model.api.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ export class ApiEntryPoint extends ApiEntryPoint_base {
133133
buildCanonicalReference(): DeclarationReference;
134134
// @override (undocumented)
135135
readonly containerKey: string;
136+
readonly importPath: string;
136137
// @override (undocumented)
137138
readonly kind: ApiItemKind;
138139
}

0 commit comments

Comments
 (0)