Skip to content Skip to sidebar Skip to footer

How I Can Mark Function As "private" To Renaming It By Google Closure Compiler?

I have private function createSomething(): function Player(id) { /** * Creates stuff * @private */ this.createSomething = function() { // do something good };

Solution 1:

The solution is to use a string literal to refer to the property.

functionPlayer(id) {
  /**
   *  @private
   */this['createSomething'] = function() {
    // do something good
  };
}

This works because the compiler never renames string literals. But be careful.

You can compile your code with ADVANCED_OPTIMIZATIONS and still have you compatibility with other libraries. You'll need to read about externs and exports in the library documentation:

Solution 2:

Just use without this

functionPlayer(id) {

  /**
   *  Creates stuff
   *  @private
   */
  createSomething = function() {
    // do something good
  };
}

Post a Comment for "How I Can Mark Function As "private" To Renaming It By Google Closure Compiler?"