TypeStrong/typedoc

Display and link to `Throws` types

开放

#3,097 创建于 2026年4月24日

 (1 条评论) (0 个反应) (0 位负责人)HTML (521 个派生)batch import
help wanted

仓库指标

星标
 (4,616 个星标)
PR 合并指标
 (PR 指标待抓取)

描述

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">&lt;</span><span class="tsd-signature-type">void</span><span class="tsd-signature-symbol">&gt;</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>

贡献者指南