--- source: crates/rome_formatter_test/src/snapshot_builder.rs info: test_file: js/record/spread.js --- # Input ```js const formData = #{ title: "Implement all the things" } const taskNow = #{ id: 42, status: "WIP", ...formData } const taskLater = #{ ...taskNow, status: "DONE" } // A reminder: The ordering of keys in record literals does not affect equality (and is not retained) assert(taskLater === #{ status: "DONE", title: formData.title, id: 42 }) ``` # Prettier differences ```diff --- Prettier +++ Rome @@ -1,6 +1,16 @@ -const formData = #{ title: "Implement all the things" }; -const taskNow = #{ id: 42, status: "WIP", ...formData }; -const taskLater = #{ ...taskNow, status: "DONE" }; +const formData = #; +{ + title: "Implement all the things"; +} +const taskNow = #; +{ + id: 42, status; + : "WIP", ...formData +} +const taskLater = #; +{ + ...taskNow, status: "DONE" +} // A reminder: The ordering of keys in record literals does not affect equality (and is not retained) -assert(taskLater === #{ status: "DONE", title: formData.title, id: 42 }); +assert(taskLater === #{ status: "DONE", title: formData.title, id: 42 }) ``` # Output ```js const formData = #; { title: "Implement all the things"; } const taskNow = #; { id: 42, status; : "WIP", ...formData } const taskLater = #; { ...taskNow, status: "DONE" } // A reminder: The ordering of keys in record literals does not affect equality (and is not retained) assert(taskLater === #{ status: "DONE", title: formData.title, id: 42 }) ``` # Errors ``` spread.js:1:19 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ × expected an identifier but instead found '{' > 1 │ const formData = #{ title: "Implement all the things" } │ ^ 2 │ const taskNow = #{ id: 42, status: "WIP", ...formData } 3 │ const taskLater = #{ ...taskNow, status: "DONE" } i Expected an identifier here > 1 │ const formData = #{ title: "Implement all the things" } │ ^ 2 │ const taskNow = #{ id: 42, status: "WIP", ...formData } 3 │ const taskLater = #{ ...taskNow, status: "DONE" } spread.js:1:18 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ × Private names are only allowed on the left side of a 'in' expression > 1 │ const formData = #{ title: "Implement all the things" } │ ^ 2 │ const taskNow = #{ id: 42, status: "WIP", ...formData } 3 │ const taskLater = #{ ...taskNow, status: "DONE" } spread.js:1:19 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ × Expected a semicolon or an implicit semicolon after a statement, but found none > 1 │ const formData = #{ title: "Implement all the things" } │ ^ 2 │ const taskNow = #{ id: 42, status: "WIP", ...formData } 3 │ const taskLater = #{ ...taskNow, status: "DONE" } i An explicit or implicit semicolon is expected here... > 1 │ const formData = #{ title: "Implement all the things" } │ ^ 2 │ const taskNow = #{ id: 42, status: "WIP", ...formData } 3 │ const taskLater = #{ ...taskNow, status: "DONE" } i ...Which is required to end this statement > 1 │ const formData = #{ title: "Implement all the things" } │ ^^^^^^^^^^^^^^^^^^ 2 │ const taskNow = #{ id: 42, status: "WIP", ...formData } 3 │ const taskLater = #{ ...taskNow, status: "DONE" } spread.js:2:18 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ × expected an identifier but instead found '{' 1 │ const formData = #{ title: "Implement all the things" } > 2 │ const taskNow = #{ id: 42, status: "WIP", ...formData } │ ^ 3 │ const taskLater = #{ ...taskNow, status: "DONE" } 4 │ i Expected an identifier here 1 │ const formData = #{ title: "Implement all the things" } > 2 │ const taskNow = #{ id: 42, status: "WIP", ...formData } │ ^ 3 │ const taskLater = #{ ...taskNow, status: "DONE" } 4 │ spread.js:2:17 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ × Private names are only allowed on the left side of a 'in' expression 1 │ const formData = #{ title: "Implement all the things" } > 2 │ const taskNow = #{ id: 42, status: "WIP", ...formData } │ ^ 3 │ const taskLater = #{ ...taskNow, status: "DONE" } 4 │ spread.js:2:18 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ × Expected a semicolon or an implicit semicolon after a statement, but found none 1 │ const formData = #{ title: "Implement all the things" } > 2 │ const taskNow = #{ id: 42, status: "WIP", ...formData } │ ^ 3 │ const taskLater = #{ ...taskNow, status: "DONE" } 4 │ i An explicit or implicit semicolon is expected here... 1 │ const formData = #{ title: "Implement all the things" } > 2 │ const taskNow = #{ id: 42, status: "WIP", ...formData } │ ^ 3 │ const taskLater = #{ ...taskNow, status: "DONE" } 4 │ i ...Which is required to end this statement 1 │ const formData = #{ title: "Implement all the things" } > 2 │ const taskNow = #{ id: 42, status: "WIP", ...formData } │ ^^^^^^^^^^^^^^^^^ 3 │ const taskLater = #{ ...taskNow, status: "DONE" } 4 │ spread.js:2:34 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ × Expected a semicolon or an implicit semicolon after a statement, but found none 1 │ const formData = #{ title: "Implement all the things" } > 2 │ const taskNow = #{ id: 42, status: "WIP", ...formData } │ ^ 3 │ const taskLater = #{ ...taskNow, status: "DONE" } 4 │ i An explicit or implicit semicolon is expected here... 1 │ const formData = #{ title: "Implement all the things" } > 2 │ const taskNow = #{ id: 42, status: "WIP", ...formData } │ ^ 3 │ const taskLater = #{ ...taskNow, status: "DONE" } 4 │ i ...Which is required to end this statement 1 │ const formData = #{ title: "Implement all the things" } > 2 │ const taskNow = #{ id: 42, status: "WIP", ...formData } │ ^^^^^^^^^^^ 3 │ const taskLater = #{ ...taskNow, status: "DONE" } 4 │ spread.js:3:20 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ × expected an identifier but instead found '{' 1 │ const formData = #{ title: "Implement all the things" } 2 │ const taskNow = #{ id: 42, status: "WIP", ...formData } > 3 │ const taskLater = #{ ...taskNow, status: "DONE" } │ ^ 4 │ 5 │ // A reminder: The ordering of keys in record literals does not affect equality (and is not retained) i Expected an identifier here 1 │ const formData = #{ title: "Implement all the things" } 2 │ const taskNow = #{ id: 42, status: "WIP", ...formData } > 3 │ const taskLater = #{ ...taskNow, status: "DONE" } │ ^ 4 │ 5 │ // A reminder: The ordering of keys in record literals does not affect equality (and is not retained) spread.js:3:19 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ × Private names are only allowed on the left side of a 'in' expression 1 │ const formData = #{ title: "Implement all the things" } 2 │ const taskNow = #{ id: 42, status: "WIP", ...formData } > 3 │ const taskLater = #{ ...taskNow, status: "DONE" } │ ^ 4 │ 5 │ // A reminder: The ordering of keys in record literals does not affect equality (and is not retained) spread.js:3:20 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ × Expected a semicolon or an implicit semicolon after a statement, but found none 1 │ const formData = #{ title: "Implement all the things" } 2 │ const taskNow = #{ id: 42, status: "WIP", ...formData } > 3 │ const taskLater = #{ ...taskNow, status: "DONE" } │ ^ 4 │ 5 │ // A reminder: The ordering of keys in record literals does not affect equality (and is not retained) i An explicit or implicit semicolon is expected here... 1 │ const formData = #{ title: "Implement all the things" } 2 │ const taskNow = #{ id: 42, status: "WIP", ...formData } > 3 │ const taskLater = #{ ...taskNow, status: "DONE" } │ ^ 4 │ 5 │ // A reminder: The ordering of keys in record literals does not affect equality (and is not retained) i ...Which is required to end this statement 1 │ const formData = #{ title: "Implement all the things" } 2 │ const taskNow = #{ id: 42, status: "WIP", ...formData } > 3 │ const taskLater = #{ ...taskNow, status: "DONE" } │ ^^^^^^^^^^^^^^^^^^^ 4 │ 5 │ // A reminder: The ordering of keys in record literals does not affect equality (and is not retained) spread.js:3:22 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ × expected an expression but instead found '...taskNow, status: "DONE"' 1 │ const formData = #{ title: "Implement all the things" } 2 │ const taskNow = #{ id: 42, status: "WIP", ...formData } > 3 │ const taskLater = #{ ...taskNow, status: "DONE" } │ ^^^^^^^^^^^^^^^^^^^^^^^^^^ 4 │ 5 │ // A reminder: The ordering of keys in record literals does not affect equality (and is not retained) i Expected an expression here 1 │ const formData = #{ title: "Implement all the things" } 2 │ const taskNow = #{ id: 42, status: "WIP", ...formData } > 3 │ const taskLater = #{ ...taskNow, status: "DONE" } │ ^^^^^^^^^^^^^^^^^^^^^^^^^^ 4 │ 5 │ // A reminder: The ordering of keys in record literals does not affect equality (and is not retained) spread.js:6:23 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ × expected an identifier but instead found '{' 5 │ // A reminder: The ordering of keys in record literals does not affect equality (and is not retained) > 6 │ assert(taskLater === #{ status: "DONE", title: formData.title, id: 42 }) │ ^ 7 │ i Expected an identifier here 5 │ // A reminder: The ordering of keys in record literals does not affect equality (and is not retained) > 6 │ assert(taskLater === #{ status: "DONE", title: formData.title, id: 42 }) │ ^ 7 │ spread.js:6:22 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ × Private names are only allowed on the left side of a 'in' expression 5 │ // A reminder: The ordering of keys in record literals does not affect equality (and is not retained) > 6 │ assert(taskLater === #{ status: "DONE", title: formData.title, id: 42 }) │ ^ 7 │ spread.js:6:23 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ × expected `,` but instead found `{` 5 │ // A reminder: The ordering of keys in record literals does not affect equality (and is not retained) > 6 │ assert(taskLater === #{ status: "DONE", title: formData.title, id: 42 }) │ ^ 7 │ i Remove { ``` # Lines exceeding max width of 80 characters ``` 15: // A reminder: The ordering of keys in record literals does not affect equality (and is not retained) ```