diff --git a/.changeset/swift-cameras-join.md b/.changeset/swift-cameras-join.md new file mode 100644 index 000000000..436a4270a --- /dev/null +++ b/.changeset/swift-cameras-join.md @@ -0,0 +1,5 @@ +--- +"@effect/schema": patch +--- + +fix missing class .struct schema diff --git a/src/Schema.ts b/src/Schema.ts index 43c44589f..f2548cf38 100644 --- a/src/Schema.ts +++ b/src/Schema.ts @@ -3789,6 +3789,8 @@ const makeClass = ( ).ast } + static struct = selfSchema + static extend() { return (fields: any) => { const newFields = { ...selfFields, ...fields } diff --git a/test/Schema/Class.test.ts b/test/Schema/Class.test.ts index 302967a00..4d0030876 100644 --- a/test/Schema/Class.test.ts +++ b/test/Schema/Class.test.ts @@ -7,7 +7,7 @@ import * as Data from "effect/Data" import * as Equal from "effect/Equal" import * as O from "effect/Option" import * as Request from "effect/Request" -import { describe, expect, it } from "vitest" +import { assert, describe, expect, it } from "vitest" class Person extends S.Class()({ id: S.number, @@ -129,6 +129,11 @@ describe("Schema/Class", () => { ) }) + it(".struct", async () => { + const person = S.parseSync(Person.struct)({ id: 1, name: "John" }) + assert.deepStrictEqual(person, { id: 1, name: "John" }) + }) + it("extends", () => { const person = S.parseSync(PersonWithAge)({ id: 1,