jsdoc icon indicating copy to clipboard operation
jsdoc copied to clipboard

ERROR: Unable to parse a tag's type expression for source file

Open zababurinsv opened this issue 3 years ago • 2 comments

When i want hed created docs from existen files i getting error

this

ERROR: Unable to parse a tag's type expression for source file /home/zb/Desktop/newkind-service/palette/src/github.com/zababurinsv/newkind-db/frontend/src/components/newkind-db/modules/index.mjs in line 101557 with tag title "typedef" and text "{import('./').MfsContext} MfsContext": Invalid type expression "import('./').MfsContext": Expected "!", "=", "?", "[]", "|", or end of input but "(" found.
ERROR: Unable to parse a tag's type expression for source file /home/zb/Desktop/newkind-service/palette/src/github.com/zababurinsv/newkind-db/frontend/src/components/newkind-db/modules/index.mjs in line 101587 with tag title "type" and text "{import('ipfs-core-types/src/files').API["mkdir"]}": Invalid type expression "import('ipfs-core-types/src/files').API["mkdir"]": Expected "!", "=", "?", "[]", "|", or end of input but "(" found.

and this

ERROR: Unable to parse /home/zb/Desktop/newkind-service/palette/src/github.com/zababurinsv/newkind-db/frontend/src/components/newkind-db/node_modules/@parcel/babel-ast-utils/src/babelErrorUtils.js: Unexpected token (2:12)
ERROR: Unable to parse /home/zb/Desktop/newkind-service/palette/src/github.com/zababurinsv/newkind-db/frontend/src/components/newkind-db/node_modules/@parcel/babel-ast-utils/src/index.js: Unexpected token (3:12)
/home/zb/Desktop/newkind-service/node_modules/jsdoc/lib/jsdoc/src/parser.js:392
            if (doclet.memberof) {
                       ^

TypeError: Cannot read properties of null (reading 'memberof')
    at Parser.astnodeToMemberof (/home/zb/Desktop/newkind-service/node_modules/jsdoc/lib/jsdoc/src/parser.js:392:24)
    at addSymbolMemberof (/home/zb/Desktop/newkind-service/node_modules/jsdoc/lib/jsdoc/src/handlers.js:268:31)
    at newSymbolDoclet (/home/zb/Desktop/newkind-service/node_modules/jsdoc/lib/jsdoc/src/handlers.js:298:13)
    at Parser.<anonymous> (/home/zb/Desktop/newkind-service/node_modules/jsdoc/lib/jsdoc/src/handlers.js:365:13)
    at Parser.emit (node:events:390:28)
    at Visitor.visitNode (/home/zb/Desktop/newkind-service/node_modules/jsdoc/lib/jsdoc/src/visitor.js:846:20)
    at Visitor.visit (/home/zb/Desktop/newkind-service/node_modules/jsdoc/lib/jsdoc/src/visitor.js:756:21)
    at Walker.recurse (/home/zb/Desktop/newkind-service/node_modules/jsdoc/lib/jsdoc/src/walker.js:694:42)
    at Parser._walkAst (/home/zb/Desktop/newkind-service/node_modules/jsdoc/lib/jsdoc/src/parser.js:305:22)
    at Parser._parseSourceCode (/home/zb/Desktop/newkind-service/node_modules/jsdoc/lib/jsdoc/src/parser.js:296:22)
    at Parser.parse (/home/zb/Desktop/newkind-service/node_modules/jsdoc/lib/jsdoc/src/parser.js:202:22)
    at Object.module.exports.cli.parseFiles (/home/zb/Desktop/newkind-service/node_modules/jsdoc/cli.js:365:46)
    at module.exports.cli.main (/home/zb/Desktop/newkind-service/node_modules/jsdoc/cli.js:234:18)
    at Object.module.exports.cli.runCommand (/home/zb/Desktop/newkind-service/node_modules/jsdoc/cli.js:186:9)
    at /home/zb/Desktop/newkind-service/node_modules/jsdoc/jsdoc.js:93:9
    at Object.<anonymous> (/home/zb/Desktop/newkind-service/node_modules/jsdoc/jsdoc.js:94:3)


error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Process finished with exit code 1



Input code


// regex for testing for non-latin characters
var $37b7467ccb67e16e$var$_nonLatinRegex = /[^\\u0000-\\u00ff]/;
/**
 * Pretty prints an ASN.1 object to a string.
 *
 * @param obj the object to write out.
 * @param level the level in the tree.
 * @param indentation the indentation to use.
 *
 * @return the string.
 */ $37b7467ccb67e16e$var$asn1.prettyPrint = function(obj, level, indentation) {
    var rval = '';
    // set default level and indentation
    level = level || 0;
    indentation = indentation || 2;
    // start new line for deep levels
    if (level > 0) rval += '\n';
    // create indent
    var indent = '';
    for(var i = 0; i < level * indentation; ++i)indent += ' ';
    // print class:type
    rval += indent + 'Tag: ';
    switch(obj.tagClass){
        case $37b7467ccb67e16e$var$asn1.Class.UNIVERSAL:
            rval += 'Universal:';
            break;
        case $37b7467ccb67e16e$var$asn1.Class.APPLICATION:
            rval += 'Application:';
            break;
        case $37b7467ccb67e16e$var$asn1.Class.CONTEXT_SPECIFIC:
            rval += 'Context-Specific:';
            break;
        case $37b7467ccb67e16e$var$asn1.Class.PRIVATE:
            rval += 'Private:';
            break;
    }
    if (obj.tagClass === $37b7467ccb67e16e$var$asn1.Class.UNIVERSAL) {
        rval += obj.type;
        // known types
        switch(obj.type){
            case $37b7467ccb67e16e$var$asn1.Type.NONE:
                rval += ' (None)';
                break;
            case $37b7467ccb67e16e$var$asn1.Type.BOOLEAN:
                rval += ' (Boolean)';
                break;
            case $37b7467ccb67e16e$var$asn1.Type.INTEGER:
                rval += ' (Integer)';
                break;
            case $37b7467ccb67e16e$var$asn1.Type.BITSTRING:
                rval += ' (Bit string)';
                break;
            case $37b7467ccb67e16e$var$asn1.Type.OCTETSTRING:
                rval += ' (Octet string)';
                break;
            case $37b7467ccb67e16e$var$asn1.Type.NULL:
                rval += ' (Null)';

JSDoc configuration

{
  "plugins": [
    "plugins/markdown",
    "plugins/summarize"
  ],
  "recurseDepth": 10,
  "source": {
    "include": [
      "palette/src/github.com/zababurinsv/newkind-db/"
    ],
    "exclude": ["node_modules"],
    "includePattern": ".+\\.(js(doc|x)?|mjs)$",
    "excludePattern": "(^|\\/|\\\\)_"
  },
  "sourceType": "module",
  "tags": {
    "allowUnknownTags": true,
    "dictionaries": ["jsdoc","closure"]
  },
  "markdown": {
    "parser": "gfm",
    "hardwrap": true
  },
  "templates": {
    "search": true,
    "cleverLinks": false,
    "monospaceLinks": false,
    "default": {
      "outputSourceFiles": true,
      "includeDate": false
    },
    "scripts": [],
    "favicon": "",
    "css": []
  },
  "menu":{
    "Admin Documentation": {
      "href":"https://zababurinsv.github.io/admin/",
      "target":"_blank",
      "class":"menu-item",
      "id":"repository"
    }
  },
  "opts": {
    "template": "./jsdoc/docdash/",
    "encoding": "utf8",
    "destination": "./documents",
    "recurse": true
  },
  "docdash": {
    "static": true,         // Display the static members inside the navbar
    "sort": true,           // Sort the methods in the navbar
    "sectionOrder": [               // Order the main section in the navbar (default order shown here)
      "Classes",
      "Modules",
      "Externals",
      "Events",
      "Namespaces",
      "Mixins",
      "Tutorials",
      "Interfaces"
    ],
    "disqus": "",                   // Shortname for your disqus (subdomain during site creation)
    "openGraph": {                  // Open Graph options (mostly for Facebook and other sites to easily extract meta information)
      "title": "",                // Title of the website
      "type": "website",          // Type of the website
      "image": "",                // Main image/logo
      "site_name": "",            // Site name
      "url": ""                   // Main canonical URL for the main page of the site
    },
    "meta": {                       // Meta information options (mostly for search engines that have not indexed your site yet)
      "title": "",                // Also will be used as postfix to actualy page title, prefixed with object/document name
      "description": "",          // Description of overal contents of your website
      "keyword": ""               // Keywords for search engines
    },
    "search": true,         // Display seach box above navigation which allows to search/filter navigation items
    "collapse": true,       // Collapse navigation by default except current object's navigation of the current page
    "wrap": true,           // Wrap long navigation names instead of trimming them
    "typedefs":true,       // Include typedefs in menu
    "navLevel": 3,          // depth level to show in navbar, starting at 0 (false or -1 to disable)
    "private": false,        // set to false to not show @private in navbar
    "removeQuotes":"trim",// Remove single and double quotes, trim removes only surrounding ones
    "scripts": [],                  // Array of external (or relative local copied using templates.default.staticFiles.include) js or css files to inject into HTML,
    "menu": {                       // Adding additional menu items after Home
      "Admin": {        // Menu item name
        "href":"https://zababurinsv.github.io/admin/", //the rest of HTML properties to add to manu item
        "target":"_blank",
        "class":"menu-item",
        "id":"website_link"
      }
    },
    "scopeInOutputPath": true, // Add scope from package file (if present) to the output path, true by default.
    "nameInOutputPath": true, // Add name from package file to the output path, true by default.
    "versionInOutputPath": true // Add package version to the output path, true by default.
  }
}

JSDoc debug output

Parsing /home/zb/Desktop/newkind-service/palette/src/github.com/zababurinsv/newkind-db/frontend/src/components/newkind-db/node_modules/@mapbox/node-pre-gyp/node_modules/semver/preload.js ...
Parsing /home/zb/Desktop/newkind-service/palette/src/github.com/zababurinsv/newkind-db/frontend/src/components/newkind-db/node_modules/@motrix/nat-api/index.js ...

<--- Last few GCs --->

[21946:0x5b740f0]   187339 ms: Mark-sweep (reduce) 4026.0 (4143.2) -> 4025.0 (4143.7) MB, 10546.4 / 0.0 ms  (average mu = 0.083, current mu = 0.012) allocation failure scavenge might not succeed
[21946:0x5b740f0]   197150 ms: Mark-sweep (reduce) 4026.2 (4143.7) -> 4025.4 (4144.2) MB, 9800.6 / 0.0 ms  (average mu = 0.043, current mu = 0.001) allocation failure scavenge might not succeed


<--- JS stacktrace --->
ERROR: Unable to parse a tag's type expression for source file /home/zb/Desktop/newkind-service/palette/src/github.com/zababurinsv/newkind-db/frontend/src/components/newkind-db/modules/index.mjs in line 158849 with tag title "typedef" and text "{import('../').PeerData} PeerData": Invalid type expression "import('../').PeerData": Expected "!", "=", "?", "[]", "|", or end of input but "(" found.
ERROR: Unable to parse a tag's type expression for source file /home/zb/Desktop/newkind-service/palette/src/github.com/zababurinsv/newkind-db/frontend/src/components/newkind-db/modules/index.mjs in line 158863 with tag title "type" and text "{{ peerId: PeerId, distance: Uint8Array }[]}": Invalid type expression "{ peerId: PeerId, distance: Uint8Array }[]": Expected "!", "=", "?", "|", or end of input but "[" found.
ERROR: Unable to parse a tag's type expression for source file /home/zb/Desktop/newkind-service/palette/src/github.com/zababurinsv/newkind-db/frontend/src/components/newkind-db/modules/index.mjs in line 158863 with tag title "type" and text "{{ peerId: PeerId, distance: Uint8Array }[]}": Invalid type expression "{ peerId: PeerId, distance: Uint8Array }[]": Expected "!", "=", "?", "|", or end of input but "[" found.
ERROR: Unable to parse a tag's type expression for source file /home/zb/Desktop/newkind-service/palette/src/github.com/zababurinsv/newkind-db/frontend/src/components/newkind-db/modules/index.mjs in line 158926 with tag title "typedef" and text "{import('peer-id')} PeerId": Invalid type expression "import('peer-id')": Expected "!", "=", "?", "[]", "|", or end of input but "(" found.


FATAL ERROR: Reached heap limit Allocation failed - JavaScript heap out of memory
 1: 0xb2c2c0 node::Abort() [/usr/bin/node]
 2: 0xa4023c node::FatalError(char const*, char const*) [/usr/bin/node]
 3: 0xd1cafe v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, bool) [/usr/bin/node]
 4: 0xd1ce77 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, bool) [/usr/bin/node]
 5: 0xed6945  [/usr/bin/node]
 6: 0xee7d1d v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) [/usr/bin/node]
 7: 0xeeaa4e v8::internal::Heap::AllocateRawWithRetryOrFailSlowPath(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [/usr/bin/node]
 8: 0xeac032 v8::internal::Factory::AllocateRaw(int, v8::internal::AllocationType, v8::internal::AllocationAlignment) [/usr/bin/node]
 9: 0xea454c v8::internal::FactoryBase<v8::internal::Factory>::AllocateRawArray(int, v8::internal::AllocationType) [/usr/bin/node]
10: 0xea45f5 v8::internal::FactoryBase<v8::internal::Factory>::NewFixedArrayWithFiller(v8::internal::Handle<v8::internal::Map>, int, v8::internal::Handle<v8::internal::Oddball>, v8::internal::AllocationType) [/usr/bin/node]
11: 0x1114f53 v8::internal::Handle<v8::internal::NameDictionary> v8::internal::HashTable<v8::internal::NameDictionary, v8::internal::NameDictionaryShape>::NewInternal<v8::internal::Isolate>(v8::internal::Isolate*, int, v8::internal::AllocationType) [/usr/bin/node]
12: 0x1114ff9 v8::internal::Handle<v8::internal::NameDictionary> v8::internal::BaseNameDictionary<v8::internal::NameDictionary, v8::internal::NameDictionaryShape>::New<v8::internal::Isolate>(v8::internal::Isolate*, int, v8::internal::AllocationType, v8::internal::MinimumCapacity) [/usr/bin/node]
13: 0x10c00db v8::internal::JSObject::MigrateToMap(v8::internal::Isolate*, v8::internal::Handle<v8::internal::JSObject>, v8::internal::Handle<v8::internal::Map>, int) [/usr/bin/node]
14: 0x10e407a v8::internal::LookupIterator::TransitionToAccessorProperty(v8::internal::Handle<v8::internal::Object>, v8::internal::Handle<v8::internal::Object>, v8::internal::PropertyAttributes) [/usr/bin/node]
15: 0x10bab5d v8::internal::JSObject::DefineAccessor(v8::internal::LookupIterator*, v8::internal::Handle<v8::internal::Object>, v8::internal::Handle<v8::internal::Object>, v8::internal::PropertyAttributes) [/usr/bin/node]
16: 0x10bb3b4 v8::internal::JSReceiver::ValidateAndApplyPropertyDescriptor(v8::internal::Isolate*, v8::internal::LookupIterator*, bool, v8::internal::PropertyDescriptor*, v8::internal::PropertyDescriptor*, v8::Maybe<v8::internal::ShouldThrow>, v8::internal::Handle<v8::internal::Name>) [/usr/bin/node]
17: 0x10bb88e v8::internal::JSReceiver::OrdinaryDefineOwnProperty(v8::internal::LookupIterator*, v8::internal::PropertyDescriptor*, v8::Maybe<v8::internal::ShouldThrow>) [/usr/bin/node]
18: 0x10bbbd8 v8::internal::JSReceiver::OrdinaryDefineOwnProperty(v8::internal::Isolate*, v8::internal::Handle<v8::internal::JSObject>, v8::internal::PropertyKey const&, v8::internal::PropertyDescriptor*, v8::Maybe<v8::internal::ShouldThrow>) [/usr/bin/node]
19: 0x10bbc72 v8::internal::JSReceiver::DefineOwnProperty(v8::internal::Isolate*, v8::internal::Handle<v8::internal::JSReceiver>, v8::internal::Handle<v8::internal::Object>, v8::internal::PropertyDescriptor*, v8::Maybe<v8::internal::ShouldThrow>) [/usr/bin/node]
20: 0x10bc3bc v8::internal::JSReceiver::DefineProperties(v8::internal::Isolate*, v8::internal::Handle<v8::internal::Object>, v8::internal::Handle<v8::internal::Object>) [/usr/bin/node]
21: 0xd9f2f6 v8::internal::Builtin_ObjectDefineProperties(int, unsigned long*, v8::internal::Isolate*) [/usr/bin/node]
22: 0x1630179  [/usr/bin/node]
^C
Process finished with exit code 130 (interrupted by signal 2: SIGINT)


Expected behavior

How do you make a document that reads correctly?

Current behavior

Documents not created

Your environment

Software Version
JSDoc DEBUG: JSDoc 3.6.7 (Sat, 15 May 2021 01:24:54 GMT)
Node.js Node.js v17.2.0
npm 8.1.4
Operating system Ubuntu 20.04

zababurinsv avatar Dec 16 '21 22:12 zababurinsv

I get a very similar stack traceback on the following input coding using jsdoc 4.0.2 with no config file:

class Foo {
    static Nested = class Nested {
        constructor() { }
    }
}

Error thrown:

node_modules/jsdoc/lib/jsdoc/src/parser.js:392
            if (doclet.memberof) {
                       ^

TypeError: Cannot read properties of null (reading 'memberof')
    at Parser.astnodeToMemberof (node_modules/jsdoc/lib/jsdoc/src/parser.js:392:24)
    at addSymbolMemberof (node_modules/jsdoc/lib/jsdoc/src/handlers.js:268:31)
    at newSymbolDoclet (node_modules/jsdoc/lib/jsdoc/src/handlers.js:298:13)
    at Parser.<anonymous> (node_modules/jsdoc/lib/jsdoc/src/handlers.js:365:13)
    at Parser.emit (node:events:513:28)
    at Visitor.visitNode (node_modules/jsdoc/lib/jsdoc/src/visitor.js:846:20)
    at Visitor.visit (node_modules/jsdoc/lib/jsdoc/src/visitor.js:756:21)
    at Walker.recurse (node_modules/jsdoc/lib/jsdoc/src/walker.js:694:42)
    at Parser._walkAst (node_modules/jsdoc/lib/jsdoc/src/parser.js:305:22)
    at Parser._parseSourceCode (node_modules/jsdoc/lib/jsdoc/src/parser.js:296:22)
    at Parser.parse (node_modules/jsdoc/lib/jsdoc/src/parser.js:202:22)
    at module.exports.cli.parseFiles (node_modules/jsdoc/cli.js:365:46)
    at module.exports.cli.main (node_modules/jsdoc/cli.js:234:18)
    at module.exports.cli.runCommand (node_modules/jsdoc/cli.js:186:9)
    at node_modules/jsdoc/jsdoc.js:93:9
    at Object.<anonymous> (node_modules/jsdoc/jsdoc.js:94:3)

Hornwitser avatar Feb 25 '23 22:02 Hornwitser

I'm getting the error when I added new comments that show an example of an expected object. No error on compile when I remove the line: { "MenuId": 2,"Route": "/ViewRoute","RouteParameters": "","TitleCaption": "Page Text to Display" }.

    /**
     * Get menu routes info for authenticated user.
     * @returns a routes info array of objects like:
     * { "MenuId": 2,"Route": "/ViewRoute","RouteParameters": "","TitleCaption": "Page Text to Display" }
     */
    pub.getRoutes = async () =>
    {
        ...
    }

Version: JSDoc 4.0.2 (Sun, 19 Feb 2023 23:01:18 GMT) Node version: v21.1.0

My "docs" command: jsdoc -c jsdoc.conf.json

output from npm run docs:

> [email protected] docs
> jsdoc -c jsdoc.conf.json

ERROR: Unable to parse a tag's type expression for source file D:\Dev\GitLab\...\{ "MenuId": 2,"Route": "/ViewRoute","RouteParameters": "","TitleCaption": "Page Text to Display" }": Invalid type expression ""MenuId": 2,"Route": "/ViewRoute","RouteParameters": "","TitleCaption": "Page Text to Display"": Expected "!", ".", "<", "=", "?", "[]", "|", or end of input but ":" found.
ERROR: Unable to parse a tag's type expression for source file D:\Dev\GitLab\...\{ "MenuId": 2,"Route": "/ViewRoute","RouteParameters": "","TitleCaption": "Page Text to Display" }": Invalid type expression ""MenuId": 2,"Route": "/ViewRoute","RouteParameters": "","TitleCaption": "Page Text to Display"": Expected "!", ".", "<", "=", "?", "[]", "|", or end of input but ":" found.
(node:26592) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
(Use `node --trace-deprecation ...` to show where the warning was created)

Can this be customized in jsdoc.conf.json? Thanks.

[UPDATE] After I posted this, I perused the jsDoc info some more and realized that it better practice to use defined types rather than the hard-coded object that I have in my exmaple above. I changed my docs to @typedef my objects and then use the @returns {customObject} I defined. That took care of the errors altogether. It helps to do it right. :)

AYColumbia avatar Nov 13 '23 00:11 AYColumbia