Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError when using rest operator in function parameter destructuring #24

Open
reygreen1 opened this issue Dec 16, 2020 · 1 comment
Open

Comments

@reygreen1
Copy link

I encountered an error when using the rest operator when destructuring a function parameter.

My test source code like this:

var a = {name:'hi', age:11};
function foo(e={...a}){}

The error info like this:

TypeError: Cannot read property 'type' of undefined
    at Object.Property (/Users/curry/test/node_modules/typhonjs-escomplex-commons/dist/utils/ast/astSyntax.js:814:30)
    at ObjectExpression (/Users/curry/test/node_modules/typhonjs-escomplex-commons/dist/utils/ast/astSyntax.js:779:18)
    at Object.AssignmentPattern (/Users/curry/test/node_modules/typhonjs-escomplex-commons/dist/utils/ast/astSyntax.js:908:28)
    at Function.parse (/Users/curry/test/node_modules/typhonjs-escomplex-commons/dist/utils/ast/ASTGenerator.js:66:39)
    at /Users/curry/test/node_modules/escomplex-plugin-syntax-estree/dist/PluginSyntaxESTree.js:491:61
    at Array.forEach (<anonymous>)
    at Trait._data (/Users/curry/test/node_modules/escomplex-plugin-syntax-estree/dist/PluginSyntaxESTree.js:490:28)
    at Trait.valueOf (/Users/curry/test/node_modules/typhonjs-escomplex-commons/dist/module/traits/Trait.js:86:60)
    at Object.enterNode (/Users/curry/test/node_modules/typhonjs-escomplex-module/dist/ESComplexModule.js:114:53)
    at ASTWalker._visitNode (/Users/curry/test/node_modules/typhonjs-ast-walker/dist/ASTWalker.js:72:88)

I have tried the method in #11 , but it does not work. So any help?

Dependencies versions:

typhonjs-escomplex@0.1.0
typhonjs-escomplex-commons@0.1.1
@typhonrt
Copy link
Member

I'll try and get a look at upgrading the underlying parser and fundamental AST processing soon which means likely January. From the stack trace it doesn't seem to be a code parser issue, but how the generated AST is handled. Alas when I made that last patch update in Dec '18 / Jan '19 I likely didn't include all the thorough use cases at the time in the tests.

I'm working on some new build tooling right now for Node modules that I need to complete first as I'll use this in the upgrade process to other TyphonJS modules. This issue should go away once I rebuild and upgrade the underlying Babel parser for escomplex and handle the AST processing of any of the newer language features.

I suppose the good news is that I'm back coding and certainly realize that some updates need to occur to escomplex and I appreciate you submitting this issue to light a bit of a fire behind getting these fundamental updates done. :D

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

No branches or pull requests

2 participants