closure-compiler: Extending computed class name identifiers throws:
Input:
var a = {
foo: class {}
}
class bar extends a['foo']{
}
CC throws:
JSC_DYNAMIC_EXTENDS_TYPE: The class in an extends clause must be a qualified name. at line 6 character 18
class bar extends a['foo']{
^
Is this by design? The JS code is valid.
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Reactions: 1
- Comments: 20 (4 by maintainers)
Commits related to this issue
- Fix crash when class declaration extends an expression. Fixes #679. It's possible for a class declaration to extend an expression that does not have a symbol, for example when a mixin function is us... — committed to aomarks/tsickle by aomarks 6 years ago
- Fix crash when class declaration extends an expression. Fixes #679. It's possible for a class declaration to extend an expression that does not have a symbol, for example when a mixin function is us... — committed to angular/tsickle by aomarks 6 years ago
I ran into this issue and decided to take a stab at fixing it (despite never having touched the Closure Compiler codebase before…). As far as I can tell, the most elegant solution is to allow CC to consider terms like
a.b['c']as a qualified name, similar (but not equivalent!) toa.b.c.I don’t want to submit a PR for this as my fix isn’t perfect – it fails some tests – but perhaps somebody more familiar with the codebase can build upon it and complete it: https://github.com/Treeki/closure-compiler/tree/allow-constant-getelem-in-qualified-names
See #2997
You should be able to do that with
type: