Open liolick opened 10 years ago
Thanks for the report. We will fix this in the new type checker.
Btw, if you want the type to be (boolean|undefined), you should declare that type on the interface instead of just boolean.
Thanks, Dimitris! Yes, it's (boolean|undefined) on interface, I just shortened an example here.
Are there any plans on new type checker? Can we try it on latest (v20140407) compiler via Java API? What is a suitable workaround for a while?
You can try it by setting this option https://github.com/google/closure-compiler/blob/4b3d5e471b410e552ca17d7bc39dcb5d4cdf21f7/src/com/google/javascript/jscomp/CompilerOptions.java#L1760
But it's still experimental and not stable. We hope to land it in the next 2-3 months.
I have followed code:
Compiling it with "--compilation_level ADVANCED_OPTIMIZATIONS --jscomp_warning reportUnknownTypes --warning_level VERBOSE" I get a warning:
If I add
@type {boolean}
toCls.prototype.prop
all is fine. It seems compiler is unable to infer type fromItf.prototype.prop
.Initializing overrided property resolves a problem, but in my case it should be uninitialized (it's type actually
{(boolean|undefined)}
).See discussion: https://groups.google.com/forum/#!topic/closure-compiler-discuss/gdKj25kAWeg