--- source: crates/rome_formatter_test/src/snapshot_builder.rs info: test_file: js/tuple/destructuring.js --- # Input ```js const [a, b] = #[1, 2]; assert(a === 1); assert(b === 2); const [a, ...rest] = #[1, 2, 3]; assert(a === 1); assert(Array.isArray(rest)); assert(rest[0] === 2); assert(rest[1] === 3); ``` # Prettier differences ```diff --- Prettier +++ Rome @@ -1,8 +1,10 @@ -const [a, b] = #[1, 2]; +const [a, b] = #; +[1, 2]; assert(a === 1); assert(b === 2); -const [a, ...rest] = #[1, 2, 3]; +const [a, ...rest] = #; +[1, 2, 3]; assert(a === 1); assert(Array.isArray(rest)); assert(rest[0] === 2); ``` # Output ```js const [a, b] = #; [1, 2]; assert(a === 1); assert(b === 2); const [a, ...rest] = #; [1, 2, 3]; assert(a === 1); assert(Array.isArray(rest)); assert(rest[0] === 2); assert(rest[1] === 3); ``` # Errors ``` destructuring.js:1:17 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ × expected an identifier but instead found '[' > 1 │ const [a, b] = #[1, 2]; │ ^ 2 │ assert(a === 1); 3 │ assert(b === 2); i Expected an identifier here > 1 │ const [a, b] = #[1, 2]; │ ^ 2 │ assert(a === 1); 3 │ assert(b === 2); destructuring.js:1:16 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ × Private names are only allowed on the left side of a 'in' expression > 1 │ const [a, b] = #[1, 2]; │ ^ 2 │ assert(a === 1); 3 │ assert(b === 2); destructuring.js:1:17 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ × Expected a semicolon or an implicit semicolon after a statement, but found none > 1 │ const [a, b] = #[1, 2]; │ ^ 2 │ assert(a === 1); 3 │ assert(b === 2); i An explicit or implicit semicolon is expected here... > 1 │ const [a, b] = #[1, 2]; │ ^ 2 │ assert(a === 1); 3 │ assert(b === 2); i ...Which is required to end this statement > 1 │ const [a, b] = #[1, 2]; │ ^^^^^^^^^^^^^^^^ 2 │ assert(a === 1); 3 │ assert(b === 2); destructuring.js:5:23 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ × expected an identifier but instead found '[' 3 │ assert(b === 2); 4 │ > 5 │ const [a, ...rest] = #[1, 2, 3]; │ ^ 6 │ assert(a === 1); 7 │ assert(Array.isArray(rest)); i Expected an identifier here 3 │ assert(b === 2); 4 │ > 5 │ const [a, ...rest] = #[1, 2, 3]; │ ^ 6 │ assert(a === 1); 7 │ assert(Array.isArray(rest)); destructuring.js:5:22 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ × Private names are only allowed on the left side of a 'in' expression 3 │ assert(b === 2); 4 │ > 5 │ const [a, ...rest] = #[1, 2, 3]; │ ^ 6 │ assert(a === 1); 7 │ assert(Array.isArray(rest)); destructuring.js:5:23 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ × Expected a semicolon or an implicit semicolon after a statement, but found none 3 │ assert(b === 2); 4 │ > 5 │ const [a, ...rest] = #[1, 2, 3]; │ ^ 6 │ assert(a === 1); 7 │ assert(Array.isArray(rest)); i An explicit or implicit semicolon is expected here... 3 │ assert(b === 2); 4 │ > 5 │ const [a, ...rest] = #[1, 2, 3]; │ ^ 6 │ assert(a === 1); 7 │ assert(Array.isArray(rest)); i ...Which is required to end this statement 3 │ assert(b === 2); 4 │ > 5 │ const [a, ...rest] = #[1, 2, 3]; │ ^^^^^^^^^^^^^^^^^^^^^^ 6 │ assert(a === 1); 7 │ assert(Array.isArray(rest)); ```