Skip to content

Commit

Permalink
chore: Add test for getters/setters in object literal
Browse files Browse the repository at this point in the history
Resolves #1475
  • Loading branch information
Gerrit0 committed Jan 23, 2021
1 parent 4a539dd commit f546e93
Show file tree
Hide file tree
Showing 5 changed files with 169 additions and 14 deletions.
12 changes: 12 additions & 0 deletions examples/basic/src/mod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,15 @@ export const a = 1;
* Will not be included in mod2
*/
export default function () {}

export const gh1475 = {
get getIt(): number {
return 1;
},
set setIt(n: number) {},

get both(): string {
return "";
},
set both(x: string) {},
};
7 changes: 7 additions & 0 deletions src/test/converter/variables/literal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,10 @@ export const callbackReturn = {
};

export { objectLiteral };

export const gh1475 = {
get getIt(): number {
return 1;
},
set setIt(n: number) {},
};
114 changes: 100 additions & 14 deletions src/test/converter/variables/specs.json
Original file line number Diff line number Diff line change
Expand Up @@ -743,6 +743,91 @@
},
"defaultValue": "..."
},
{
"id": 92,
"name": "gh1475",
"kind": 32,
"kindString": "Variable",
"flags": {
"isConst": true
},
"type": {
"type": "reflection",
"declaration": {
"id": 93,
"name": "__type",
"kind": 65536,
"kindString": "Type literal",
"flags": {},
"children": [
{
"id": 94,
"name": "getIt",
"kind": 262144,
"kindString": "Accessor",
"flags": {},
"getSignature": [
{
"id": 95,
"name": "getIt",
"kind": 524288,
"kindString": "Get signature",
"flags": {},
"type": {
"type": "intrinsic",
"name": "number"
}
}
]
},
{
"id": 96,
"name": "setIt",
"kind": 262144,
"kindString": "Accessor",
"flags": {},
"setSignature": [
{
"id": 97,
"name": "setIt",
"kind": 1048576,
"kindString": "Set signature",
"flags": {},
"parameters": [
{
"id": 98,
"name": "n",
"kind": 32768,
"kindString": "Parameter",
"flags": {},
"type": {
"type": "intrinsic",
"name": "number"
}
}
],
"type": {
"type": "intrinsic",
"name": "void"
}
}
]
}
],
"groups": [
{
"title": "Accessors",
"kind": 262144,
"children": [
94,
96
]
}
]
}
},
"defaultValue": "..."
},
{
"id": 70,
"name": "objectLiteral",
Expand Down Expand Up @@ -1280,21 +1365,22 @@
"kind": 32,
"children": [
50,
92,
70,
31
]
}
]
},
{
"id": 92,
"id": 99,
"name": "variable",
"kind": 1,
"kindString": "Module",
"flags": {},
"children": [
{
"id": 93,
"id": 100,
"name": "myConst",
"kind": 32,
"kindString": "Variable",
Expand All @@ -1308,7 +1394,7 @@
"defaultValue": "15"
},
{
"id": 94,
"id": 101,
"name": "myLet",
"kind": 32,
"kindString": "Variable",
Expand All @@ -1322,7 +1408,7 @@
"defaultValue": "15"
},
{
"id": 95,
"id": 102,
"name": "myVar",
"kind": 32,
"kindString": "Variable",
Expand All @@ -1334,7 +1420,7 @@
"defaultValue": "15"
},
{
"id": 96,
"id": 103,
"name": "x",
"kind": 32,
"kindString": "Variable",
Expand All @@ -1347,7 +1433,7 @@
}
},
{
"id": 97,
"id": 104,
"name": "y",
"kind": 32,
"kindString": "Variable",
Expand All @@ -1366,7 +1452,7 @@
}
},
{
"id": 98,
"id": 105,
"name": "z",
"kind": 32,
"kindString": "Variable",
Expand All @@ -1390,12 +1476,12 @@
"title": "Variables",
"kind": 32,
"children": [
93,
94,
95,
96,
97,
98
100,
101,
102,
103,
104,
105
]
}
]
Expand All @@ -1409,7 +1495,7 @@
1,
15,
30,
92
99
]
}
]
Expand Down
25 changes: 25 additions & 0 deletions src/test/renderer/specs/modules/mod.html
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ <h2>Index</h2>
<h3>Variables</h3>
<ul class="tsd-index-list">
<li class="tsd-kind-variable tsd-parent-kind-module"><a href="mod.html#a" class="tsd-kind-icon">a</a></li>
<li class="tsd-kind-variable tsd-parent-kind-module"><a href="mod.html#gh1475" class="tsd-kind-icon">gh1475</a></li>
</ul>
</section>
<section class="tsd-index-section ">
Expand All @@ -93,6 +94,27 @@ <h3><span class="tsd-flag ts-flagConst">Const</span> a</h3>
<aside class="tsd-sources">
</aside>
</section>
<section class="tsd-panel tsd-member tsd-kind-variable tsd-parent-kind-module">
<a name="gh1475" class="tsd-anchor"></a>
<h3><span class="tsd-flag ts-flagConst">Const</span> gh1475</h3>
<div class="tsd-signature tsd-kind-icon">gh1475<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-symbol">{ </span>both<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">string</span><span class="tsd-signature-symbol">; </span><span class="tsd-signature-symbol">get </span>getIt<span class="tsd-signature-symbol">(): </span><span class="tsd-signature-type">number</span><span class="tsd-signature-symbol">; </span><span class="tsd-signature-symbol">set </span>setIt<span class="tsd-signature-symbol">(</span>n<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">number</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol"> }</span><span class="tsd-signature-symbol"> = ...</span></div>
<aside class="tsd-sources">
</aside>
<div class="tsd-type-declaration">
<h4>Type declaration</h4>
<ul class="tsd-parameters">
<li class="tsd-parameter">
<h5>both<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">string</span></h5>
</li>
<li class="tsd-parameter">
<h5><span class="tsd-signature-symbol">get </span>get<wbr>It<span class="tsd-signature-symbol">(): </span><span class="tsd-signature-type">number</span></h5>
</li>
<li class="tsd-parameter">
<h5><span class="tsd-signature-symbol">set </span>set<wbr>It<span class="tsd-signature-symbol">(</span>n<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">number</span><span class="tsd-signature-symbol">)</span></h5>
</li>
</ul>
</div>
</section>
</section>
<section class="tsd-panel-group tsd-member-group ">
<h2>Functions</h2>
Expand Down Expand Up @@ -172,6 +194,9 @@ <h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">void</spa
<li class=" tsd-kind-variable tsd-parent-kind-module">
<a href="mod.html#a" class="tsd-kind-icon">a</a>
</li>
<li class=" tsd-kind-variable tsd-parent-kind-module">
<a href="mod.html#gh1475" class="tsd-kind-icon">gh1475</a>
</li>
<li class=" tsd-kind-function tsd-parent-kind-module">
<a href="mod.html#default" class="tsd-kind-icon">default</a>
</li>
Expand Down
25 changes: 25 additions & 0 deletions src/test/renderer/specs/modules/mod2.html
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ <h2>Index</h2>
<h3>Variables</h3>
<ul class="tsd-index-list">
<li class="tsd-kind-variable tsd-parent-kind-module"><a href="mod2.html#a" class="tsd-kind-icon">a</a></li>
<li class="tsd-kind-variable tsd-parent-kind-module"><a href="mod2.html#gh1475" class="tsd-kind-icon">gh1475</a></li>
</ul>
</section>
<section class="tsd-index-section ">
Expand All @@ -93,6 +94,27 @@ <h3><span class="tsd-flag ts-flagConst">Const</span> a</h3>
<aside class="tsd-sources">
</aside>
</section>
<section class="tsd-panel tsd-member tsd-kind-variable tsd-parent-kind-module">
<a name="gh1475" class="tsd-anchor"></a>
<h3><span class="tsd-flag ts-flagConst">Const</span> gh1475</h3>
<div class="tsd-signature tsd-kind-icon">gh1475<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-symbol">{ </span>both<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">string</span><span class="tsd-signature-symbol">; </span><span class="tsd-signature-symbol">get </span>getIt<span class="tsd-signature-symbol">(): </span><span class="tsd-signature-type">number</span><span class="tsd-signature-symbol">; </span><span class="tsd-signature-symbol">set </span>setIt<span class="tsd-signature-symbol">(</span>n<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">number</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol"> }</span><span class="tsd-signature-symbol"> = ...</span></div>
<aside class="tsd-sources">
</aside>
<div class="tsd-type-declaration">
<h4>Type declaration</h4>
<ul class="tsd-parameters">
<li class="tsd-parameter">
<h5>both<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">string</span></h5>
</li>
<li class="tsd-parameter">
<h5><span class="tsd-signature-symbol">get </span>get<wbr>It<span class="tsd-signature-symbol">(): </span><span class="tsd-signature-type">number</span></h5>
</li>
<li class="tsd-parameter">
<h5><span class="tsd-signature-symbol">set </span>set<wbr>It<span class="tsd-signature-symbol">(</span>n<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">number</span><span class="tsd-signature-symbol">)</span></h5>
</li>
</ul>
</div>
</section>
</section>
<section class="tsd-panel-group tsd-member-group ">
<h2>Functions</h2>
Expand Down Expand Up @@ -172,6 +194,9 @@ <h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">void</spa
<li class=" tsd-kind-variable tsd-parent-kind-module">
<a href="mod2.html#a" class="tsd-kind-icon">a</a>
</li>
<li class=" tsd-kind-variable tsd-parent-kind-module">
<a href="mod2.html#gh1475" class="tsd-kind-icon">gh1475</a>
</li>
<li class=" tsd-kind-function tsd-parent-kind-module">
<a href="mod2.html#default" class="tsd-kind-icon">default</a>
</li>
Expand Down

0 comments on commit f546e93

Please sign in to comment.