Skip to content

require-returns-check doesn't handle * types correctly #950

@noahtallen

Description

@noahtallen

Expected behavior

I think this one might be a bug. I expect this to be ok:

/*
 * @param {boolean} bar A fun variable.
 * @returns {*} Anything at all!
 */
function foo( bar ) {
  if ( bar ) {
    return functionWithUnknownReturnType();
  }
}

The * type means the function can return anything, which IMO should include undefined/void/etc. This can be fixed with {*|undefined}, but that's pretty weird :P

Actual behavior

This error happens: JSDoc @returns declaration present but return expression not available in function

ESLint Config

'jsdoc/require-returns-check': 'error'

ESLint sample

See above

Environment

  • Node version: happens in both 16 and 18
  • ESLint version: 8.14.0
  • eslint-plugin-jsdoc version: 39.6.6 (latest)

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions