Runtime error when using create() on superstruct.record with a frozen object
gwisp2 opened this issue · comments
gwisp2 commented
Code
import { record, string } from "superstruct";
const exampleStruct = record(string(), string());
console.log(exampleStruct.create(Object.freeze({ a: "b" })));
Expected result
{ "a": "b" }
Actual result
TypeError
Cannot assign to read only property 'a' of object '#'
at utils.ts#L178
Possible cause
object()
creates a Struct whose coercer
method creates a copy of the input.
record()
creates a Struct with a default coerce
method that returns the input without changes.