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.

Cannot read property 'type' of undefined when using transformObjectKeys

See original GitHub issue

Expected Behavior

Using transformObjectKeys should not cause an error

Current Behavior

It causes the following error.

Steps to Reproduce (for bugs)

Unknown

Your Environment

  • Obfuscator version used: Versions 0.14 through 0.18 have had this issue
  • Node version used: 8.11.3

The code is generated by Webpack and the Webpack output.libraryTarget is ‘commonjs2’

Stack trace

C:\Projects\myApp\node_modules\javascript-obfuscator\dist\webpack:\JavaScriptObfuscator\src\node\NodeGuards.ts:262
        return node.type === NodeType.ObjectPattern;
                    ^
TypeError: Cannot read property 'type' of undefined
    at Function.type (C:\Projects\myApp\node_modules\javascript-obfuscator\dist\webpack:\JavaScriptObfuscator\src\node\NodeGuards.ts:262:21)
    at Function.isObjectPatternNode (C:\Projects\myApp\node_modules\javascript-obfuscator\dist\webpack:\JavaScriptObfuscator\src\node-transformers\converting-transformers\properties-extractors\AbstractPropertiesExtractor.ts:78:27)
    at t.isProhibitedPattern (C:\Projects\myApp\node_modules\javascript-obfuscator\dist\webpack:\JavaScriptObfuscator\src\node-transformers\converting-transformers\properties-extractors\AbstractPropertiesExtractor.ts:112:45)
    at t.extractPropertiesToExpressionStatements (C:\Projects\myApp\node_modules\javascript-obfuscator\dist\webpack:\JavaScriptObfuscator\src\node-transformers\converting-transformers\properties-extractors\AbstractPropertiesExtractor.ts:179:14)
    at transformObjectExpressionNode (C:\Projects\myApp\node_modules\javascript-obfuscator\dist\webpack:\JavaScriptObfuscator\src\node-transformers\converting-transformers\properties-extractors\VariableDeclaratorPropertiesExtractor.ts:42:21)
    at t.extract (C:\Projects\myApp\node_modules\javascript-obfuscator\dist\webpack:\JavaScriptObfuscator\src\node-transformers\converting-transformers\ObjectExpressionKeysTransformer.ts:104:36)
    at transformNode (C:\Projects\myApp\node_modules\javascript-obfuscator\dist\webpack:\JavaScriptObfuscator\src\node-transformers\converting-transformers\ObjectExpressionKeysTransformer.ts:67:33)
    at Controller.visitorFunction (C:\Projects\myApp\node_modules\javascript-obfuscator\dist\webpack:\JavaScriptObfuscator\src\node-transformers\TransformersRunner.ts:111:55)
    at Controller.__execute (C:\Projects\myApp\node_modules\estraverse\estraverse.js:397:31)
    at Controller.replace (C:\Projects\myApp\node_modules\estraverse\estraverse.js:637:27)
error Command failed with exit code 1.

Minimal working example that will help to reproduce issue

Unknown

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:10 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
sanex3339commented, Aug 31, 2018

Hi, i’ll look into this issue but currently i take a 1-2 months timeout with this project to doing renovations on my flat. So, until october i’ll have no time to look into this.

0reactions
Instupelligidentcommented, Feb 23, 2021

Hello. I tried testing this using my application and when trying to use the transformObjectKeys option, I received the same “Cannot read property ‘type’ of undefined” error. Currently, I am using version 2.10.3 but did go through this thread and tried the .16 and .18 before writing this up (I am receiving the error on them all). I was wondering if anyone had the ability to relook into this.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cannot Read Property of Undefined in JavaScript - Rollbar
TypeError: Cannot read property of undefined occurs when a property is read or a function is called on an undefined variable.
Read more >
How to fix 'Type Error: Cannot Read Property 'name' of ...
You are trying to access the items in the fiteredStudents array before the promise has had a chance to resolve and before your...
Read more >
"Cannot read property 'type' of undefined" after upgrading to ...
Got the error after upgrading to 4.14.0 on Flow type definitions TypeError: Cannot read property 'type' of undefined TypeError: Cannot read ...
Read more >
Uncaught TypeError : Cannot read properties of undefined
The error clearly says that it is Undefined, which means the variable might be declared or used. Still, there is no value associated...
Read more >
Avoiding those dang cannot read property of undefined errors
Uncaught TypeError: Cannot read property 'foo' of undefined. ​ The dreaded error we all hit at some point in JavaScript development.
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