Skip to content

Commit 2ad993e

Browse files
authored
Merge pull request microsoft#1309 from microsoft/octogonz/ae-ctor-cannot-be-static
[api-extractor] Remove ApiConstructor.isStatic, since TypeScript constructors cannot be static
2 parents c5e13a0 + 418dee8 commit 2ad993e

6 files changed

Lines changed: 32 additions & 19 deletions

File tree

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

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
// See LICENSE in the project root for license information.
33

44
import { ApiItemKind } from '../items/ApiItem';
5-
import { ApiStaticMixin, IApiStaticMixinOptions } from '../mixins/ApiStaticMixin';
65
import { IApiDeclaredItemOptions, ApiDeclaredItem } from '../items/ApiDeclaredItem';
76
import { IApiParameterListMixinOptions, ApiParameterListMixin } from '../mixins/ApiParameterListMixin';
87
import { IApiReleaseTagMixinOptions, ApiReleaseTagMixin } from '../mixins/ApiReleaseTagMixin';
@@ -14,7 +13,6 @@ import { IApiReleaseTagMixinOptions, ApiReleaseTagMixin } from '../mixins/ApiRel
1413
export interface IApiConstructorOptions extends
1514
IApiParameterListMixinOptions,
1615
IApiReleaseTagMixinOptions,
17-
IApiStaticMixinOptions,
1816
IApiDeclaredItemOptions {
1917
}
2018

@@ -45,14 +43,10 @@ export interface IApiConstructorOptions extends
4543
*
4644
* @public
4745
*/
48-
export class ApiConstructor extends ApiParameterListMixin(ApiReleaseTagMixin(ApiStaticMixin(ApiDeclaredItem))) {
46+
export class ApiConstructor extends ApiParameterListMixin(ApiReleaseTagMixin(ApiDeclaredItem)) {
4947

50-
public static getCanonicalReference(isStatic: boolean, overloadIndex: number): string {
51-
if (isStatic) {
52-
return `(:constructor,static,${overloadIndex})`;
53-
} else {
54-
return `(:constructor,instance,${overloadIndex})`;
55-
}
48+
public static getCanonicalReference(overloadIndex: number): string {
49+
return `(:constructor,${overloadIndex})`;
5650
}
5751

5852
public constructor(options: IApiConstructorOptions) {
@@ -66,6 +60,6 @@ export class ApiConstructor extends ApiParameterListMixin(ApiReleaseTagMixin(Api
6660

6761
/** @override */
6862
public get canonicalReference(): string {
69-
return ApiConstructor.getCanonicalReference(this.isStatic, this.overloadIndex);
63+
return ApiConstructor.getCanonicalReference(this.overloadIndex);
7064
}
7165
}

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -207,9 +207,8 @@ export class ApiModelGenerator {
207207
private _processApiConstructor(astDeclaration: AstDeclaration, exportedName: string | undefined,
208208
parentApiItem: ApiItemContainerMixin): void {
209209

210-
const isStatic: boolean = (astDeclaration.modifierFlags & ts.ModifierFlags.Static) !== 0;
211210
const overloadIndex: number = this._getOverloadIndex(astDeclaration);
212-
const canonicalReference: string = ApiConstructor.getCanonicalReference(isStatic, overloadIndex);
211+
const canonicalReference: string = ApiConstructor.getCanonicalReference(overloadIndex);
213212

214213
let apiConstructor: ApiConstructor | undefined = parentApiItem.tryGetMember(canonicalReference) as ApiConstructor;
215214

@@ -229,7 +228,7 @@ export class ApiModelGenerator {
229228
const docComment: tsdoc.DocComment | undefined = this._collector.fetchMetadata(astDeclaration).tsdocComment;
230229
const releaseTag: ReleaseTag = this._collector.fetchMetadata(astDeclaration.astSymbol).releaseTag;
231230

232-
apiConstructor = new ApiConstructor({ docComment, releaseTag, isStatic, parameters, overloadIndex,
231+
apiConstructor = new ApiConstructor({ docComment, releaseTag, parameters, overloadIndex,
233232
excerptTokens });
234233

235234
parentApiItem.addMember(apiConstructor);

build-tests/api-documenter-test/etc/api-documenter-test.api.json

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,22 +37,21 @@
3737
"members": [
3838
{
3939
"kind": "Constructor",
40-
"canonicalReference": "(:constructor,instance,0)",
40+
"canonicalReference": "(:constructor,0)",
4141
"docComment": "/**\n * The simple constructor for `DocBaseClass`\n */\n",
4242
"excerptTokens": [
4343
{
4444
"kind": "Content",
4545
"text": "constructor();"
4646
}
4747
],
48-
"isStatic": false,
4948
"releaseTag": "Public",
5049
"overloadIndex": 0,
5150
"parameters": []
5251
},
5352
{
5453
"kind": "Constructor",
55-
"canonicalReference": "(:constructor,instance,1)",
54+
"canonicalReference": "(:constructor,1)",
5655
"docComment": "/**\n * The overloaded constructor for `DocBaseClass`\n */\n",
5756
"excerptTokens": [
5857
{
@@ -76,7 +75,6 @@
7675
"text": ");"
7776
}
7877
],
79-
"isStatic": false,
8078
"releaseTag": "Public",
8179
"overloadIndex": 1,
8280
"parameters": [
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"changes": [
3+
{
4+
"packageName": "@microsoft/api-extractor-model",
5+
"comment": "Fix an issue where ApiConstructor inherited from ApiStaticMixin, but TypeScript constructors cannot be static",
6+
"type": "patch"
7+
}
8+
],
9+
"packageName": "@microsoft/api-extractor-model",
10+
"email": "4673363+octogonz@users.noreply.github.com"
11+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"changes": [
3+
{
4+
"packageName": "@microsoft/api-extractor",
5+
"comment": "Upgrade api-extractor-model to remove ApiConstructor.isStatic, since TypeScript constructors cannot be static",
6+
"type": "patch"
7+
}
8+
],
9+
"packageName": "@microsoft/api-extractor",
10+
"email": "4673363+octogonz@users.noreply.github.com"
11+
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ export class ApiConstructor extends ApiConstructor_base {
6666
// @override (undocumented)
6767
readonly canonicalReference: string;
6868
// (undocumented)
69-
static getCanonicalReference(isStatic: boolean, overloadIndex: number): string;
69+
static getCanonicalReference(overloadIndex: number): string;
7070
// @override (undocumented)
7171
readonly kind: ApiItemKind;
7272
}
@@ -565,7 +565,7 @@ export interface IApiClassOptions extends IApiItemContainerMixinOptions, IApiNam
565565
}
566566

567567
// @public
568-
export interface IApiConstructorOptions extends IApiParameterListMixinOptions, IApiReleaseTagMixinOptions, IApiStaticMixinOptions, IApiDeclaredItemOptions {
568+
export interface IApiConstructorOptions extends IApiParameterListMixinOptions, IApiReleaseTagMixinOptions, IApiDeclaredItemOptions {
569569
}
570570

571571
// @public

0 commit comments

Comments
 (0)