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

Can't use goog.reflect.object/objectProperty from es6 module. #4182

Open
ribrdb opened this issue Jul 25, 2024 · 2 comments
Open

Can't use goog.reflect.object/objectProperty from es6 module. #4182

ribrdb opened this issue Jul 25, 2024 · 2 comments

Comments

@ribrdb
Copy link

ribrdb commented Jul 25, 2024

I see that objectProperty and object are available in closure-compiler/lib/reflect.js. However I do not see any way to use these from an es6 module. I tried adding these to goog.js and using it like this:

import * as goog from 'goog.js'
const x = goog.reflect.objectProperty(...)

However goog.js only seems to work with properties of goog itself, not two-levels deep.
I end up with an ast like (GETPROPERTY objectProperty (NAME goog$reflect)), but the isPropertyRenameFunction method only allows one of these:

(NAME JSCompiler_renameProperty)
(GETPROP objectProperty (GETPROP reflect (NAME goog)))
(NAME goog$reflect$objectProperty)
@lauraharker
Copy link
Contributor

From our team's triage meeting - we don't have bandwidth to investigate right now but if you can find a solution besides @closurePrimitive would be happy to review

@ribrdb
Copy link
Author

ribrdb commented Sep 3, 2024

It appears that adding JSCompiler_renameProperty to base.js or to an externs file allows it to work from an es6 module. I think this will be sufficient for our use, but maybe this should be documented somewhere?
Perhaps https://github.com/google/closure-compiler/wiki/Type-Based-Property-Renaming

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

No branches or pull requests

2 participants