From 48e4046a812074d97d80d779fda20133de8c380c Mon Sep 17 00:00:00 2001 From: mrshllstock Date: Mon, 23 May 2022 13:05:17 -0700 Subject: [PATCH] [api-extractor] cleanup and verify static readonly case --- .../etc/api-documenter-test.api.json | 28 +++++++++++++++++++ .../etc/api-documenter-test.api.md | 2 ++ .../markdown/api-documenter-test.docclass1.md | 1 + ...nter-test.docclass1.staticreadonlything.md | 11 ++++++++ .../yaml/api-documenter-test/docclass1.yml | 13 +++++++++ .../api-documenter-test/src/DocClass1.ts | 2 ++ .../api-extractor-scenarios.api.json | 6 ++-- .../api-extractor-scenarios.api.md | 2 +- .../readonlyDeclarations/rollup.d.ts | 2 +- .../src/readonlyDeclarations/index.ts | 2 +- 10 files changed, 63 insertions(+), 6 deletions(-) create mode 100644 build-tests/api-documenter-test/etc/markdown/api-documenter-test.docclass1.staticreadonlything.md diff --git a/build-tests/api-documenter-test/etc/api-documenter-test.api.json b/build-tests/api-documenter-test/etc/api-documenter-test.api.json index 370f707dc71..7ff939b6140 100644 --- a/build-tests/api-documenter-test/etc/api-documenter-test.api.json +++ b/build-tests/api-documenter-test/etc/api-documenter-test.api.json @@ -790,6 +790,34 @@ }, "isStatic": false }, + { + "kind": "Property", + "canonicalReference": "api-documenter-test!DocClass1.staticReadonlyThing:member", + "docComment": "", + "excerptTokens": [ + { + "kind": "Content", + "text": "static readonly staticReadonlyThing: " + }, + { + "kind": "Content", + "text": "boolean" + }, + { + "kind": "Content", + "text": ";" + } + ], + "isReadonly": true, + "isOptional": false, + "releaseTag": "Public", + "name": "staticReadonlyThing", + "propertyTypeTokenRange": { + "startIndex": 1, + "endIndex": 2 + }, + "isStatic": true + }, { "kind": "Method", "canonicalReference": "api-documenter-test!DocClass1.sumWithExample:member(1)", diff --git a/build-tests/api-documenter-test/etc/api-documenter-test.api.md b/build-tests/api-documenter-test/etc/api-documenter-test.api.md index 828c30e2583..e9e1412b999 100644 --- a/build-tests/api-documenter-test/etc/api-documenter-test.api.md +++ b/build-tests/api-documenter-test/etc/api-documenter-test.api.md @@ -44,6 +44,8 @@ export class DocClass1 extends DocBaseClass implements IDocInterface1, IDocInter // (undocumented) get readonlyProperty(): string; regularProperty: SystemEvent; + // (undocumented) + static readonly staticReadonlyThing: boolean; static sumWithExample(x: number, y: number): number; tableExample(): void; // (undocumented) diff --git a/build-tests/api-documenter-test/etc/markdown/api-documenter-test.docclass1.md b/build-tests/api-documenter-test/etc/markdown/api-documenter-test.docclass1.md index 478eba2e035..f37f7abb0ff 100644 --- a/build-tests/api-documenter-test/etc/markdown/api-documenter-test.docclass1.md +++ b/build-tests/api-documenter-test/etc/markdown/api-documenter-test.docclass1.md @@ -37,6 +37,7 @@ The constructor for this class is marked as internal. Third-party code should no | --- | --- | --- | --- | | [readonlyProperty](./api-documenter-test.docclass1.readonlyproperty.md) | readonly | string | | | [regularProperty](./api-documenter-test.docclass1.regularproperty.md) | | [SystemEvent](./api-documenter-test.systemevent.md) | This is a regular property that happens to use the SystemEvent type. | +| [staticReadonlyThing](./api-documenter-test.docclass1.staticreadonlything.md) | staticreadonly | boolean | | | [writeableProperty](./api-documenter-test.docclass1.writeableproperty.md) | | string | | | [writeonlyProperty](./api-documenter-test.docclass1.writeonlyproperty.md) | | string | API Extractor will surface an ae-missing-getter finding for this property. | diff --git a/build-tests/api-documenter-test/etc/markdown/api-documenter-test.docclass1.staticreadonlything.md b/build-tests/api-documenter-test/etc/markdown/api-documenter-test.docclass1.staticreadonlything.md new file mode 100644 index 00000000000..ecb46a0668b --- /dev/null +++ b/build-tests/api-documenter-test/etc/markdown/api-documenter-test.docclass1.staticreadonlything.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [api-documenter-test](./api-documenter-test.md) > [DocClass1](./api-documenter-test.docclass1.md) > [staticReadonlyThing](./api-documenter-test.docclass1.staticreadonlything.md) + +## DocClass1.staticReadonlyThing property + +Signature: + +```typescript +static readonly staticReadonlyThing: boolean; +``` diff --git a/build-tests/api-documenter-test/etc/yaml/api-documenter-test/docclass1.yml b/build-tests/api-documenter-test/etc/yaml/api-documenter-test/docclass1.yml index b02c6cb4ff3..5914b86ab2b 100644 --- a/build-tests/api-documenter-test/etc/yaml/api-documenter-test/docclass1.yml +++ b/build-tests/api-documenter-test/etc/yaml/api-documenter-test/docclass1.yml @@ -45,6 +45,19 @@ properties: content: 'regularProperty: SystemEvent;' return: type: '' + - name: staticReadonlyThing + uid: 'api-documenter-test!DocClass1.staticReadonlyThing:member' + package: api-documenter-test! + fullName: staticReadonlyThing + summary: '' + remarks: '' + example: [] + isPreview: false + isDeprecated: false + syntax: + content: 'static readonly staticReadonlyThing: boolean;' + return: + type: boolean - name: writeableProperty uid: 'api-documenter-test!DocClass1#writeableProperty:member' package: api-documenter-test! diff --git a/build-tests/api-documenter-test/src/DocClass1.ts b/build-tests/api-documenter-test/src/DocClass1.ts index 313a0f45a95..08c5764ca10 100644 --- a/build-tests/api-documenter-test/src/DocClass1.ts +++ b/build-tests/api-documenter-test/src/DocClass1.ts @@ -169,6 +169,8 @@ export class DocClass1 extends DocBaseClass implements IDocInterface1, IDocInter super(); } + static readonly staticReadonlyThing: boolean; + /** * This is an overloaded function. * @param a - the first string diff --git a/build-tests/api-extractor-scenarios/etc/test-outputs/readonlyDeclarations/api-extractor-scenarios.api.json b/build-tests/api-extractor-scenarios/etc/test-outputs/readonlyDeclarations/api-extractor-scenarios.api.json index 9f6563394b1..c8733be5632 100644 --- a/build-tests/api-extractor-scenarios/etc/test-outputs/readonlyDeclarations/api-extractor-scenarios.api.json +++ b/build-tests/api-extractor-scenarios/etc/test-outputs/readonlyDeclarations/api-extractor-scenarios.api.json @@ -317,12 +317,12 @@ }, { "kind": "Property", - "canonicalReference": "api-extractor-scenarios!MyClass#declaredReadonlyThing:member", + "canonicalReference": "api-extractor-scenarios!MyClass.declaredReadonlyThing:member", "docComment": "", "excerptTokens": [ { "kind": "Content", - "text": "readonly declaredReadonlyThing: " + "text": "static readonly declaredReadonlyThing: " }, { "kind": "Reference", @@ -342,7 +342,7 @@ "startIndex": 1, "endIndex": 2 }, - "isStatic": false + "isStatic": true }, { "kind": "Property", diff --git a/build-tests/api-extractor-scenarios/etc/test-outputs/readonlyDeclarations/api-extractor-scenarios.api.md b/build-tests/api-extractor-scenarios/etc/test-outputs/readonlyDeclarations/api-extractor-scenarios.api.md index c2da0080e20..a3b886324d9 100644 --- a/build-tests/api-extractor-scenarios/etc/test-outputs/readonlyDeclarations/api-extractor-scenarios.api.md +++ b/build-tests/api-extractor-scenarios/etc/test-outputs/readonlyDeclarations/api-extractor-scenarios.api.md @@ -16,7 +16,7 @@ export interface _IInternalThing { // @public (undocumented) export class MyClass { // (undocumented) - readonly declaredReadonlyThing: _IInternalThing; + static readonly declaredReadonlyThing: _IInternalThing; // (undocumented) get _onlyHasGetterThing(): _IInternalThing; tsDocReadonlyThing: _IInternalThing; diff --git a/build-tests/api-extractor-scenarios/etc/test-outputs/readonlyDeclarations/rollup.d.ts b/build-tests/api-extractor-scenarios/etc/test-outputs/readonlyDeclarations/rollup.d.ts index 55210491872..d133028f380 100644 --- a/build-tests/api-extractor-scenarios/etc/test-outputs/readonlyDeclarations/rollup.d.ts +++ b/build-tests/api-extractor-scenarios/etc/test-outputs/readonlyDeclarations/rollup.d.ts @@ -11,7 +11,7 @@ export declare class MyClass { get _writableThing(): _IInternalThing; set _writableThing(value: _IInternalThing); get _onlyHasGetterThing(): _IInternalThing; - readonly declaredReadonlyThing: _IInternalThing; + static readonly declaredReadonlyThing: _IInternalThing; /** * Technically isn't but for testing purposes * @readonly diff --git a/build-tests/api-extractor-scenarios/src/readonlyDeclarations/index.ts b/build-tests/api-extractor-scenarios/src/readonlyDeclarations/index.ts index fbd233d382f..9d627cc9b4c 100644 --- a/build-tests/api-extractor-scenarios/src/readonlyDeclarations/index.ts +++ b/build-tests/api-extractor-scenarios/src/readonlyDeclarations/index.ts @@ -21,7 +21,7 @@ export class MyClass { return { title: 'thing' }; } - readonly declaredReadonlyThing: _IInternalThing; + static readonly declaredReadonlyThing: _IInternalThing; /** * Technically isn't but for testing purposes