TypeStrong / TypeStrong/typedoc
Display and link to `Throws` types
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 8.5k
- Forks
- 775
- PR merge metrics
- No merged PRs in 30d
Description
Search Terms
aliases, errors, exceptions, html, href, links, linking, parsing, signatures, throws, titles, type aliases, types, typography
Problem
Currently, error types are not displayed in typedoc exports. Additionally, errors are displayed in separated blocks of text, when it is possible for there to be multiple of them, which suggests that they should be presented in the same structure as parameters.
Suggested Solution
Referenced error types in docstrings should be shown in the doctype export, in the same way as parameters, for example:
/**
* @param {string} arg1 A string argument.
* @param {number} arg2 An integer argument.
* @returns {Promise<void>} A Promise that resolves when the function is complete.
* @throws {TypeError} If `arg1` is not a string.
* @throws {TypeError} If `arg2` is not an integer.
* @throws {RangeError} If `arg2` being used as an index on `arg1` is out of bounds.
* @throws {CustomExportedError} If unable to get the accumulator value.
*/
...should become:
<div class="tsd-parameters">
<h4 class="tsd-parameters-title">Parameters</h4>
<ul class="tsd-parameter-list">
<li>
<span><span class="tsd-kind-parameter">arg1</span>: <span class="tsd-signature-type">string</span></span>
<div class="tsd-comment tsd-typography"><p>A string argument.</p></div>
</li>
<li>
<span><span class="tsd-kind-parameter">arg2</span>: <span class="tsd-signature-type">number</span></span>
<div class="tsd-comment tsd-typography"><p>An integer argument.</p></div>
</li>
</ul>
</div>
<h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol"><</span><span class="tsd-signature-type">void</span><span class="tsd-signature-symbol">></span></h4>
<p>A Promise that resolves when the function is complete.</p>
<!-- The below is what may appear when this issue is resolved. Note the unordered list format and linked error types. -->
<div class="tsd-throws">
<h4 class="tsd-throws-title">Throws</h4>
<ul class="tsd-throws-list">
<li>
<span><span class="tsd-signature-type">TypeError</span></span>
<div class="tsd-comment tsd-typography"><p>If <code>arg1</code> is not a string.</p></div>
</li>
<li>
<span><span class="tsd-signature-type">TypeError</span></span>
<div class="tsd-comment tsd-typography"><p>If <code>arg2</code> is not an integer.</p></div>
</li>
<li>
<span><span class="tsd-signature-type">RangeError</span></span>
<div class="tsd-comment tsd-typography"><p>If <code>arg2</code> being used as an index on <code>arg1</code> is out of bounds.</p></div>
</li>
<li>
<span><a href="..." class="tsd-signature-type tsd-kind-type-alias">CustomExportedError</a></span>
<div class="tsd-comment tsd-typography"><p>If unable to get the accumulator value.</p></div>
</li>
</ul>
</div>
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing how TypeDoc parses @throws entries and renders typedoc exports as HTML, paying attention to referenced type aliases and multiple error entries. Done means exported error types are linked when applicable and all throws entries appear together in an unordered list with their descriptions.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- documentation
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100