Skip to content

Commit 8545224

Browse files
author
Pavel Zavora
committed
fix(api-extractor): add test for computed property references #3629
1 parent 75f0d91 commit 8545224

File tree

4 files changed

+162
-0
lines changed

4 files changed

+162
-0
lines changed

build-tests/api-extractor-scenarios/etc/referenceTokens/api-extractor-scenarios.api.json

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -807,6 +807,42 @@
807807
"name": "SomeInterface1",
808808
"preserveMemberOrder": false,
809809
"members": [
810+
{
811+
"kind": "PropertySignature",
812+
"canonicalReference": "api-extractor-scenarios!SomeInterface1#[SomeSymbol1]:member",
813+
"docComment": "",
814+
"excerptTokens": [
815+
{
816+
"kind": "Content",
817+
"text": "["
818+
},
819+
{
820+
"kind": "Reference",
821+
"text": "SomeSymbol1",
822+
"canonicalReference": "api-extractor-scenarios!SomeSymbol1:var"
823+
},
824+
{
825+
"kind": "Content",
826+
"text": "]: "
827+
},
828+
{
829+
"kind": "Content",
830+
"text": "() => string"
831+
},
832+
{
833+
"kind": "Content",
834+
"text": ";"
835+
}
836+
],
837+
"isReadonly": false,
838+
"isOptional": false,
839+
"releaseTag": "Public",
840+
"name": "[SomeSymbol1]",
841+
"propertyTypeTokenRange": {
842+
"startIndex": 3,
843+
"endIndex": 4
844+
}
845+
},
810846
{
811847
"kind": "PropertySignature",
812848
"canonicalReference": "api-extractor-scenarios!SomeInterface1#prop:member",
@@ -833,9 +869,93 @@
833869
"startIndex": 1,
834870
"endIndex": 2
835871
}
872+
},
873+
{
874+
"kind": "PropertySignature",
875+
"canonicalReference": "api-extractor-scenarios!SomeInterface1#ThisIsSomeVar1:member",
876+
"docComment": "",
877+
"excerptTokens": [
878+
{
879+
"kind": "Content",
880+
"text": "["
881+
},
882+
{
883+
"kind": "Reference",
884+
"text": "SomeVar1",
885+
"canonicalReference": "api-extractor-scenarios!SomeVar1:var"
886+
},
887+
{
888+
"kind": "Content",
889+
"text": "]: "
890+
},
891+
{
892+
"kind": "Content",
893+
"text": "() => string"
894+
},
895+
{
896+
"kind": "Content",
897+
"text": ";"
898+
}
899+
],
900+
"isReadonly": false,
901+
"isOptional": false,
902+
"releaseTag": "Public",
903+
"name": "ThisIsSomeVar1",
904+
"propertyTypeTokenRange": {
905+
"startIndex": 3,
906+
"endIndex": 4
907+
}
836908
}
837909
],
838910
"extendsTokenRanges": []
911+
},
912+
{
913+
"kind": "Variable",
914+
"canonicalReference": "api-extractor-scenarios!SomeSymbol1:var",
915+
"docComment": "/**\n * @public\n */\n",
916+
"excerptTokens": [
917+
{
918+
"kind": "Content",
919+
"text": "SomeSymbol1: "
920+
},
921+
{
922+
"kind": "Content",
923+
"text": "unique symbol"
924+
}
925+
],
926+
"isReadonly": true,
927+
"releaseTag": "Public",
928+
"name": "SomeSymbol1",
929+
"variableTypeTokenRange": {
930+
"startIndex": 1,
931+
"endIndex": 2
932+
}
933+
},
934+
{
935+
"kind": "Variable",
936+
"canonicalReference": "api-extractor-scenarios!SomeVar1:var",
937+
"docComment": "/**\n * @public\n */\n",
938+
"excerptTokens": [
939+
{
940+
"kind": "Content",
941+
"text": "SomeVar1 = "
942+
},
943+
{
944+
"kind": "Content",
945+
"text": "\"ThisIsSomeVar1\""
946+
}
947+
],
948+
"initializerTokenRange": {
949+
"startIndex": 1,
950+
"endIndex": 2
951+
},
952+
"isReadonly": true,
953+
"releaseTag": "Public",
954+
"name": "SomeVar1",
955+
"variableTypeTokenRange": {
956+
"startIndex": 0,
957+
"endIndex": 0
958+
}
839959
}
840960
]
841961
}

build-tests/api-extractor-scenarios/etc/referenceTokens/api-extractor-scenarios.api.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,20 @@ export interface SomeInterface1 {
7979
prop: number;
8080
}
8181

82+
// @public
83+
export interface SomeInterface1 {
84+
// (undocumented)
85+
[SomeSymbol1]: () => string;
86+
// (undocumented)
87+
[SomeVar1]: () => string;
88+
}
89+
90+
// @public (undocumented)
91+
export const SomeSymbol1: unique symbol;
92+
93+
// @public (undocumented)
94+
export const SomeVar1 = "ThisIsSomeVar1";
95+
8296
// (No @packageDocumentation comment for this package)
8397

8498
```

build-tests/api-extractor-scenarios/etc/referenceTokens/rollup.d.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,4 +86,19 @@ export declare interface SomeInterface1 {
8686
prop: number;
8787
}
8888

89+
/**
90+
* References to computed properties.
91+
* @public
92+
*/
93+
export declare interface SomeInterface1 {
94+
[SomeVar1]: () => string;
95+
[SomeSymbol1]: () => string;
96+
}
97+
98+
/** @public */
99+
export declare const SomeSymbol1: unique symbol;
100+
101+
/** @public */
102+
export declare const SomeVar1 = "ThisIsSomeVar1";
103+
89104
export { }

build-tests/api-extractor-scenarios/src/referenceTokens/index.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,3 +102,16 @@ export function someFunction8({ prop: prop2 }: Lib2Class): void {}
102102
* @public
103103
*/
104104
export class SomeClass4 extends SomeClass5 {}
105+
106+
/** @public */
107+
export const SomeSymbol1 = Symbol('ThisIsSomeSymbol1');
108+
/** @public */
109+
export const SomeVar1 = 'ThisIsSomeVar1';
110+
/**
111+
* References to computed properties.
112+
* @public
113+
*/
114+
export interface SomeInterface1 {
115+
[SomeVar1]: () => string;
116+
[SomeSymbol1]: () => string;
117+
}

0 commit comments

Comments
 (0)