-
Notifications
You must be signed in to change notification settings - Fork 96
Make tfjs-layers compatible with the closure compiler #442
Conversation
cc @ericdnielsen , @bileschi , @davidsoergel as an FYI. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status:
complete! 1 of 1 approvals obtained (waiting on @caisq, @davidsoergel, and @nsthorat)
src/engine/container.ts, line 775 at r1 (raw file):
const theConfig = this.getConfig(); const modelConfig: serialization.ConfigDict = {}; modelConfig.className = this.getClassName();
FYI, this is a known issue with Closure. You can't do object literals even if you immediately assign them to a variable that is marked as being an external interface, such as ConfigDict
. You have to assign each field individually.
@dsmilkov Thank you for spending the time and effort in making the code compile with closure. Is there a way to ensure that going forward, people making changes in tfjs-layers will not break the closure compiler? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 24 of 24 files at r1.
Reviewable status:complete! 1 of 1 approvals obtained (waiting on @caisq, @davidsoergel, and @nsthorat)
src/engine/container.ts, line 775 at r1 (raw file):
Previously, dsmilkov (Daniel Smilkov) wrote…
FYI, this is a known issue with Closure. You can't do object literals even if you immediately assign them to a variable that is marked as being an external interface, such as
ConfigDict
. You have to assign each field individually.
There are tons of object literals in our tests. I guess it's OK there?
So an idea is to setup a weekly cron job to sync layers and test compilation with closure by executing a few pre-trained models (most of these problems only show up on run-time when code is compiled with aggressive closure rewriting rules). We don't sync existing tests at all. |
- Add `/** @nocollapse */` on static properties to tell closure not to remove them. - Prepend `declare` in front of interfaces and types that are external (used in json deserialization/serialization) so closure doesn't rename its properties. - Fix issues where the promise was unused. Similar changes in tfjs-layers: tensorflow/tfjs-layers#442
/** @nocollapse */
on static properties to tell closure not to remove them.declare
in front of interfaces and types that are external (used in json deserialization/serialization) so closure doesn't rename their properties.serialization.ConfigDict
so closure doesn't rename its properties.Similar changes in tfjs-core: tensorflow/tfjs-core#1521
This change is