Skip to content
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

Better error message on invalid types #1068

Closed
thernstig opened this issue May 9, 2023 · 1 comment · Fixed by #1069
Closed

Better error message on invalid types #1068

thernstig opened this issue May 9, 2023 · 1 comment · Fixed by #1069

Comments

@thernstig
Copy link

Motivation

Better error messages helps users fix faults.

Current behavior

/**
 * @returns {Promise<{publicKey, privateKey}>} - The public and private key
 */

Having the above (incorrect) TypeScript definition yields this output:

> eslint --max-warnings=0 .

Oops! Something went wrong! :(

ESLint: 8.31.0

TypeError: Cannot read properties of undefined (reading 'type')
Occurred while linting /home/userA/code/projectA/server/util/crypt.js:126
Rule: "jsdoc/valid-types"
    at /home/userA/code/projectA/node_modules/eslint-plugin-jsdoc/dist/rules/validTypes.js:99:93
    at _traverse (/home/userA/code/projectA/node_modules/jsdoc-type-pratt-parser/dist/index.js:2500:59)
    at _traverse (/home/userA/code/projectA/node_modules/jsdoc-type-pratt-parser/dist/index.js:2507:25)
    at _traverse (/home/userA/code/projectA/node_modules/jsdoc-type-pratt-parser/dist/index.js:2507:25)
    at traverse (/home/userA/code/projectA/node_modules/jsdoc-type-pratt-parser/dist/index.js:2524:9)
    at validTypeParsing (/home/userA/code/projectA/node_modules/eslint-plugin-jsdoc/dist/rules/validTypes.js:95:36)
    at _default.iterateAllJsdocs (/home/userA/code/projectA/node_modules/eslint-plugin-jsdoc/dist/rules/validTypes.js:194:7)
    at iterate (/home/userA/code/projectA/node_modules/eslint-plugin-jsdoc/dist/iterateJsdoc.js:852:3)
    at callIterator (/home/userA/code/projectA/node_modules/eslint-plugin-jsdoc/dist/iterateJsdoc.js:953:7)
    at *:not(Program) (/home/userA/code/projectA/node_modules/eslint-plugin-jsdoc/dist/iterateJsdoc.js:998:11)

Desired behavior

It would be nice if it could say something like:

The type `Promise<{publicKey, privateKey}>` is not a valid TypeScript type.

With the normal file + line number output.

Alternatives considered

Do not be bad and write invalid types in our code base 😄

@github-actions
Copy link

github-actions bot commented May 9, 2023

🎉 This issue has been resolved in version 44.0.2 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant