Skip to content

Commit e3b64a0

Browse files
committed
1 parent 49fccba commit e3b64a0

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

ecmascript/codegen/src/lib.rs

+11-5
Original file line numberDiff line numberDiff line change
@@ -1812,12 +1812,18 @@ impl<'a> Emitter<'a> {
18121812
fn emit_object_pat(&mut self, node: &ObjectPat) -> Result {
18131813
self.emit_leading_comments_of_pos(node.span().lo(), false)?;
18141814

1815+
let is_last_rest = match node.props.last() {
1816+
Some(ObjectPatProp::Rest(..)) => true,
1817+
_ => false,
1818+
};
1819+
let format = if is_last_rest {
1820+
ListFormat::ObjectBindingPatternElements ^ ListFormat::AllowTrailingComma
1821+
} else {
1822+
ListFormat::ObjectBindingPatternElements
1823+
};
1824+
18151825
punct!("{");
1816-
self.emit_list(
1817-
node.span(),
1818-
Some(&node.props),
1819-
ListFormat::ObjectBindingPatternElements,
1820-
)?;
1826+
self.emit_list(node.span(), Some(&node.props), format)?;
18211827
punct!("}");
18221828
if node.optional {
18231829
punct!("?");

0 commit comments

Comments
 (0)