Skip to content

new rules: require-throws-type, require-yields-type #1461

@otomad

Description

@otomad

Motivation

It is useful to declare types for @throws and @yields, @next. For example:

/**
 * @throws {TypeError} if `n` is not a number.
 */
function addOne(n) {
    if (typeof n !== "number") throw new TypeError("param n is not a number");
    return n + 1;
}

/**
 * @yields {number}
 * @next {string}
 */
function* gen() {
    
}

Current behavior

It doesn't care if it declares the type for @throws and @yields, @next.

Desired behavior

Force the jsdoc to declare the type for @throws and @yields, @next (or not).

Alternatives considered

These rules can be added by new rules (similar to require-param-type, require-returns-type, and require-property-type), or just add an option type to require-throws and require-yields because it is simpler.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions