--- source: crates/rome_formatter_test/src/snapshot_builder.rs info: test_file: js/record/destructuring.js --- # Input ```js const { a, b } = #{ a: 1, b: 2 }; assert(a === 1); assert(b === 2); const { a, ...rest } = #{ a: 1, b: 2, c: 3 }; assert(a === 1); assert(typeof rest === "object"); assert(rest.b === 2); assert(rest.c === 3); ``` # Prettier differences ```diff --- Prettier +++ Rome @@ -1,8 +1,16 @@ -const { a, b } = #{ a: 1, b: 2 }; +const { a, b } = #; +{ + a: 1, b; + : 2 +} assert(a === 1); assert(b === 2); -const { a, ...rest } = #{ a: 1, b: 2, c: 3 }; +const { a, ...rest } = #; +{ + a: 1, b; + : 2, c: 3 +} assert(a === 1); assert(typeof rest === "object"); assert(rest.b === 2); ``` # Output ```js const { a, b } = #; { a: 1, b; : 2 } assert(a === 1); assert(b === 2); const { a, ...rest } = #; { a: 1, b; : 2, c: 3 } assert(a === 1); assert(typeof rest === "object"); assert(rest.b === 2); assert(rest.c === 3); ``` # Errors ``` destructuring.js:1:19 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ × expected an identifier but instead found '{' > 1 │ const { a, b } = #{ a: 1, b: 2 }; │ ^ 2 │ assert(a === 1); 3 │ assert(b === 2); i Expected an identifier here > 1 │ const { a, b } = #{ a: 1, b: 2 }; │ ^ 2 │ assert(a === 1); 3 │ assert(b === 2); destructuring.js:1:18 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ × Private names are only allowed on the left side of a 'in' expression > 1 │ const { a, b } = #{ a: 1, b: 2 }; │ ^ 2 │ assert(a === 1); 3 │ assert(b === 2); destructuring.js:1:19 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ × Expected a semicolon or an implicit semicolon after a statement, but found none > 1 │ const { a, b } = #{ a: 1, b: 2 }; │ ^ 2 │ assert(a === 1); 3 │ assert(b === 2); i An explicit or implicit semicolon is expected here... > 1 │ const { a, b } = #{ a: 1, b: 2 }; │ ^ 2 │ assert(a === 1); 3 │ assert(b === 2); i ...Which is required to end this statement > 1 │ const { a, b } = #{ a: 1, b: 2 }; │ ^^^^^^^^^^^^^^^^^^ 2 │ assert(a === 1); 3 │ assert(b === 2); destructuring.js:1:28 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ × Expected a semicolon or an implicit semicolon after a statement, but found none > 1 │ const { a, b } = #{ a: 1, b: 2 }; │ ^ 2 │ assert(a === 1); 3 │ assert(b === 2); i An explicit or implicit semicolon is expected here... > 1 │ const { a, b } = #{ a: 1, b: 2 }; │ ^ 2 │ assert(a === 1); 3 │ assert(b === 2); i ...Which is required to end this statement > 1 │ const { a, b } = #{ a: 1, b: 2 }; │ ^^^^^ 2 │ assert(a === 1); 3 │ assert(b === 2); destructuring.js:5:25 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ × expected an identifier but instead found '{' 3 │ assert(b === 2); 4 │ > 5 │ const { a, ...rest } = #{ a: 1, b: 2, c: 3 }; │ ^ 6 │ assert(a === 1); 7 │ assert(typeof rest === "object"); i Expected an identifier here 3 │ assert(b === 2); 4 │ > 5 │ const { a, ...rest } = #{ a: 1, b: 2, c: 3 }; │ ^ 6 │ assert(a === 1); 7 │ assert(typeof rest === "object"); destructuring.js:5:24 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ × Private names are only allowed on the left side of a 'in' expression 3 │ assert(b === 2); 4 │ > 5 │ const { a, ...rest } = #{ a: 1, b: 2, c: 3 }; │ ^ 6 │ assert(a === 1); 7 │ assert(typeof rest === "object"); destructuring.js:5:25 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ × Expected a semicolon or an implicit semicolon after a statement, but found none 3 │ assert(b === 2); 4 │ > 5 │ const { a, ...rest } = #{ a: 1, b: 2, c: 3 }; │ ^ 6 │ assert(a === 1); 7 │ assert(typeof rest === "object"); i An explicit or implicit semicolon is expected here... 3 │ assert(b === 2); 4 │ > 5 │ const { a, ...rest } = #{ a: 1, b: 2, c: 3 }; │ ^ 6 │ assert(a === 1); 7 │ assert(typeof rest === "object"); i ...Which is required to end this statement 3 │ assert(b === 2); 4 │ > 5 │ const { a, ...rest } = #{ a: 1, b: 2, c: 3 }; │ ^^^^^^^^^^^^^^^^^^^^^^^^ 6 │ assert(a === 1); 7 │ assert(typeof rest === "object"); destructuring.js:5:34 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ × Expected a semicolon or an implicit semicolon after a statement, but found none 3 │ assert(b === 2); 4 │ > 5 │ const { a, ...rest } = #{ a: 1, b: 2, c: 3 }; │ ^ 6 │ assert(a === 1); 7 │ assert(typeof rest === "object"); i An explicit or implicit semicolon is expected here... 3 │ assert(b === 2); 4 │ > 5 │ const { a, ...rest } = #{ a: 1, b: 2, c: 3 }; │ ^ 6 │ assert(a === 1); 7 │ assert(typeof rest === "object"); i ...Which is required to end this statement 3 │ assert(b === 2); 4 │ > 5 │ const { a, ...rest } = #{ a: 1, b: 2, c: 3 }; │ ^^^^^ 6 │ assert(a === 1); 7 │ assert(typeof rest === "object"); ```