Fix class properties after nested class' bare super#7671
Fix class properties after nested class' bare super#7671jridgewell merged 11 commits intobabel:masterfrom
Conversation
|
Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/7596/ |
|
Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/7463/ |
| } | ||
| }, | ||
|
|
||
| ClassBody(path) { |
There was a problem hiding this comment.
This should skip methods, not the entire body.
|
How should this code behave? class A extends B {
x = 2;
constructor() {
class C extends D {
y = super();
}
}
} |
|
It's an early error. |
a517412 to
cb1ca47
Compare
| // context. | ||
| if (path.node.computed) { | ||
| path.get("key").traverse(visitor, state); | ||
| path.get("key").traverse(path.context.opts, state); |
There was a problem hiding this comment.
I'm trying to create a base visitor that will be merged into several other complete visitors. This one defines the class environment traversal behavior (skip instance fields, class methods, but traverse computed keys).
But, it needs to be recursive. This is the best way I've found to reference the complete visitor from the sub-visitor.
/cc @loganfsmyth
There was a problem hiding this comment.
TraversalContext internally uses this.opts to traverse child nodes, so I guess that this is ok.
Alternatively, you can do something like this (disclaimer: I found this method 2 mins ago 😆):
path.skipKey("decorators");
path.skipKey("params");
path.skipKey("body");
if (!path.node.computed) path.skipKey("key");There was a problem hiding this comment.
Curious. It's been in there since v5, but doesn't seem to be used anymore...
| computedPath.traverse(classFieldDefinitionEvaluationTDZVisitor, { | ||
| classRef: path.scope.getBinding(ref.name), | ||
| file: this.file, | ||
| shouldSkip: computedPath.get("value"), |
There was a problem hiding this comment.
You can probably remove shouldSkip.
|
Travis is failing because of |
Fixes #7371.
Depends on #7691.