You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Aug 1, 2024. It is now read-only.
I've defined custom EventType for a sub class of goog.ui.Component like following:
goog.provide('a.b.c.SomeClass');goog.provide('a.b.c.SomeClass.EventType');goog.require('goog.ui.Component');a.b.c.SomeClass=classextendsgoog.ui.Component{/* some codes... */}/** * @enum {string} */a.b.c.SomeClass.EventType={CUSTOM_EVENT_A: '...',CUSTOM_EVENT_B: '...',};
But, when I updated Closure Libray and Compiler to v20190709, the above code becomes causing JSC_HIDDEN_PROTOTYPAL_SUPERTYPE_PROPERTY_MISMATCH and JSC_HIDDEN_SUPERCLASS_PROPERTY errors.
How can I define custom EvenType for a sub class of goog.ui.Component with ES2015 class inheritance?
The text was updated successfully, but these errors were encountered:
The short answer is you can't. This is actually a known issue that's blocking us migrating many of the goog.ui classes to ES6.
The underlying issue is that ES6 classes have class-side inheritance, and Closure Compiler (and TypeScript as well, FWIW) seem to want to enforce that static properties on a subclass are assignable to static properties on the base class. In my opinion, this is incorrect, since subclasses are not generally substitutable for base classes (see microsoft/TypeScript#4628 (comment) for a familiar example). But that's beside the point, it's unlikely to change any time soon.
Instead, the approach we recommend is to make this a module with "named exports". That is,
This avoids needing to nest the enum on the class, which our internal TypeScript infrastructure doesn't even really support anyway (so there's another reason we're moving away from that pattern).
More broadly, I'd also recommend getting off of goog.ui entirely. It's been effectively unmaintained for years, and we continue to get more and more hesitant to touch anything about it as time passes.
I've defined custom EventType for a sub class of goog.ui.Component like following:
But, when I updated Closure Libray and Compiler to v20190709, the above code becomes causing
JSC_HIDDEN_PROTOTYPAL_SUPERTYPE_PROPERTY_MISMATCH
andJSC_HIDDEN_SUPERCLASS_PROPERTY
errors.How can I define custom EvenType for a sub class of goog.ui.Component with ES2015 class inheritance?
The text was updated successfully, but these errors were encountered: