question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Extending computed class name identifiers throws:

See original GitHub issue

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.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:1
  • Comments:20 (4 by maintainers)

github_iconTop GitHub Comments

4reactions
Treekicommented, Oct 25, 2017

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!) to a.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

1reaction
ChadKillingsworthcommented, Jul 3, 2018

See #2997

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found