-
Notifications
You must be signed in to change notification settings - Fork 12.8k
ES6 destructuring with this
variable - tuple and array
#10076
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
Comments
Can't repro on the Playground this with the code given. Can you post a complete sample (with the surrounding function) ? |
@RyanCavanaugh I could not reproduce this on the playground either. But strangely i figured out a fix. When I would write something to the effect of
it would fail and would output as I had previously stated.
I am not sure why this is. I thought the type did not change transpilation, but only is there for transpile time type checking, but it looks like it matters for that too. |
Definitely a bug declare function wrapper(x: any);
wrapper((array: [any]) => {
[this.test, this.test1, this.test2] = array;
}); should output three |
@Guardiannw the reason why wrapper((array: [any]) => {
[this.test, this.test1, this.test2] = array;
}); and this one wrapper((array: Array<any>) => {
[this.test, this.test1, this.test2] = array;
}); behaves differently is that the first example |
@yuit That makes complete sense, but I thought that the types did not create any changes in the exported code, that they only made compile time type checks. Is this correct or incorrect with the desired specs? |
@Guardiannw I think this is incorrect and undesirable that we skip checking I have merged the fix into |
this
variablethis
variable - tuple and array
TypeScript Version: 1.8.10
Code
Expected behavior:
for it to compile as
_this.test = array[0], _this.test2 = array[1], _this.test3 = array[2];
Actual behavior:
it compiles as
_this.test = array[0], this.test2 = array[1], this.test3 = array[2];
This is a problem because the
this
scope does not match correctly that of the lambda.The text was updated successfully, but these errors were encountered: