fix(es/fixer): Handle more expressions in the super class position (#3452)

This commit is contained in:
magic-akari 2022-02-05 16:38:48 +08:00 committed by GitHub
parent 479b509845
commit 032f397b52
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -305,7 +305,15 @@ impl VisitMut for Fixer<'_> {
self.ctx = Context::Default;
node.visit_mut_children_with(self);
match &mut node.super_class {
Some(ref mut e) if e.is_seq() || e.is_await_expr() || e.is_bin() => self.wrap(&mut **e),
Some(ref mut e)
if e.is_seq()
|| e.is_await_expr()
|| e.is_bin()
|| e.is_assign()
|| e.is_cond() =>
{
self.wrap(&mut **e)
}
_ => {}
};
self.ctx = old;
@ -1330,6 +1338,30 @@ var store = global[SHARED] || (global[SHARED] = {});
"class MultiVector extends (options.baseType||Float32Array) {}"
);
identical!(
extends_nullish_coalescing,
"class Foo extends (Bar ?? class{}) {}"
);
identical!(extends_assign, "class Foo extends (Bar = class{}) {}");
identical!(
extends_logical_or_assin,
"class Foo extends (Bar ||= class{}) {}"
);
identical!(
extends_logical_and_assin,
"class Foo extends (Bar &&= class{}) {}"
);
identical!(
extends_logical_nullish_assin,
"class Foo extends (Bar ??= class{}) {}"
);
identical!(extends_cond, "class Foo extends (true ? Bar : Baz) {}");
identical!(deno_10668_1, "console.log(null ?? (undefined && true))");
identical!(deno_10668_2, "console.log(null && (undefined ?? true))");