2

I am using closure compiler for my project.

One of my project files has an declaration like :

var data = window.somedata || {}; 

The file returns this object which is being used by other files. Closure compiler renames all the properties of this data object (in advanced mode) when it is used.

How to tell the compiler not to rename any property related to this variable?

Mohammed Acharki
  • 234
  • 2
  • 14

1 Answers1

0

You can prevent renaming by either using quotes for every property access:

console.log(data['myprop'])

Or by using externs. Externs are separate files that define types.

extern

/** @typedef {{prop1: string, prop2: boolean}} */
var FileObj;

source

var data = window.somedata || /** @type {FileObj} */ ({}); 

More about writing externs

Chad Killingsworth
  • 14,360
  • 2
  • 34
  • 57