Skip to content

Fixed SyntaxError when obfuscating a class that extends a boolean literal - #1420

Merged
sanex3339 merged 1 commit into
javascript-obfuscator:masterfrom
cycsmail:fix/boolean-literal-extends-syntax-error
Jul 9, 2026
Merged

Fixed SyntaxError when obfuscating a class that extends a boolean literal#1420
sanex3339 merged 1 commit into
javascript-obfuscator:masterfrom
cycsmail:fix/boolean-literal-extends-syntax-error

Conversation

@cycsmail

Copy link
Copy Markdown
Contributor

class C extends true {} is valid JavaScript, but BooleanLiteralTransformer rewrote true/false into !![]/![] even in the extends position, emitting class C extends ![] {}. A class heritage must be a LeftHandSideExpression, so that causes an early SyntaxError. I skip the transformation when the literal is the class superClass and leave it unchanged; booleans everywhere else are still transformed as before. Added a regression test (it fails without the fix and passes with it).

Fixes #1131

@sanex3339 sanex3339 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you

@sanex3339
sanex3339 merged commit fecc145 into javascript-obfuscator:master Jul 9, 2026
13 of 15 checks passed
@sanex3339

Copy link
Copy Markdown
Member

Released in 5.4.4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Extending a boolean literal results in SyntaxError

2 participants