You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[plugin] Assignment expressions and implicit returns #34
That code is attempting to return the declared variable when it reaches a variable declaration.
Resolution
I think one of two things should happen:
Flatly throw an error when trying to implicitly return a variable declarataion.
Return the RHS of the declaration rather than the LHS. (Will have to hoist a ref to the RHS to avoid duplicating side effects etc) -- if no RHS, return undefined or don't insert the return.
Activity
rattrayalex commentedon Jun 8, 2017
Agreed this is an issue - thanks for reporting.
I think a third resolution is possible:
I think this is actually awesome code – it makes extracting & returning a subset of a tree much easier/cleaner.
Should just be a case of detecting a
patternon the LHS and then converting to anObjectExpression/ArrayExpressionwcjohnson commentedon Jun 9, 2017
Fixed, implementing your suggestion, at: wcjohnson/babel-plugin-lightscript@91592ad
rattrayalex commentedon Jun 9, 2017
Cool, I hope to merge that in after
match