Skip to content

Commit 4326cdc

Browse files
committed
Change overloadIndex to start from 1 as specified by TSDoc
1 parent 0d16e0e commit 4326cdc

4 files changed

Lines changed: 10 additions & 4 deletions

File tree

apps/api-documenter/src/documenters/MarkdownDocumenter.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -793,7 +793,7 @@ export class MarkdownDocumenter {
793793
// For overloaded methods, add a suffix such as "MyClass.myMethod_2".
794794
let qualifiedName: string = hierarchyItem.displayName;
795795
if (ApiParameterListMixin.isBaseClassOf(hierarchyItem)) {
796-
if (hierarchyItem.overloadIndex > 0) {
796+
if (hierarchyItem.overloadIndex > 1) {
797797
qualifiedName += `_${hierarchyItem.overloadIndex}`;
798798
}
799799
}

apps/api-documenter/src/documenters/YamlDocumenter.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -526,7 +526,7 @@ export class YamlDocumenter {
526526
// For overloaded methods, add a suffix such as "MyClass.myMethod_2".
527527
let qualifiedName: string = hierarchyItem.displayName;
528528
if (ApiParameterListMixin.isBaseClassOf(hierarchyItem)) {
529-
if (hierarchyItem.overloadIndex > 0) {
529+
if (hierarchyItem.overloadIndex > 1) {
530530
qualifiedName += `_${hierarchyItem.overloadIndex}`;
531531
}
532532
}

apps/api-extractor-model/src/mixins/ApiParameterListMixin.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,16 +60,21 @@ export interface ApiParameterListMixin extends ApiItem {
6060
*
6161
* ```ts
6262
* export namespace Versioning {
63+
* // TSDoc: Versioning.(addVersions:1)
6364
* export function addVersions(x: number, y: number): number;
65+
*
66+
* // TSDoc: Versioning.(addVersions:2)
6467
* export function addVersions(x: string, y: string): string;
68+
*
69+
* // (implementation)
6570
* export function addVersions(x: number|string, y: number|string): number|string {
6671
* // . . .
6772
* }
6873
* }
6974
* ```
7075
*
7176
* In the above example, there are two overloaded declarations. The overload using numbers will have
72-
* `overloadIndex = 0`. The overload using strings will have `overloadIndex = 1`. The third declaration that
77+
* `overloadIndex = 1`. The overload using strings will have `overloadIndex = 2`. The third declaration that
7378
* accepts all possible inputs is considered part of the implementation, and is not processed by API Extractor.
7479
*/
7580
readonly overloadIndex: number;

apps/api-extractor/src/generators/ApiModelGenerator.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -724,7 +724,8 @@ export class ApiModelGenerator {
724724
let overloadIndex: number | undefined = this._cachedOverloadIndexesByDeclaration.get(astDeclaration);
725725

726726
if (overloadIndex === undefined) {
727-
let nextIndex: number = 0;
727+
// TSDoc index selectors are positive integers counting from 1
728+
let nextIndex: number = 1;
728729
for (const other of allDeclarations) {
729730
// Filter out other declarations that are not overloads. For example, an overloaded function can also
730731
// be a namespace.

0 commit comments

Comments
 (0)