fix(yaml): fix sortKey error message (#5873)

initial commit
This commit is contained in:
Tim Reichen 2024-09-03 06:52:38 +02:00 committed by GitHub
parent 8abff456f8
commit d01e301921
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 8 additions and 1 deletions

View File

@ -652,7 +652,8 @@ export class DumperState {
} else if (this.sortKeys) {
// Something is wrong
throw new TypeError(
'"sortKeys" must be a boolean or a function: received ${typeof this.sortKeys}',
`"sortKeys" must be a boolean or a function: received ${typeof this
.sortKeys}`,
);
}

View File

@ -553,6 +553,12 @@ Deno.test("stringify() changes the key order when the sortKeys option is specifi
1.0.10: null
`,
);
assertThrows(
() => stringify(object, { sortKeys: "true" as unknown as boolean }),
TypeError,
'"sortKeys" must be a boolean or a function: received string',
);
});
Deno.test("stringify() changes line wrap behavior based on lineWidth option", () => {