Skip to content

Commit

Permalink
feat: Support for named tuples
Browse files Browse the repository at this point in the history
Closes #1357
  • Loading branch information
Gerrit0 committed Aug 28, 2020
1 parent e136469 commit 3a8560c
Show file tree
Hide file tree
Showing 10 changed files with 57 additions and 27 deletions.
4 changes: 2 additions & 2 deletions examples/basic/src/mixin.ts
Expand Up @@ -39,8 +39,8 @@ export const Mixin1Func = <T extends AnyConstructor<Base>>(base: T) =>
class Mixin1Class extends base {
property1 = 'init';

method1 (arg: Mixin1Type): Mixin1Type[] {
return [ arg, this ];
method1 (arg: Mixin1Type[]): Mixin1Type[] {
return [ ...arg, this ];
}
};

Expand Down
2 changes: 2 additions & 0 deletions examples/basic/src/modules.ts
Expand Up @@ -83,3 +83,5 @@ let typeLiteral: {
valueA?: number;
valueB?: boolean;
};

export type NamedTuple = [name: string, optionalName?: number];
12 changes: 6 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -29,7 +29,7 @@
"minimatch": "^3.0.0",
"progress": "^2.0.3",
"shelljs": "^0.8.4",
"typedoc-default-themes": "^0.11.0"
"typedoc-default-themes": "^0.11.1"
},
"peerDependencies": {
"typescript": ">=4.0.2"
Expand Down
4 changes: 2 additions & 2 deletions src/test/converter/mixin/mixin.ts
Expand Up @@ -37,8 +37,8 @@ export const Mixin1Func = <T extends AnyConstructor<Base>>(base: T) =>
class Mixin1Class extends base {
property1 = 'init';

method1 (arg: Mixin1Type): Mixin1Type[] {
return [ arg, this ];
method1 (arg: Mixin1Type[]): Mixin1Type[] {
return [ ...arg, this ];
}
};

Expand Down
29 changes: 19 additions & 10 deletions src/test/converter/mixin/specs.json
Expand Up @@ -270,9 +270,12 @@
"isExported": true
},
"type": {
"type": "reference",
"id": 6,
"name": "Mixin1Type"
"type": "array",
"elementType": {
"type": "reference",
"id": 6,
"name": "Mixin1Type"
}
}
}
],
Expand Down Expand Up @@ -566,9 +569,12 @@
"isExported": true
},
"type": {
"type": "reference",
"id": 6,
"name": "Mixin1Type"
"type": "array",
"elementType": {
"type": "reference",
"id": 6,
"name": "Mixin1Type"
}
}
}
],
Expand Down Expand Up @@ -793,9 +799,12 @@
"isExported": true
},
"type": {
"type": "reference",
"id": 6,
"name": "Mixin1Type"
"type": "array",
"elementType": {
"type": "reference",
"id": 6,
"name": "Mixin1Type"
}
}
}
],
Expand Down Expand Up @@ -1050,7 +1059,7 @@
"default": {
"type": "intrinsic",
"name": "any"
}
}
}
}
]
Expand Down
Expand Up @@ -186,7 +186,7 @@ <h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">string</s
<a name="method1" class="tsd-anchor"></a>
<h3>method1</h3>
<ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class tsd-is-overwrite tsd-is-inherited">
<li class="tsd-signature tsd-kind-icon">method1<span class="tsd-signature-symbol">(</span>arg<span class="tsd-signature-symbol">: </span><a href="../interfaces/_mixin_.mixin1type.html" class="tsd-signature-type">Mixin1Type</a><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><a href="../interfaces/_mixin_.mixin1type.html" class="tsd-signature-type">Mixin1Type</a><span class="tsd-signature-symbol">[]</span></li>
<li class="tsd-signature tsd-kind-icon">method1<span class="tsd-signature-symbol">(</span>arg<span class="tsd-signature-symbol">: </span><a href="../interfaces/_mixin_.mixin1type.html" class="tsd-signature-type">Mixin1Type</a><span class="tsd-signature-symbol">[]</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><a href="../interfaces/_mixin_.mixin1type.html" class="tsd-signature-type">Mixin1Type</a><span class="tsd-signature-symbol">[]</span></li>
</ul>
<ul class="tsd-descriptions">
<li class="tsd-description">
Expand All @@ -197,7 +197,7 @@ <h3>method1</h3>
<h4 class="tsd-parameters-title">Parameters</h4>
<ul class="tsd-parameters">
<li>
<h5>arg: <a href="../interfaces/_mixin_.mixin1type.html" class="tsd-signature-type">Mixin1Type</a></h5>
<h5>arg: <a href="../interfaces/_mixin_.mixin1type.html" class="tsd-signature-type">Mixin1Type</a><span class="tsd-signature-symbol">[]</span></h5>
</li>
</ul>
<h4 class="tsd-returns-title">Returns <a href="../interfaces/_mixin_.mixin1type.html" class="tsd-signature-type">Mixin1Type</a><span class="tsd-signature-symbol">[]</span></h4>
Expand Down
4 changes: 2 additions & 2 deletions src/test/renderer/specs/interfaces/_mixin_.mixin1type.html
Expand Up @@ -152,7 +152,7 @@ <h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">number</s
<a name="method1" class="tsd-anchor"></a>
<h3>method1</h3>
<ul class="tsd-signatures tsd-kind-method tsd-parent-kind-interface tsd-is-inherited">
<li class="tsd-signature tsd-kind-icon">method1<span class="tsd-signature-symbol">(</span>arg<span class="tsd-signature-symbol">: </span><a href="_mixin_.mixin1type.html" class="tsd-signature-type">Mixin1Type</a><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><a href="_mixin_.mixin1type.html" class="tsd-signature-type">Mixin1Type</a><span class="tsd-signature-symbol">[]</span></li>
<li class="tsd-signature tsd-kind-icon">method1<span class="tsd-signature-symbol">(</span>arg<span class="tsd-signature-symbol">: </span><a href="_mixin_.mixin1type.html" class="tsd-signature-type">Mixin1Type</a><span class="tsd-signature-symbol">[]</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><a href="_mixin_.mixin1type.html" class="tsd-signature-type">Mixin1Type</a><span class="tsd-signature-symbol">[]</span></li>
</ul>
<ul class="tsd-descriptions">
<li class="tsd-description">
Expand All @@ -162,7 +162,7 @@ <h3>method1</h3>
<h4 class="tsd-parameters-title">Parameters</h4>
<ul class="tsd-parameters">
<li>
<h5>arg: <a href="_mixin_.mixin1type.html" class="tsd-signature-type">Mixin1Type</a></h5>
<h5>arg: <a href="_mixin_.mixin1type.html" class="tsd-signature-type">Mixin1Type</a><span class="tsd-signature-symbol">[]</span></h5>
</li>
</ul>
<h4 class="tsd-returns-title">Returns <a href="_mixin_.mixin1type.html" class="tsd-signature-type">Mixin1Type</a><span class="tsd-signature-symbol">[]</span></h4>
Expand Down
4 changes: 2 additions & 2 deletions src/test/renderer/specs/interfaces/_mixin_.mixin2.html
Expand Up @@ -163,7 +163,7 @@ <h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">number</s
<a name="method1" class="tsd-anchor"></a>
<h3>method1</h3>
<ul class="tsd-signatures tsd-kind-method tsd-parent-kind-interface tsd-is-overwrite tsd-is-inherited">
<li class="tsd-signature tsd-kind-icon">method1<span class="tsd-signature-symbol">(</span>arg<span class="tsd-signature-symbol">: </span><a href="_mixin_.mixin1type.html" class="tsd-signature-type">Mixin1Type</a><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><a href="_mixin_.mixin1type.html" class="tsd-signature-type">Mixin1Type</a><span class="tsd-signature-symbol">[]</span></li>
<li class="tsd-signature tsd-kind-icon">method1<span class="tsd-signature-symbol">(</span>arg<span class="tsd-signature-symbol">: </span><a href="_mixin_.mixin1type.html" class="tsd-signature-type">Mixin1Type</a><span class="tsd-signature-symbol">[]</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><a href="_mixin_.mixin1type.html" class="tsd-signature-type">Mixin1Type</a><span class="tsd-signature-symbol">[]</span></li>
</ul>
<ul class="tsd-descriptions">
<li class="tsd-description">
Expand All @@ -174,7 +174,7 @@ <h3>method1</h3>
<h4 class="tsd-parameters-title">Parameters</h4>
<ul class="tsd-parameters">
<li>
<h5>arg: <a href="_mixin_.mixin1type.html" class="tsd-signature-type">Mixin1Type</a></h5>
<h5>arg: <a href="_mixin_.mixin1type.html" class="tsd-signature-type">Mixin1Type</a><span class="tsd-signature-symbol">[]</span></h5>
</li>
</ul>
<h4 class="tsd-returns-title">Returns <a href="_mixin_.mixin1type.html" class="tsd-signature-type">Mixin1Type</a><span class="tsd-signature-symbol">[]</span></h4>
Expand Down
19 changes: 19 additions & 0 deletions src/test/renderer/specs/modules/_modules_.html
Expand Up @@ -85,6 +85,12 @@ <h3>Namespaces</h3>
<li class="tsd-kind-namespace tsd-parent-kind-module"><a href="_modules_.mymodule.html" class="tsd-kind-icon">My<wbr>Module</a></li>
</ul>
</section>
<section class="tsd-index-section ">
<h3>Type aliases</h3>
<ul class="tsd-index-list">
<li class="tsd-kind-type-alias tsd-parent-kind-module"><a href="_modules_.html#namedtuple" class="tsd-kind-icon">Named<wbr>Tuple</a></li>
</ul>
</section>
<section class="tsd-index-section ">
<h3>Variables</h3>
<ul class="tsd-index-list">
Expand All @@ -102,6 +108,16 @@ <h3>Object literals</h3>
</div>
</section>
</section>
<section class="tsd-panel-group tsd-member-group ">
<h2>Type aliases</h2>
<section class="tsd-panel tsd-member tsd-kind-type-alias tsd-parent-kind-module">
<a name="namedtuple" class="tsd-anchor"></a>
<h3>Named<wbr>Tuple</h3>
<div class="tsd-signature tsd-kind-icon">Named<wbr>Tuple<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-symbol">[</span>name<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">string</span><span class="tsd-signature-symbol">, </span>optionalName<span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">number</span><span class="tsd-signature-symbol">]</span></div>
<aside class="tsd-sources">
</aside>
</section>
</section>
<section class="tsd-panel-group tsd-member-group ">
<h2>Variables</h2>
<section class="tsd-panel tsd-member tsd-kind-variable tsd-parent-kind-module">
Expand Down Expand Up @@ -369,6 +385,9 @@ <h5>b<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type
</nav>
<nav class="tsd-navigation secondary menu-sticky">
<ul class="before-current">
<li class=" tsd-kind-type-alias tsd-parent-kind-module">
<a href="_modules_.html#namedtuple" class="tsd-kind-icon">Named<wbr>Tuple</a>
</li>
<li class=" tsd-kind-variable tsd-parent-kind-module">
<a href="_modules_.html#exportedglobalvariable" class="tsd-kind-icon">exported<wbr>Global<wbr>Variable</a>
</li>
Expand Down

0 comments on commit 3a8560c

Please sign in to comment.