Skip to content

Native Fetch types are seen as undefined types #1097

Closed
@DrakaSAN

Description

@DrakaSAN

Expected behavior

RequestInfo and RequestInit are recognized as built in types as they are provided and used by the native fetch from nodejs.

Actual behavior

$ npx eslint ./test.js 

/path/to/test.js
  4:1  error  The type 'RequestInfo' is undefined  jsdoc/no-undefined-types
  5:1  error  The type 'RequestInit' is undefined  jsdoc/no-undefined-types

✖ 2 problems (2 errors, 0 warnings)

ESLint Config

{
	"root": true,
	"plugins": ["jsdoc"],
	"parserOptions": {
		"ecmaVersion": 2022,
		"sourceType": "script"
	},
	"env": {
		"node": true,
		"es2022": true
	},
	"rules": {
		"jsdoc/no-undefined-types": ["error"]
	},
	"settings": {
		"jsdoc": {
			"mode": "typescript"
		}
	}
}

ESLint sample

'use strict'

/**
 * @param {RequestInfo} url
 * @param {RequestInit | undefined} options
 * @returns {Promise<Response>}
 */
async function call(url, options) {
	return fetch(url, options)
}

module.exports = { call }

Environment

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

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions