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

check-types: Traversing variadic AST (for function(...)) gives "TypeError: Cannot read property 'type' of null" #389

Closed
vapier opened this issue Oct 2, 2019 · 3 comments · Fixed by postmanlabs/postman-collection-transformer#265

Comments

@vapier
Copy link

vapier commented Oct 2, 2019

code snippet:

/** @param {function(...)} callback The function to invoke. */
var subscribe = function(callback) {};

eslint crashes:

TypeError: Cannot read property 'type' of null
Occurred while linting test.js:2
    at .../node_modules/eslint-plugin-jsdoc/dist/rules/checkTypes.js:133:25
    at opt_onEnter (.../node_modules/jsdoctypeparser/lib/traversing.js:19:7)
...

this basically means the func accepts an arbitrary number of arguments of arbitrary type.

  • eslint-6.4.0
  • eslint-15.9.5
  • jsdoctypeparser-5.0.1
@brettz9
Copy link
Collaborator

brettz9 commented Oct 2, 2019

This appears, in a sense, to be an issue with jsdoctypeparser. While we could wrap the call to the traverse function in a try-catch, jsdoctypeparser shouldn't be passing the parsing stage and failing at the traverse stage.

So an issue should really be filed there.

However, I'm not sure what the course of action should be in this case. It is not entirely clear that the variadic format you are using--three dots not followed by anything--is considered acceptable or not (and if so by which jsdoc dialects).

As a workaround (until determination is made on whether to eliminate this possibility or fully support it) you might use ...* or ...any.

@brettz9
Copy link
Collaborator

brettz9 commented Oct 3, 2019

This is now blocking on jsdoctypeparser/jsdoctypeparser#89 .

Feel free to subscribe there.

@brettz9 brettz9 changed the title TypeError: Cannot read property 'type' of null when using "function(...)" check-types: Traversing variadic AST (for function(...)) gives "TypeError: Cannot read property 'type' of null" Oct 3, 2019
@brettz9 brettz9 closed this as completed in 24dd328 Oct 4, 2019
@gajus
Copy link
Owner

gajus commented Oct 4, 2019

🎉 This issue has been resolved in version 15.9.9 🎉

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.

3 participants