oxc-project/oxc · warning · OxcDiagnostic

Missing JSDoc `@yields` type.

Error message

Missing JSDoc `@yields` type.

What it means

This is the oxlint `jsdoc/require-yields-type` diagnostic. It fires when a `@yields` tag on a generator's JSDoc lacks the `{Type}` in curly brackets. Like `require-returns-type`, it makes the yielded value's type machine-readable.

Source

Thrown at crates/oxc_linter/src/rules/jsdoc/require_yields_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_yields_type_diagnostic(span: Span) -> OxcDiagnostic {
    OxcDiagnostic::warn("Missing JSDoc `@yields` type.")
        .with_help("Add {type} to `@yields` tag.")
        .with_label(span)
}

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

declare_oxc_lint!(
    /// ### What it does
    ///
    /// Requires a type on the `@yields` tag.
    ///
    /// ### Why is this bad?
    ///
    /// A `@yields` tag should document the type yielded by the generator.
    ///
    /// ### Examples
    ///

View on GitHub (pinned to e1e7af627c)

Solutions

  1. Add the type: `@yields {Row} Each parsed row.`
  2. Disable the rule when TS signatures already carry yield types.

Example fix

// before
/**
 * @yields Each buffered line.
 */
function* lines(buf) {}

// after
/**
 * @yields {string} Each buffered line.
 */
function* lines(buf) {}
Defensive patterns

Strategy: validation

Validate before calling

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

Prevention

When it happens

Trigger: A documented function has `@yields Each row` — description without a `{Type}` part. Tag aliases (`@yield`) configured through `settings.jsdoc.tagName` are also matched.

Common situations: Hand-written generator docs that describe iteration in prose only; codebases adopting the jsdoc plugin rules wholesale.

Related errors


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