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

@webdoc/parser 1.6.0 crashes when mangling a method with no parameter #182

Closed
Julien-Marcou opened this issue Jul 10, 2022 · 1 comment · Fixed by #184
Closed

@webdoc/parser 1.6.0 crashes when mangling a method with no parameter #182

Julien-Marcou opened this issue Jul 10, 2022 · 1 comment · Fixed by #184

Comments

@Julien-Marcou
Copy link

Related to pixijs/pixijs#8480

When @webdoc/parser parses a method that has no parameters, it crashes with the following error:

(node:4199) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'map' of undefined
    at mangled (/home/runner/work/pixijs/pixijs/node_modules/@webdoc/model/lib/doc.js:296:50)
    at discoverMembers (/home/runner/work/pixijs/pixijs/node_modules/@webdoc/parser/lib/transformer/mod-discover-members.js:53:45)
    at ensureDiscovered (/home/runner/work/pixijs/pixijs/node_modules/@webdoc/parser/lib/transformer/mod-discover-members.js:21:3)
    at discoverMembers (/home/runner/work/pixijs/pixijs/node_modules/@webdoc/parser/lib/transformer/mod-discover-members.js:81:5)
    at discover (/home/runner/work/pixijs/pixijs/node_modules/@webdoc/parser/lib/transformer/mod-discover-members.js:116:3)
    at Object.discover [as mod] (/home/runner/work/pixijs/pixijs/node_modules/@webdoc/parser/lib/transformer/mod-discover-members.js:120:7)
    at mod (/home/runner/work/pixijs/pixijs/node_modules/@webdoc/parser/lib/transformer/document-tree-modifiers.js:66:22)
    at parse (/home/runner/work/pixijs/pixijs/node_modules/@webdoc/parser/lib/parse.js:82:38)
    at async main (/home/runner/work/pixijs/pixijs/node_modules/@webdoc/cli/lib/index.js:136:5)

The mangled() function doesn't check if params is defined, it should probably return something like ${doc.type}:${doc.name} or ${doc.type}:${doc.name}:undefined when that is the case:

export function mangled(doc: Doc): string {
if (doc.type === "MethodDoc") {
return `${doc.type}:${doc.name}:${
doc.params.map((p) => p.dataType ? p.dataType[0] : "unknown").join("-")}`;
}
return `${doc.type}:${doc.name}`;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants