oxc-project/oxc · warning · OxcDiagnostic

Missing JSDoc `@throws` type.

Error message

Missing JSDoc `@throws` type.

What it means

This is the oxlint `jsdoc/require-throws-type` diagnostic. It fires when a `@throws` tag on a function's JSDoc lacks the `{Type}` in curly brackets. The rule ensures the exception class is machine-readable so tooling can surface what can be thrown.

Source

Thrown at crates/oxc_linter/src/rules/jsdoc/require_throws_type.rs:12

use oxc_diagnostics::OxcDiagnostic;
use oxc_macros::declare_oxc_lint;
use oxc_span::Span;

use crate::{
    context::LintContext,
    rule::Rule,
    utils::{should_ignore_as_internal, should_ignore_as_private},
};

fn require_throws_type_diagnostic(span: Span) -> OxcDiagnostic {
    OxcDiagnostic::warn("Missing JSDoc `@throws` type.")
        .with_help("Add {type} to `@throws` tag.")
        .with_label(span)
}

#[derive(Debug, Default, Clone)]
pub struct RequireThrowsType;

declare_oxc_lint!(
    /// ### What it does
    ///
    /// Requires a type on the `@throws` tag.
    ///
    /// ### Why is this bad?
    ///
    /// A `@throws` tag should document the type of error that may be thrown.
    ///
    /// ### Examples
    ///

View on GitHub (pinned to e1e7af627c)

Solutions

  1. Add the error type: `@throws {ENOENT} When the config file does not exist.`
  2. Disable the rule when only descriptive `@throws` text is wanted (`"jsdoc/require-throws-type": "off"`).

Example fix

// before
/**
 * @throws When the file is missing.
 */
function readConfig(path) {}

// after
/**
 * @throws {Error} When the file is missing.
 */
function readConfig(path) {}
Defensive patterns

Strategy: validation

Validate before calling

// Flag @throws tags without a {Type} part
const src = require('fs').readFileSync(file, 'utf8');
const noType = /@throws\s+[^{\s]/.exec(src);
if (noType) console.error('jsdoc/require-throws-type will fire:', file);

Prevention

When it happens

Trigger: A documented function has `@throws When the file is missing` — a description but no `{ErrorType}` in braces. The tag name `@throws` (and `@exception` alias where configured) is matched via `settings.jsdoc.tagName`.

Common situations: Doc comments written prose-first without exception classes; projects migrating to oxlint with the full jsdoc rule set enabled for the first time.

Related errors


AI-assisted analysis of oxc-project/oxc@e1e7af627c (2026-08-20). Data as JSON: /api/errors/1cfb78ac70636294. Report an issue: GitHub.