-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
goog.reflect.objectProperty does not prevent inlining of methods breaking method annotations #2437
Comments
No. That's beyond the scope of that intrinsic. Can you post an example of what it might look like when inlined? |
TypeScript input (target es6):
TypeScript output and CC input (with
From the above output, you can see |
This is a problem with property reflection - the method call is hidden from the compiler. Polymer suffers from the same problem. What's needed to block this is a sink value. See https://google.github.io/closure-library/api/goog.reflect.html#sinkValue Ideally tsickle would be updated to output this for you. |
Great thanks, we'll integrate |
@WearyMonkey After thinking on this overnight - this may not be what you want. Adding the sink value will block inlining, but it will also block dead code elimination. I don't know of a way to block inlining but not block dead code elimination. @concavelenz might have ideas though. |
Closure Compiler Service example
We are using TypeScript method decorators which transpiles:
to
Which we further transpile into the CC compatible form:
However, in some instances CC is inlining the invocation of the annotated methods, which effecively by passes the annotation.
This is breaking our usage of modern annotated driven libraries such as MobX.
Can compiler treatment of
goog.reflect.objectProperty
be extended to prevent inlining?Is there canonical way we can prevent inlining of specific methods which we can include in a transpilation?
Cheers!
The text was updated successfully, but these errors were encountered: