-
-
Notifications
You must be signed in to change notification settings - Fork 158
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
no-undefined-types
: false positives inside functions for type parameters declared by template tags
#559
Comments
I hit this same issue with this reproduction: class {
/**
* @template {object} T
* @param {(node: QDigestNode) => T} callback
* @returns {T[]}
*/
map(callback) {
/** @type {T[]} */
let vals;
vals = [];
this.forEach((node) => vals.push(callback(node)));
return vals;
}
} |
This error apparently also occurs when the type parameter is referenced inside the function by using other TypeScript-supported tags like /**
* @template T
* @param {T} arg
* @returns {[T]}
*/
function genericFunctionExample(arg) {
const result = /** @type {[T]} */ (new Array());
result[0] = arg;
return result;
} |
@brettz9 Regarding the scope of template tags, I could find some docs at Otherwise, from my experience using TypeScript with JsDoc,
|
…nctions within its scope; fixes part of gajus#559
Thank you for the reports and helpful information. While I got some of the more low-hanging fruit by fixing the first problem case (with a nested function), fixing the other cases would seem to require creating our own scope detection based on following the AST This is not currently something on my priority list (unless I may be able to get to it in the course of hopefully addressing #99 at some point), but PRs would be welcome. |
🎉 This issue has been resolved in version 37.5.1 🎉 The release is available on: Your semantic-release bot 📦🚀 |
wrt the mentioned issues with this rule: * gajus/eslint-plugin-jsdoc#559 is resolved * gajus/eslint-plugin-jsdoc#280 - this seems like we can [use this workaround](gajus/eslint-plugin-jsdoc#280 (comment)) including configuration for common builtin types here in hd-scripts
wrt the mentioned issues with this rule: * gajus/eslint-plugin-jsdoc#559 is resolved * gajus/eslint-plugin-jsdoc#280 - this seems like we can [use this workaround](gajus/eslint-plugin-jsdoc#280 (comment)) including configuration for common builtin types here in hd-scripts
Expected behavior
No error.
Actual behavior
7:0 error The type 'T' is undefined jsdoc/no-undefined-types
ESLint Config
ESLint sample
Environment
eslint-plugin-jsdoc
version: 27.0.0The text was updated successfully, but these errors were encountered: