Skip to content

no-undefined-types doesn't know Iterable and IteratorObject #1712

Description

@regseb

Expected behavior

The no-undefined-types rule does not report an error if the variables Iterable and IteratorObject are used in the JSDoc.

tsc knows these two types and doesn't report any errors when they're used in a TypeScript file.

Actual behavior

/home/regseb/testcase/index_jsdoc.js
  2:1  error  The type 'Iterable' is undefined        jsdoc/no-undefined-types
  3:1  error  The type 'IteratorObject' is undefined  jsdoc/no-undefined-types

Files

eslint.config.js

import jsdoc from "eslint-plugin-jsdoc";

export default [
  {
    plugins: { jsdoc },
    rules: {
      "jsdoc/no-undefined-types": "error",
    }
  }
];

index_jsdoc.js

/**
 * @param {...Iterable<any>} its
 * @returns {IteratorObject<any>}
 * @see https://developer.mozilla.org/Web/JavaScript/Reference/Global_Objects/Iterator/concat
 */
const concatIteratorJSDoc = (...its) => {
    return Iterator.from(its.flat());
};

index_typescript.ts

const concatIteratorTypeScript = (...its: Iterable<any>[]): IteratorObject<any> => {
    return Iterator.from(its.flat());
};

package.json

{
    "name": "testcase",
    "version": "1.0.0",
    "type": "module",
    "dependencies": {
        "eslint": "10.5.0",
        "eslint-plugin-jsdoc": "63.0.6",
        "typescript": "6.0.3"
    }
}

Steps

  1. npm i
  2. npx eslint
    /home/regseb/testcase/index_jsdoc.js
      2:1  error  The type 'Iterable' is undefined        jsdoc/no-undefined-types
      3:1  error  The type 'IteratorObject' is undefined  jsdoc/no-undefined-types
    
    ✖ 2 problems (2 errors, 0 warnings)
    
  3. npx tsc --noEmit index_typescript.ts
    # no error
    

Environment

  • Node version: v26.3.1
  • ESLint version: v10.5.0
  • eslint-plugin-jsdoc version: 63.0.6

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions