Skip to content

Native Fetch types are seen as undefined types #1097

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
DrakaSAN opened this issue May 26, 2023 · 2 comments
Closed

Native Fetch types are seen as undefined types #1097

DrakaSAN opened this issue May 26, 2023 · 2 comments

Comments

@DrakaSAN
Copy link

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
@DrakaSAN
Copy link
Author

Interestingly, while using eslint directly show this error, VSCode itself seems to not stumble on it

@brettz9
Copy link
Collaborator

brettz9 commented May 26, 2023

This is effectively a dupe of #888 . Can be tracked there.

@brettz9 brettz9 closed this as completed May 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants