support destructured shorthand for default parameters (#5059)

closes #4990
This commit is contained in:
Alex Lam S.L
2021-07-07 15:45:24 +01:00
committed by GitHub
parent 0c48b84540
commit 2340feff87
2 changed files with 16 additions and 4 deletions

View File

@@ -1629,7 +1629,19 @@ function OutputStream(options) {
var self = this;
var key = print_property_key(self, output);
var value = self.value;
if (key && value instanceof AST_SymbolDeclaration && key == get_symbol_name(value)) return;
if (key) {
if (value instanceof AST_DefaultValue) {
if (value.name instanceof AST_Symbol && key == get_symbol_name(value.name)) {
output.space();
output.print("=");
output.space();
value.value.print(output);
return;
}
} else if (value instanceof AST_Symbol) {
if (key == get_symbol_name(value)) return;
}
}
output.colon();
value.print(output);
});