diff --git a/yaml/_dumper_state.ts b/yaml/_dumper_state.ts index 7771f9ad32b4..19a2fa442bfe 100644 --- a/yaml/_dumper_state.ts +++ b/yaml/_dumper_state.ts @@ -666,7 +666,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}`, ); } diff --git a/yaml/stringify_test.ts b/yaml/stringify_test.ts index 55ef4e6a59e2..0e168c718648 100644 --- a/yaml/stringify_test.ts +++ b/yaml/stringify_test.ts @@ -547,6 +547,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", () => {