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

TypeError: Cannot read property 'longname' of null #1416

Closed
alexisab opened this issue Jul 26, 2017 · 4 comments
Closed

TypeError: Cannot read property 'longname' of null #1416

alexisab opened this issue Jul 26, 2017 · 4 comments
Labels
Milestone

Comments

@alexisab
Copy link

alexisab commented Jul 26, 2017

I try to setup jsdoc in my project. I've write some simple comments but when I run jsdoc i got this error :

/home/alexis/Documents/programmation/clovis/client/node_modules/jsdoc/lib/jsdoc/src/parser.js:360
        result.memberof = doclet.longname + jsdoc.name.SCOPE.PUNC.INSTANCE;
                                ^

TypeError: Cannot read property 'longname' of null
    at exports.Parser.Parser.astnodeToMemberof (/home/alexis/Documents/programmation/clovis/client/node_modules/jsdoc/lib/jsdoc/src/parser.js:360:33)
    at addSymbolMemberof (/home/alexis/Documents/programmation/clovis/client/node_modules/jsdoc/lib/jsdoc/src/handlers.js:252:31)
    at newSymbolDoclet (/home/alexis/Documents/programmation/clovis/client/node_modules/jsdoc/lib/jsdoc/src/handlers.js:282:13)
    at exports.Parser.<anonymous> (/home/alexis/Documents/programmation/clovis/client/node_modules/jsdoc/lib/jsdoc/src/handlers.js:349:13)
    at emitTwo (events.js:106:13)
    at exports.Parser.emit (events.js:192:7)
    at exports.Visitor.Visitor.visitNode (/home/alexis/Documents/programmation/clovis/client/node_modules/jsdoc/lib/jsdoc/src/visitor.js:566:16)
    at exports.Visitor.Visitor.visit (/home/alexis/Documents/programmation/clovis/client/node_modules/jsdoc/lib/jsdoc/src/visitor.js:468:27)
    at exports.Walker.Walker.recurse (/home/alexis/Documents/programmation/clovis/client/node_modules/jsdoc/lib/jsdoc/src/walker.js:699:38)
    at exports.Parser.Parser._walkAst (/home/alexis/Documents/programmation/clovis/client/node_modules/jsdoc/lib/jsdoc/src/parser.js:265:18)
    at exports.Parser.Parser._parseSourceCode (/home/alexis/Documents/programmation/clovis/client/node_modules/jsdoc/lib/jsdoc/src/parser.js:256:18)
    at exports.Parser.Parser.parse (/home/alexis/Documents/programmation/clovis/client/node_modules/jsdoc/lib/jsdoc/src/parser.js:179:18)
    at Object.module.exports.cli.parseFiles (/home/alexis/Documents/programmation/clovis/client/node_modules/jsdoc/cli.js:370:42)
    at module.exports.cli.main (/home/alexis/Documents/programmation/clovis/client/node_modules/jsdoc/cli.js:239:14)
    at Object.module.exports.cli.runCommand (/home/alexis/Documents/programmation/clovis/client/node_modules/jsdoc/cli.js:189:5)
    at /home/alexis/Documents/programmation/clovis/client/node_modules/jsdoc/jsdoc.js:105:9
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Here is my config file :

{
    "plugins": [],
    "recurseDepth": 3,
    "source": {
        "include": [ "src" ],
        "includePattern": ".+\\.js(doc|x)?$",
        "excludePattern": "(^|\\/|\\\\)_"
    },
    "sourceType": "module",
    "tags": {
        "allowUnknownTags": true,
        "dictionaries": ["jsdoc","closure"]
    },
    "templates": {
        "cleverLinks": false,
        "monospaceLinks": false
    },
    "opts": {
        "template": "node_modules/docdash",
        "destination": "./doc/",
        "readme": "./README.md",
        "verbose": true,
        "recurse": true
    }
}

I run this command (in my package.json, but I got the same error if I use directly jsdoc bin):

jsdoc -c .jsdoc.json

If I remove the recurse option it works 😕

I'm on ubuntu 16.04,
Node v7.6.0
Yarn 0.27.5
jsdoc 3.5.3

@hegemonic
Copy link
Contributor

I can't diagnose this issue without an example of source code that triggers the error. Can you please provide an example?

@alexisab
Copy link
Author

alexisab commented Jul 27, 2017

I've investigate a little bit more and I've found that the problem is from a specific file. I copy paste the code below :


import { connect } from 'react-redux'

import actions from '../actions'
import selectors from '../selectors'
import { TextInput } from '../text-input'
import { ValidationResult } from '../text-input/validation'
import { validatePassword, validateNewPassword } from '../util/password'
import { ScrollPane } from '../scroll-pane'
import { FullscreenPopup } from './popup'

export const EditPassword = connect(state => {
    const me = selectors.me(state)
    const { passwordUpdate } = state

    return {
        me,
        passwordUpdate,
    }
})(class extends React.Component {
    state = {
        old: null,
        new0: null,
        new1: null,
        pendingRequest: false,
        error: null,
    }

    inputs = {}

    send = () => {
        if (!this.valid) {
            return
        }

        const { old, new0 } = this.state
        this.props.dispatch(actions.users.me.password.put.request({
            oldPassword: old,
            newPassword: new0,
        }))
        this.setState({pendingRequest: true})
    }

    componentWillReceiveProps(nextProps) {
        if (!this.state.pendingRequest) {
            return
        }

        const { passwordUpdate } = nextProps
        const { error } = passwordUpdate
        if (error) {
            this.setState({
                error,
                pendingRequest: false,
            })
            return
        }
        if (!this.state.pending) {
            nextProps.onClose()
        }
    }

    validateNew1 = password => {
        if (validateNewPassword(password)) {
            return validateNewPassword(password)
        }

        if (password !== this.state.new0) {
            return new ValidationResult(
                'error', 'Les mots de passe ne correspondent pas')
        }
    }

    get valid() {
        const { old, new0, new1 } = this.state
        return !validatePassword(old) &&
               !validateNewPassword(new0) &&
               !this.validateNew1(new1)
    }

    get buttonDisabled() {
        return this.state.pendingRequest || !this.valid
    }

    get oldError() {
        const { error } = this.state
        if (!error) {
            return null
        }

        if (error.body && error.body.message === 'badOldPassword') {
            return new ValidationResult(
                'error', 'Ancien mot de passe invalide')
        }

        return new ValidationResult(
            'error', 'Une erreur s’est produite')
    }

    oldPasswordChanged = old => {
        this.setState({
            old,
            error: null,
        })
    }

    renderForm = () => (
        <form action="javascript:void(0)">
            <h1>Changement de mot de passe</h1>


            <label>Ancien mot de passe :</label>

            <TextInput placeholder="Ancien mot de passe"
                       type="password"
                       onChange={this.oldPasswordChanged}
                       validator={validatePassword}
                       autoFocus
                       validationResult={this.oldError}
                       ref={input => this.inputs.old = input} />

            <label>Nouveau mot de passe :</label>

            <TextInput placeholder="Nouveau mot de passe"
                       type="password"
                       onChange={new0 => this.setState({new0})}
                       validator={validateNewPassword} />

            <label>Confirmez votre nouveau mot de passe :</label>

            <TextInput placeholder="Confirmez votre nouveau mot de passe"
                       type="password"
                       onChange={new1 => this.setState({new1})}
                       validator={this.validateNew1} />

            <button className="button--primary"
                    type="submit"
                    disabled={this.buttonDisabled}
                    onClick={this.send}>
                Valider
            </button>
        </form>
    )

    render = () => (
        <FullscreenPopup onClose={this.props.onClose}>
            <ScrollPane>
                {this.renderForm()}
            </ScrollPane>
        </FullscreenPopup>
    )
})

If I run the command ./node_modules/.bin/jsdoc file.js where file.js is the code above, I get the same error.

@hegemonic hegemonic added this to the 3.5.4 milestone Jul 29, 2017
@hegemonic
Copy link
Contributor

hegemonic commented Jul 29, 2017

Thanks for the example, @alexisab. I can trigger the error with your example and this reduced test case:

export const Foo = bar(baz => {
})(class {
    qux = () => {}
});

Investigating.

@hegemonic
Copy link
Contributor

Fixed on master and releases/3.5. The fix will be included in JSDoc 3.5.4.

lheberlie added a commit to bsvensson/jsdoc that referenced this issue Aug 15, 2017
3.5.4

* tag '3.5.4':
  3.5.4
  upgrade Babylon
  fix test breakage
  3.5.4 changelog
  prevent crash when an anonymous class is passed as a parameter (jsdoc#1416)
  hide the signature in the heading for classes with hidden constructors (jsdoc#1397)
  update tested Node.js versions
  enable more Babylon options (jsdoc#1411)
  upgrade Babylon
  update .gitignore
  fix problems with methods and properties in classes returned by arrow function expressions (jsdoc#1409)
  followup to 3b604fb
  Deferred process.exit() to allow STDOUT pipe to flush (jsdoc#1408)
  add Slack channel to README
  start 3.5.4-dev

# Conflicts:
#	package.json
lheberlie added a commit to bsvensson/jsdoc that referenced this issue May 2, 2019
* master: (95 commits)
  update dependencies and supported Node.js versions
  3.5.5 changelog
  Prefer copyFileSync from here over native (jsdoc#1440)
  upgrade Babylon
  fix test breakage
  3.5.4 changelog
  prevent crash when an anonymous class is passed as a parameter (jsdoc#1416)
  hide the signature in the heading for classes with hidden constructors (jsdoc#1397)
  chore(package): update nyc to version 11.1.0 (jsdoc#1417)
  add `templates.useShortNamesInLinks` config option (jsdoc#738)
  allow users to specify a highlighter for Markdown code blocks (jsdoc#1412)
  document `longnamesToTree`, plus other doc improvements (jsdoc#43)
  move namespaces and interfaces up in the nav (jsdoc#1410)
  don't pretty-print code blocks that begin with "```plain" (jsdoc#1361)
  improve comment
  make the `exports` tag work correctly when combined with the `enum` tag (jsdoc#970)
  fix Node.js 4.x
  update tested Node.js versions
  use the markdown-it Markdown parser by default (jsdoc#1243)
  enable more Babylon options (jsdoc#1411)
  ...

# Conflicts:
#	.travis.yml
#	README.md
#	lib/jsdoc/src/astbuilder.js
#	lib/jsdoc/src/visitor.js
#	lib/jsdoc/util/markdown.js
#	lib/jsdoc/util/templateHelper.js
#	package.json
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants