Expected behavior
If I import a type with the JSDoc @import and I use an property of this type, ESLint shouldn't report an error for the jsdoc/no-undefined-types rule.
Actual behavior
ESLint reports error: The type 'Foo.Bar' is undefined
Files
eslint.config.js
import jsdoc from "eslint-plugin-jsdoc";
export default [
{
plugins: { jsdoc },
rules: {
"jsdoc/no-undefined-types": "error",
}
}
];
type.d.ts
export namespace Foo {
type Bar = string;
}
index.js
/**
* @import { Foo } from "./type.d.ts"
*/
/**
* @type {Foo.Bar}
*/
const baz = 42;
package.json
{
"name": "testcase",
"version": "1.0.0",
"type": "module",
"dependencies": {
"eslint": "9.29.0",
"eslint-plugin-jsdoc": "51.2.1",
"typescript": "5.8.3"
}
}
To reproduce
-
npm install
-
npx eslint
/home/regseb/testcase/index.js
6:1 error The type 'Foo.Bar' is undefined jsdoc/no-undefined-types
✖ 1 problem (1 error, 0 warnings)
Environment
- Node version: v22.15.0
- ESLint version: v9.29.0
eslint-plugin-jsdoc version: 51.2.1
Additional information
Type declaration and import is correct, because TypeScript finds the Bar property and reports type error:
-
npx tsc --checkJs --noEmit index.js
index.js:8:7 - error TS2322: Type 'number' is not assignable to type 'string'.
8 const baz = 42;
~~~
Found 1 error in index.js:8
Expected behavior
If I import a type with the JSDoc
@importand I use an property of this type, ESLint shouldn't report an error for thejsdoc/no-undefined-typesrule.Actual behavior
ESLint reports error: The type 'Foo.Bar' is undefined
Files
eslint.config.jstype.d.tsindex.jspackage.json{ "name": "testcase", "version": "1.0.0", "type": "module", "dependencies": { "eslint": "9.29.0", "eslint-plugin-jsdoc": "51.2.1", "typescript": "5.8.3" } }To reproduce
npm installnpx eslintEnvironment
eslint-plugin-jsdocversion: 51.2.1Additional information
Type declaration and import is correct, because TypeScript finds the
Barproperty and reports type error:npx tsc --checkJs --noEmit index.js