Skip to content

jsdoc/require-returns-check: Support the never type #817

@stof

Description

@stof

Expected behavior

Using the never return type on a method not using return statement should be allowed (it could even check that you don't return).

The never type is not equivalent to the void type (which is what the absence of a @returns represents). So being able to use the never type is useful when using type-checking (through tsc --allow-js --check-js) on the JS code

Actual behavior

The plugin rule complains about the presence of the @returns tag

ESLint Config

{
  "root": true,
  "plugins": ["jsdoc"],
  "rules": {
    "jsdoc/require-returns-check": "error"
  } 
}

ESLint sample

class MyMetric {
  /**
   * @returns {never}
   */
  computeByUsers() {
    throw new Error('Computation grouped by user is not supported for this metric');
  }
}

Environment

  • Node version: 14.18.2
  • ESLint version: 7.32.0
  • eslint-plugin-jsdoc version: 37.1.0

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions