-
Notifications
You must be signed in to change notification settings - Fork 71
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
generate JsDoc api.json fails on MemberExpressions with Literals #561
Comments
Thank you for your excellent analysis @killerfurbel! I was able to reproduce the issue with the OpenUI5 library var PageBackgroundDesign = mLibrary["PageBackgroundDesign"]; Executing I can also confirm that your proposed patch resolves the issue. I will prepare a PR for that. CC: @codeworrior Thanks again! |
Without further analysis, the second branch IMO is only safe for a string literal whose value qualifies as an identifier. As long as the result of E.g. the export property in the api.json should only contain a chain of identifiers. |
I have the same issue. any plan to fix this? any workaround? |
As workaround (works for me):
|
Thanks @killerfurbel for your detailed analysis. I have retested the scenario with UI5 Tooling V3 and no error occurs. However a warning is logged to the console |
Expected Behavior
Running the build process to generate the api.json without errors:
Current Behavior
(Exception is generated here: https://github.com/SAP/ui5-builder/blob/master/lib/processors/jsdoc/lib/ui5/plugin.js#L294)
Steps to Reproduce the Issue
When you use babel-plugin-transform-modules-ui5 for TypeScript coding, you will import library enums like this:
Babel will transform that into an sap.ui.define() call with
"sap/m/library"
which produces a variablesap_m_library
. After that, it will generate the enums as follows:To reproduce, you only need to use this syntax, no TypeScript or other transformations are necessary.
The problem is gone when you rewrite the code as follows:
The reason for this is that in the
getObjectName()
function, only specific AST nodes are parsed: https://github.com/SAP/ui5-builder/blob/master/lib/processors/jsdoc/lib/ui5/plugin.js#L523The error occurs if the node.type is MemberExpression, but node.computed is true and node.property.type is Literal.
This is how the AST looks like in the error case:
My suggestion is to add another
else if
clause which covers this case:Context
ui5 --version
when using the CLI): 2.12.1Solution
I could also create a pull request if you don't have any better idea?
The text was updated successfully, but these errors were encountered: