fix(msgpack): accept readonly input data in encode() (#5832)

feat(msgpack): accept readonly input data (#5831)
This commit is contained in:
lionel-rowe 2024-08-27 13:16:03 +08:00 committed by GitHub
parent 64d80042b1
commit 15fc72c273
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 13 additions and 1 deletions

View File

@ -13,7 +13,7 @@ export type ValueType =
| boolean
| null
| Uint8Array
| ValueType[]
| readonly ValueType[]
| ValueMap;
/**

View File

@ -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("encode() accepts `as const` data", () => {
const data = {
a: 1,
b: { c: 2 },
d: [3, { e: 4 }],
} as const;
void (() => {
encode(data);
});
});