Skip to content

valid-types foails for imported typedefs #1093

@l0ner

Description

@l0ner

Expected behavior

When importing types defined in another file using this one liner:

/** @typedef {import('../types/foo.js').Foo} Foo */

(as suggested in jsdoc/jsdoc#1645 (comment))

eslint complains about syntax error

/src/foo/file.js
  6:1  warning  Syntax error in type: import('../types/sometype.js').SomeType    jsdoc/valid-types

Even whan the type gets imported correctly.

Actual behavior

ESlint should not complain about this kind of typedefs.

ESLint Config

{
	"root": true,
	"env": {
		"commonjs": false,
		"es2021": true,
		"node": true
	},
	"plugins": [
		"jsdoc",
		"eslint-comments"
	],
	"extends": [
		"eslint:recommended",
		"plugin:jsdoc/recommended"
	],
	"parserOptions": {
		"ecmaVersion": 13,
		"sourceType": "module"
	}
}

ESLint sample

File types/foo.js

/**
 * My Type
 * @typedef {object} Foo
 * @property {string} Bar - This is bar
 */

File index.js

/** @typedef {import('../types/foo.js').Foo} Foo */

Environment

  • Node version: v18.16.0
  • ESLint version v8.41.0
  • eslint-plugin-jsdoc version: 44.2.5

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions