Skip to content

Commit

Permalink
feat(msgpack): accept readonly input data (denoland#5831)
Browse files Browse the repository at this point in the history
  • Loading branch information
lionel-rowe committed Aug 26, 2024
1 parent 3946983 commit 2bf4b52
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion msgpack/encode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export type ValueType =
| boolean
| null
| Uint8Array
| ValueType[]
| readonly ValueType[]
| ValueMap;

/**
Expand Down
12 changes: 12 additions & 0 deletions msgpack/encode_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -214,3 +214,15 @@ Deno.test("encode() throws when the object is an instance of a custom class", ()
"Cannot safely encode value into messagepack",
);
});

Deno.test.only("encode() accepts `as const` data", () => {
const data = {
a: 1,
b: { c: 2 },
d: [3, { e: 4 }],
} as const;

void (() => {
encode(data);
});
});

0 comments on commit 2bf4b52

Please sign in to comment.