-
-
Notifications
You must be signed in to change notification settings - Fork 483
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
test(transformer/class-properties): add static super tagged template test #7964
test(transformer/class-properties): add static super tagged template test #7964
Conversation
How to use the Graphite Merge QueueAdd either label to this PR to merge it via the merge queue:
You must have a Graphite account in order to use the merge queue. Sign up using this link. An organization admin has enabled the Graphite Merge Queue in this repository. Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue. This stack of pull requests is managed by Graphite. Learn more about stacking. |
Unfortunately this is a bug in Babel (another one!) import assert from 'assert';
let receiver;
class S {
static method() {
receiver = this;
}
}
class C extends S {
static prop = super.method`xyz`;
}
assert(receiver === C); The assertion passes. After Babel transform: import assert from "assert";
let receiver;
class S {
static method() {
receiver = this;
}
}
class C extends S {}
_C = C;
_defineProperty(C, "prop", _superPropGet(_C, "method", _C)`xyz`);
assert(receiver === C); Assertion fails! Same as for private field as template tag, it needs extra _defineProperty(C, "prop", _superPropGet(_C, "method", _C).bind(_C)`xyz`); I will add this to my list of bugs to report to Babel! We don't need to fix this right now. It's a crazy edge case. But I don't think we should add a test with wrong output either. Maybe better to adapt this test to be a failing test, so we remember to come back to it later. |
Thank you for finding the bug, I changed the output to the correct output and also added an execution test from your example |
2c21608
to
462af93
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great. Your version of the exec test is better than mine.
I pushed a commit to remove the 2nd test case, which had the wrong output. Is there a reason that was there that I don't understand?
Also:
- Removed
import { expect } from "vitest";
- test runner already injectsexpect
into environment. - Made
input.js
a copy ofexec.js
. This follows what Babel does. I guess the reason is that when debugging the exec test, it's helpful to be able to see the transformed output.
@Dunqing If there wasn't a good reason why the 2nd test was there, please merge. If there was a good reason, and I shouldn't have removed it, please say!
It's a accident, it seemed caused by renaming the test folder name. |
Merge activity
|
…test (#7964) I just found that we don't need to transform `TaggedTemplateExpression` because its `tag` can be transformed by `transform_static_member_expression` and `transform_computed_member_expression`
ba041f3
to
e3d0889
Compare
I just found that we don't need to transform
TaggedTemplateExpression
because itstag
can be transformed bytransform_static_member_expression
andtransform_computed_member_expression