esdoc / esdoc-plugins

MIT License
139 stars 74 forks source link

Crash esdoc-accessor-plugin "Cannot read property 'charAt' of null" #28

Open lll000111 opened 7 years ago

lll000111 commented 7 years ago
.\one\node_modules\esdoc-accessor-plugin\src\Plugin.js:16
        if (autoPrivate && doc.name.charAt(0) === '_') {
                                   ^

TypeError: Cannot read property 'charAt' of null
    at Plugin.onHandleDocs (.\one\node_modules\esdoc-accessor-plugin\src\Plugin.js:16:36)
    at Plugin._execHandler (.\one\node_modules\esdoc\out\src\Plugin\Plugin.js:55:26)
    at Plugin.onHandleDocs (.\one\node_modules\esdoc\out\src\Plugin\Plugin.js:135:10)
    at Function.generate (.s\one\node_modules\esdoc\out\src\ESDoc.js:133:32)
    at ESDocCLI.exec (.\one\node_modules\esdoc\out\src\ESDocCLI.js:71:23)
    at Object.<anonymous> (.\one\node_modules\esdoc\out\src\ESDocCLI.js:182:7)
    at Module._compile (module.js:624:30)
    at Object.Module._extensions..js (module.js:635:10)
    at Module.load (module.js:545:32)
    at tryModuleLoad (module.js:508:12)
vihanb commented 7 years ago

This seems to happen if you have a@typedef {T} but don't specify a name

alexdiliberto commented 6 years ago

Also seeing this if I use a class field which has a dasherized name;

export default class MyComponent {
    /* I am a prop */
    'my-prop': 123;
}

doc.name will be undefined in this case and the Plugin will throw the TypeError

DanielRuf commented 5 years ago

undefined !== null

Simply change it to if (autoPrivate && doc.name && doc.name.charAt(0) === '_') {