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

The wrong processing of destructuring #642

Closed
miherlosev opened this issue Jun 28, 2016 · 12 comments · Fixed by #2332, #2345, #2351 or #2353
Closed

The wrong processing of destructuring #642

miherlosev opened this issue Jun 28, 2016 · 12 comments · Fixed by #2332, #2345, #2351 or #2353

Comments

@miherlosev
Copy link
Contributor

miherlosev commented Jun 28, 2016

If location declared inside function or passed as function parameter we should not process it.
It needs for fix #640 (comment)

Update! The origin issue was transfered to #2283

@iJigg
Copy link

iJigg commented Nov 27, 2019

This is being an issue for me right now.
Unfortunately I am not able to change the code below and this i blocking me from testing altogether.

renderThing({ history, location }) { ... }

get's transpiled into

renderThing({ history:history,location: __get$Loc(location) }) {  }

which throws Uncaught SyntaxError: Invalid destructuring assignment target

Any ETA on when this can be solved?

@Farfurix Farfurix self-assigned this Nov 28, 2019
@Farfurix Farfurix added this to the Planned milestone Nov 28, 2019
@Farfurix
Copy link
Contributor

@iJigg

Hello,

Thank you for your example. We have plans to fix it. However, I cannot give you any precise time frames.

@Farfurix Farfurix removed their assignment Nov 28, 2019
@silberjan
Copy link

@Farfurix this bug is making testcafe practically unusable for us right now. Is there any workaround until you fixed it?

@silberjan
Copy link

Okay i just found out myself.
Renaming the location param to anything else fixes the problem. I guess hammerhead always assumes location is window.location, which it is not for us.

@Farfurix
Copy link
Contributor

Farfurix commented Jan 6, 2020

@silberjan

Hello,

Yes, testcafe-hammerhead has special logic for the location object. Thank you for sharing your workaround. It can help other users work around the issue (when they are able to rename such objects in their projects).

We have plans to fix this issue. However, I cannot give you any estimates at the moment. Stay tuned for our updates here.

@LavrovArtem LavrovArtem modified the milestones: Planned, Sprint #50 Jan 28, 2020
@LavrovArtem LavrovArtem modified the milestones: Sprint #50, Planned Jan 31, 2020
@LavrovArtem
Copy link
Contributor

We need to transform the destructuring to fix this issue. This is a complex task. Here is how babel accomplishes it: https://github.com/babel/babel/blob/master/packages/babel-plugin-transform-destructuring/src/index.js

@LavrovArtem LavrovArtem changed the title Change location assignment processing The wrong processing of destructuring Apr 6, 2020
@LavrovArtem LavrovArtem added this to the Sprint #54 milestone Apr 6, 2020
@ajspott
Copy link

ajspott commented Apr 13, 2020

Another example occurs with Angular 9 + ngx-pipes within the ShufflePipe class

This:
[shuffled[i], shuffled[j]] = [shuffled[j], shuffled[i]];

Becomes this:
[ __get$(shuffled,i), __get$(shuffled,j)] = [ __get$(shuffled,j), __get$(shuffled,i)];

@AndreyBelym AndreyBelym modified the milestones: Sprint #54, Sprint #55 Apr 14, 2020
@AndreyBelym AndreyBelym modified the milestones: Sprint #55, Sprint #56 Apr 28, 2020
@LavrovArtem LavrovArtem self-assigned this May 7, 2020
@AndreyBelym AndreyBelym modified the milestones: Sprint #56, Sprint #57 May 25, 2020
@LavrovArtem LavrovArtem linked a pull request May 25, 2020 that will close this issue
@AndreyBelym AndreyBelym reopened this May 27, 2020
@AndreyBelym AndreyBelym modified the milestones: Sprint #57, Sprint #58 Jun 3, 2020
LavrovArtem added a commit to LavrovArtem/testcafe-hammerhead that referenced this issue Jun 10, 2020
@LavrovArtem LavrovArtem reopened this Jun 17, 2020
LavrovArtem added a commit to LavrovArtem/testcafe-hammerhead that referenced this issue Jun 17, 2020
LavrovArtem added a commit to LavrovArtem/testcafe-hammerhead that referenced this issue Jun 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment