Cannot read property 'type' of undefined when using transformObjectKeys
See original GitHub issueExpected 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:
- Created 5 years ago
- Comments:10 (4 by maintainers)
Top 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 >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
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.
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.