Extending computed class name identifiers throws:
See original GitHub issueInput:
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.
Issue Analytics
- State:
- Created 7 years ago
- Reactions:1
- Comments:20 (4 by maintainers)
Top Results From Across the Web
Is it possible to extend a class dynamically? - php
I have set a dynamic class name using the class_alias function like class_alias('TCPDF', 'TCPDF2'); . I have solved my same type of problem....
Read more >Dynamic Throw Type Extensions - PHPStan
This is the interface for dynamic throw type extension: ... public function getComponent(string $name, bool $throw): ? ... ComponentContainer::class
Read more >Overriding in Java - GeeksforGeeks
Rule#2 : If the super-class overridden method does throws an exception, subclass overriding method can only throw same, subclass exception.
Read more >DynamicClassLoader (EclipseLink 2.6.9, API Reference)
Create a new dynamic class if a ClassWriter is registered for the provided className. This code is single threaded to ensure only one...
Read more >Creating and Using Dynamic Objects (C# and Visual Basic)
To reference the id attribute of the HTML element <div id="Div1"> , you first obtain a reference to the <div> element, and then...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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