This should work fine. Just define it after the constructor as usual. Have you tried? The name won't be referenced until the constructor is called and by then the property will exist. If the compiler is complaining, that is a bug.
In a constructor, it seems there is no way to refer to a "static class field" (in the Java sense) because the class object doesn't yet exist. Is that right? I can get by with some workarounds like: define the static field on some other class; but these are sub-optimal. Here is an example of what I'd like to be able to do:
/** "static class field"
* @type {number}
* @const
*/
fooPackage.barClass.QUUX = 3;
/**
* @constructor
*/
fooPackage.barClass = function() {
/**
* @type {number}
*/
this.bazField = fooPackage.barClass.QUUX;
};
Thanks,
ErikN
--
---
You received this message because you are subscribed to the Google Groups "Closure Compiler Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to closure-compiler-d...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.