Closed gwisp2 closed 2 months ago
codesandbox
import { record, string } from "superstruct"; const exampleStruct = record(string(), string()); console.log(exampleStruct.create(Object.freeze({ a: "b" })));
{ "a": "b" }
TypeError Cannot assign to read only property 'a' of object '#' at utils.ts#L178
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.
object()
coercer
record()
coerce
Code
codesandbox
Expected result
Actual result
TypeError Cannot assign to read only property 'a' of object '#
Possible cause
object()
creates a Struct whosecoercer
method creates a copy of the input.record()
creates a Struct with a defaultcoerce
method that returns the input without changes.