Transform class static block (#12143)

Co-authored-by: Nicolò Ribaudo <nicolo.ribaudo@gmail.com>
Co-authored-by: Brian Ng <bng412@gmail.com>
This commit is contained in:
Huáng Jùnliàng
2020-10-14 13:54:41 -04:00
committed by Nicolò Ribaudo
parent 3ccca88178
commit f697e7995d
85 changed files with 861 additions and 24 deletions

View File

@@ -42,8 +42,13 @@ export function skipAllButComputedKey(path: NodePath) {
}
// environmentVisitor should be used when traversing the whole class and not for specific class elements/methods.
// For perf reasons, the environmentVisitor will be traversed with `{ noScope: true }`, which means `path.scope` is undefined.
// Avoid using `path.scope` here
export const environmentVisitor = {
TypeAnnotation(path: NodePath) {
// todo (Babel 8): remove StaticBlock brand checks
[`${t.StaticBlock ? "StaticBlock|" : ""}ClassPrivateProperty|TypeAnnotation`](
path: NodePath,
) {
path.skip();
},
@@ -55,7 +60,7 @@ export const environmentVisitor = {
path.skip();
},
"Method|ClassProperty|ClassPrivateProperty"(path: NodePath) {
"Method|ClassProperty"(path: NodePath) {
skipAllButComputedKey(path);
},
};