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

Uncaught TypeError: Cannot read property 'names' of undefined #55

Closed
dannyrb opened this issue Nov 9, 2018 · 5 comments
Closed

Uncaught TypeError: Cannot read property 'names' of undefined #55

dannyrb opened this issue Nov 9, 2018 · 5 comments
Labels
docma-web revision v3 Fixed or implemented. To be released.

Comments

@dannyrb
Copy link

dannyrb commented Nov 9, 2018

This bit of code:

.addFilter("$returns", function(symbol) {
        var returns = Array.isArray(symbol) ? symbol : symbol.returns;
        return DocmaWeb.Utils.getFormattedTypeList(docma.apis, returns, {
            delimeter: "|",
            descriptions: true,
            links: templateOpts.symbols.autoLink
        })
    })

Is called, and returns value is: [{description: "Object"}]

When this line is executed:

var types = item.type.names;

item is {description: "Object"} has a type of undefined, which causes this error.

@dannyrb
Copy link
Author

dannyrb commented Nov 9, 2018

I'm able to fix this issue by doing a find and replace for all instances of:

find:
@returns Object

replace:
@returns {Object}

We should probably emit a warning if no type is specified for @returns?

@onury
Copy link
Owner

onury commented Nov 10, 2018

Thanks for reporting.

Well that's actually invalid JSDoc but still we should watch for it. But shouldn't give warnings which would bloat the code too much. It'd be best to validate/lint jsdoc while writing it (via editors, plugins, etc) anyway..

I'm adding conditionals to watch out for this. I'll let you know shortly.

@dannyrb
Copy link
Author

dannyrb commented Nov 10, 2018

@onury, out of curiosity, what does your typical dev setup look like for enforcing valid JSDoc?

@onury
Copy link
Owner

onury commented Nov 10, 2018

Language Linter Rule VSCode
JavaScript ESLint valid-jsdoc extension
TypeScript TSLint jsdoc-format extension

I use VSCode for editor and use/install proper extensions for linting while I write.

I include .eslintrc.json or tslint.json with the project's root. In the npm scripts section of the package.json, I make sure also my build command is preceded with the proper lint command.

@onury onury added Fixed or implemented. To be released. v3 labels Nov 13, 2018
@onury
Copy link
Owner

onury commented Nov 18, 2018

Fixed with Docma v3.0.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docma-web revision v3 Fixed or implemented. To be released.
Projects
None yet
Development

No branches or pull requests

2 participants